From nobody Fri Jun 17 19:41:09 2022 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 5887985D7BF; Fri, 17 Jun 2022 19:41:11 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4LPqCp6bBPz3ht2; Fri, 17 Jun 2022 19:41:10 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jGXR9Yscooj7DR9tU+X30fQA0l1DcOSySgF52BBeEE0=; b=ui/jeQvwVupwIJaGUbkjvqZ3ONBX7kpytl5o7fGxPCyr95Y8SGazi6J8rLColV6/vjW2kX AsdP+V53Gf+mHYPZkmmY3qphYwKnV0+IKwp6qOkKhioJ1MsceHpuCRXAxh5zXbZCqKYlai LeAB4iTkNm1tltzaLp4OQzM6Cv6ey+If5l1AjduPQKOf4fGQHLhwIXGijzBvIXCrusk0Rw ha3JaXzBvZRZKi1dUorvVAEI6CiwiXHMvwRPAGZx1jAbEwu7evQVaTSV292f6pv7w9yxPx Kob2eqaX+DsjRpQB0EFhy8EeDwdm0GDOiXCoBKe5HVV/va36fD2RxSGVJXHoUw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id DFB2525DAA; Fri, 17 Jun 2022 19:41:09 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 25HJf9ZM030107; Fri, 17 Jun 2022 19:41:09 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 25HJf9pp030106; Fri, 17 Jun 2022 19:41:09 GMT (envelope-from git) Date: Fri, 17 Jun 2022 19:41:09 GMT Message-Id: <202206171941.25HJf9pp030106@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Dmitry Chagin Subject: git: e23fea0a08c0 - stable/13 - linux(4): Avoid EISCONN if addr is specified for sendto() List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dchagin X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: e23fea0a08c0d436ea51efdd035db55fc8001472 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1655494871; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=jGXR9Yscooj7DR9tU+X30fQA0l1DcOSySgF52BBeEE0=; b=fZ1jIPzJYZYt7u23nDYKEFkAGb0Xm7xm5Hyl63S5E71ju8mN/G89i4MtfvImdd251DhDSR zC4MXUG0DrJlYnVtnA6s5Cl1V1eLJH9GYoKsfelV2EV0Oay27UFzEj/EdNGHtf73eCGKp8 97KnYuUC7CWkEfGL4R6M/k6MWPWwvAmlh41BQ2oTwdJb2yrGynZGyF1saf5eLzuAxcf8Al 85kbbkEOBp7VGrlI36ORle8HNUzvodG3h723UrzDRiorXuMR3Qx4se5aap3yy7Y3eqfNsN 4ElI1uMQfOhoGPThrqvufDRaloVxjXbbAyTcBF3o5biuqEAFx7cZhacKxfXxXg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1655494871; a=rsa-sha256; cv=none; b=jLbPT7RuANGLAvqmzekgjmTo0XrWKAiqQaT2Q3dae3lO7StZPUzyO9vHxxdTphxhGNJ8VR baSJIMIaANg1/Sn5VcBcTSbifW9xpzlXrOJygA74yzTfKhL6SiHe0aHBebkpBwASPcqUoY x3TdSRmLGXF/FL0RxI/P7zezsiDCWOQXCbyVVhTCrP/L59d+bJR2dNTBzb1FRUJU42FgvN YFCDaibEgtx5uKmjV61nPdo5lN86RqklQ3TaWmNvQijxSacvaGs+B/w+k6SMMxY8QHDRL9 k/Wi+WXetSgMoUAyghkINAO9BtcMBaFQzOR0SF5PG4IuiaJ+i+N7gFtoo2g7iA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=e23fea0a08c0d436ea51efdd035db55fc8001472 commit e23fea0a08c0d436ea51efdd035db55fc8001472 Author: Dmitry Chagin AuthorDate: 2022-05-28 20:42:09 +0000 Commit: Dmitry Chagin CommitDate: 2022-06-17 19:35:33 +0000 linux(4): Avoid EISCONN if addr is specified for sendto() If the socket is in a connected state, the target address should be ignored. MFC after: 2 weeks (cherry picked from commit db48fa8319825b4428795fcef9fb5458ac34c1a9) --- sys/compat/linux/linux_socket.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/sys/compat/linux/linux_socket.c b/sys/compat/linux/linux_socket.c index 1214c2e1fa24..71f958b57298 100644 --- a/sys/compat/linux/linux_socket.c +++ b/sys/compat/linux/linux_socket.c @@ -1238,19 +1238,29 @@ linux_sendto(struct thread *td, struct linux_sendto_args *args) { struct msghdr msg; struct iovec aiov; + struct socket *so; + struct file *fp; + int error; if (linux_check_hdrincl(td, args->s) == 0) /* IP_HDRINCL set, tweak the packet before sending */ return (linux_sendto_hdrincl(td, args)); - msg.msg_name = PTRIN(args->to); - msg.msg_namelen = args->tolen; + bzero(&msg, sizeof(msg)); + error = getsock_cap(td, args->s, &cap_send_connect_rights, + &fp, NULL, NULL); + if (error != 0) + return (error); + so = fp->f_data; + if ((so->so_state & (SS_ISCONNECTED|SS_ISCONNECTING)) == 0) { + msg.msg_name = PTRIN(args->to); + msg.msg_namelen = args->tolen; + } msg.msg_iov = &aiov; msg.msg_iovlen = 1; - msg.msg_control = NULL; - msg.msg_flags = 0; aiov.iov_base = PTRIN(args->msg); aiov.iov_len = args->len; + fdrop(fp, td); return (linux_sendit(td, args->s, &msg, args->flags, NULL, UIO_USERSPACE)); }