From nobody Sat May 28 20:53:19 2022 X-Original-To: dev-commits-src-all@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 2BAA51B47EC5; Sat, 28 May 2022 20:53:20 +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 4L9YmH6jTJz4l48; Sat, 28 May 2022 20:53:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653771200; 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=MPzh4dAJ8bEAcrM3n7vmhNohFz57gq2GvkofERYeFtI=; b=l/1MGACfJKkBPLXQlmKA/yMp/1yphZwtoO+vkug8ABhftivAU2DPs3hJDCCZSs9B/NOkFH JLR+Qdla2teCpPnR2EDoN7EiGQ7liNJFIlaNF5cBWiQoO52LMtfi7HVJ7Q9d2iAiGnAN7l Gy/rKdURk5RUJX41wGiUFrx6pjmSK2QTS4+6XcrAduEiJY6IO9XoSkDruhXRdmD6oicklq W2+3KfxsjBqykBPWeqDdKFmFIByYgLiRPr93ckuDqwxfRki57e9ZxdiV/nLt3pfANGvpCq xCPPYF0L0JViz4PLaExOKvj6fuzGFAeWtzbYwV/UMxTz045bvrmcAHnW3xGFYA== 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 929741603F; Sat, 28 May 2022 20:53:19 +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 24SKrJd7099306; Sat, 28 May 2022 20:53:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 24SKrJOl099305; Sat, 28 May 2022 20:53:19 GMT (envelope-from git) Date: Sat, 28 May 2022 20:53:19 GMT Message-Id: <202205282053.24SKrJOl099305@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Dmitry Chagin Subject: git: db48fa831982 - main - linux(4): Avoid EISCONN if addr is specified for sendto() List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/main X-Git-Reftype: branch X-Git-Commit: db48fa8319825b4428795fcef9fb5458ac34c1a9 Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1653771200; 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=MPzh4dAJ8bEAcrM3n7vmhNohFz57gq2GvkofERYeFtI=; b=cjMx66hhicLqDPM80Eom6UxMjIjsgjaoU3fQohpRxpWFlJ3agE236xStZA8j9Jygw252gT hlXInsOPA8WinZ/aq8xVCVyZpj/MU9bqm+bik59Vfcf35i8fdjL3RM1RuAVmUTdmStlVDG ljC3u3URHHS0XH0qXb6VO5a07YYrMQllTQMRpgQzaXFZDyowNVUT/XJjXE4Mm9h30ubP8S hVpbES+eh4keyEYuTuOU1aWtPEqc5DuJ8BY/WV2jG0uZ5+3qGOzpPqQk2CGmJn0rbgDuio skkx1HIczm0KdbLyasqMgM45+rSRSPt8DxIONqBPZw5dNLUp5p7Wd8yW8kU/3Q== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1653771200; a=rsa-sha256; cv=none; b=WqIp0Jqy+laB7ag8pMdOy035GCs7VLSqpWyLDSv8xfULyGFxbWvyNuc029c3nujQ0KenNz Z8s/KRwzNLKfnZYkAFgx0FCvs5ThmzwLgsVypk3UxxTmunLGHcwjsQQRuDFEwX4dhB/4fu JU+4qhWYnjhOZsdciNahsSVPBY079LFCfHCregl6DN9CON+RgrPXBaPgVbiu5+ZrHvJvjr /CsL12b0UPnBA8GrWyRVm1Q+1wfiMAGiEh7dp9fvHTdaBEWLo1OD6xcLcHxwH1XiJxBHqP yd9nZeFN6X6yQnJQBVdBVMHdEh8pAKqYBZOfBkciYTiWkLSek5sgHcy4Q84yAg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dchagin: URL: https://cgit.FreeBSD.org/src/commit/?id=db48fa8319825b4428795fcef9fb5458ac34c1a9 commit db48fa8319825b4428795fcef9fb5458ac34c1a9 Author: Dmitry Chagin AuthorDate: 2022-05-28 20:42:09 +0000 Commit: Dmitry Chagin CommitDate: 2022-05-28 20:42:09 +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 --- 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)); }