Message ID | 20230915171111.4057930-1-edumazet@google.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp1351203vqi; Fri, 15 Sep 2023 15:17:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqSBpDYPJ+YkUdq+MAGWC+G0/IwezlU4aEHPOZq0CIftqTnDwMBQXJntCGOcDfheFXkClr X-Received: by 2002:a17:90a:688f:b0:274:8e3b:27cd with SMTP id a15-20020a17090a688f00b002748e3b27cdmr2734558pjd.14.1694816265780; Fri, 15 Sep 2023 15:17:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694816265; cv=none; d=google.com; s=arc-20160816; b=P60V7HEg0r7d/ISkVvlrD8t5VkApBvSL2iQDz14JPpcUi3zjNFMo1lm8JF1QUFDzjk NCoaVI6X63oeKnTxpBLv2tNP1Yid9/V4sbNV45ZKCDrOIkK0gTAG18TKQY9WZqZHW5dL y50SyHN+ATv96nHiXbeulgPccMGSJhX3uWigrG/1olgQiFkI3pbqaVOKD6iU3HeegtYM uRRXCDY7uQ3HuNkzqnxoYglAXD08KPy9AVSMUjPN85031PgilgjbEI4vM1nW8zoJAUqA ChqayLYL1Es44q86BQAy3mHvMU3kY9Ft7o9/inBNCJyDftqEipGWqIu1F51SNklgYvK7 s59w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:from:subject:message-id:mime-version:date :dkim-signature; bh=bOqFz4mwu4R8vVhIHYO47D/MyrIS2uBdDRxhIpCvwuY=; fh=mC1xPb9pA9fkPw7yIP8Af0r6rIXWuZ/YUJAoR4tDsf0=; b=kZyH21grtk+IEqDOAyzLsBQeVJq4558nHDaw1z80Z3C4Gsl6PJ7HA+vLbSAxqZVUGz dv91a1t15+bGfVpGi8+2llwU73Bah44ZIvXT5epxCWjaGCVcDBr15PIT5n3Bf55A/oWR thwqXzC6L0w5V2BqkfsT64a+GsahTTnqfPI0j0KYS5ij4DgsQ2wkwdJv0kQVi6ztvILP Fp1AMLJGDP6TICROdioXm3rCkgGW/AZ40lIXia0yqIceOXsHQvkPm4TpCxIAkMTsyxkd 6GPo3W4Oqs7wDER1/0VTt2lJ852hVhEwumuc8QJQpz9SJhvUA3GtIlSTU3oFVFLH2lsi i3ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JwG+DbNs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id kx1-20020a17090b228100b00274b668b762si522049pjb.172.2023.09.15.15.17.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 15:17:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=JwG+DbNs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id 7B27F835154F; Fri, 15 Sep 2023 10:12:09 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235448AbjIORLc (ORCPT <rfc822;ruipengqi7@gmail.com> + 30 others); Fri, 15 Sep 2023 13:11:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235452AbjIORLV (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 15 Sep 2023 13:11:21 -0400 Received: from mail-yb1-xb4a.google.com (mail-yb1-xb4a.google.com [IPv6:2607:f8b0:4864:20::b4a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3D2EDE6D for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 10:11:15 -0700 (PDT) Received: by mail-yb1-xb4a.google.com with SMTP id 3f1490d57ef6-d8191a1d5acso2440519276.1 for <linux-kernel@vger.kernel.org>; Fri, 15 Sep 2023 10:11:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1694797874; x=1695402674; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=bOqFz4mwu4R8vVhIHYO47D/MyrIS2uBdDRxhIpCvwuY=; b=JwG+DbNsDLV9VBySrOCi5UcX1b+LS9Fwx3tlhXxoP8wrVMUFqFAwOMejtEb2gnVkhh d4ShbJCa06o/n1ggzQ/CQQJxq+ejRVKK6k0sX0LPfwcAMiEK5Y+Rx668AlEldyo2vGmP cRxKD4u3FMNiMQj6seoRTGyQa3dAXr++DZiiJEGrBfZXfkjcamOIhtBdZ8Rj3HQINyvy LjGi0T5bySYIJZY4kmMzR3qGl91DR+ZgR8AtVVt0UZbXgoZDzWyogNN13Vbo1FSX7CxD QGiOB/LXNv6ZPGwkx5y89+wXYETRyBNcBt1jS6VymByrj4DLXTcfroic3NF28O9705zB 6seg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694797874; x=1695402674; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=bOqFz4mwu4R8vVhIHYO47D/MyrIS2uBdDRxhIpCvwuY=; b=Ye2hv8D/5azhcH/yJ/nyL45HCD4pamMgHRPvyPnWZea3/mKNDeviVjb5DYNDI14B6Z R13hhTG3b2T9s6C//hxlmfkARqszTe/vJRsXpS20Li7hC2Ix2HOwlWb8bjSPRsm6JJnl htcr8VV0xC3xvN3T8EAKTHvL1vS7t7+uUMdjHvcFv+tVmQ008dJxJqoghKanta3pliZC 5V1+BdkNSh9Q/CZMxjJlZ/aZke4wVd6wQMsZzc5KexpikhMDQJFe8xnmPB+Bn8z3RfRh cit3jzyY8X+NzDr0poBaSWk1RZnZnrJY320+BZUnA/312XesVe4QVYNOK2q6TOQ5naPZ mDOw== X-Gm-Message-State: AOJu0YwwSY6rdKL/r6T1IDIdZRbMu7BCaFEfJgxZzqdh3dwJwOYpIwi6 mos+zYm48/GwIDbykMmWuD5+gktCN8gUWw== X-Received: from edumazet1.c.googlers.com ([fda3:e722:ac3:cc00:2b:7d90:c0a8:395a]) (user=edumazet job=sendgmr) by 2002:a05:6902:118a:b0:d80:183c:92b9 with SMTP id m10-20020a056902118a00b00d80183c92b9mr60345ybu.4.1694797874299; Fri, 15 Sep 2023 10:11:14 -0700 (PDT) Date: Fri, 15 Sep 2023 17:11:11 +0000 Mime-Version: 1.0 X-Mailer: git-send-email 2.42.0.459.ge4e396fd5e-goog Message-ID: <20230915171111.4057930-1-edumazet@google.com> Subject: [PATCH] scsi: iscsi_tcp: restrict to TCP sockets From: Eric Dumazet <edumazet@google.com> To: Lee Duncan <lduncan@suse.com>, Mike Christie <michael.christie@oracle.com>, Chris Leech <cleech@redhat.com> Cc: linux-kernel <linux-kernel@vger.kernel.org>, netdev@vger.kernel.org, Eric Dumazet <edumazet@google.com>, Eric Dumazet <eric.dumazet@gmail.com>, "James E.J. Bottomley" <jejb@linux.ibm.com>, "Martin K. Petersen" <martin.petersen@oracle.com>, open-iscsi@googlegroups.com, linux-scsi@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-8.4 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 15 Sep 2023 10:12:09 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777143660967157406 X-GMAIL-MSGID: 1777143660967157406 |
Series |
scsi: iscsi_tcp: restrict to TCP sockets
|
|
Commit Message
Eric Dumazet
Sept. 15, 2023, 5:11 p.m. UTC
Nothing prevents iscsi_sw_tcp_conn_bind() to receive file descriptor
pointing to non TCP socket (af_unix for example).
Return -EINVAL if this is attempted, instead of crashing the kernel.
Fixes: 7ba247138907 ("[SCSI] open-iscsi/linux-iscsi-5 Initiator: Initiator code")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Cc: Lee Duncan <lduncan@suse.com>
Cc: Chris Leech <cleech@redhat.com>
Cc: Mike Christie <michael.christie@oracle.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: open-iscsi@googlegroups.com
Cc: linux-scsi@vger.kernel.org
---
drivers/scsi/iscsi_tcp.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On 9/15/23 12:11 PM, Eric Dumazet wrote: > Nothing prevents iscsi_sw_tcp_conn_bind() to receive file descriptor > pointing to non TCP socket (af_unix for example). > > Return -EINVAL if this is attempted, instead of crashing the kernel. > Reviewed-by: Mike Christie <michael.christie@oracle.com>
Hello: This patch was applied to netdev/net.git (main) by David S. Miller <davem@davemloft.net>: On Fri, 15 Sep 2023 17:11:11 +0000 you wrote: > Nothing prevents iscsi_sw_tcp_conn_bind() to receive file descriptor > pointing to non TCP socket (af_unix for example). > > Return -EINVAL if this is attempted, instead of crashing the kernel. > > Fixes: 7ba247138907 ("[SCSI] open-iscsi/linux-iscsi-5 Initiator: Initiator code") > Signed-off-by: Eric Dumazet <edumazet@google.com> > Cc: Lee Duncan <lduncan@suse.com> > Cc: Chris Leech <cleech@redhat.com> > Cc: Mike Christie <michael.christie@oracle.com> > Cc: "James E.J. Bottomley" <jejb@linux.ibm.com> > Cc: "Martin K. Petersen" <martin.petersen@oracle.com> > Cc: open-iscsi@googlegroups.com > Cc: linux-scsi@vger.kernel.org > > [...] Here is the summary with links: - scsi: iscsi_tcp: restrict to TCP sockets https://git.kernel.org/netdev/net/c/f4f82c52a0ea You are awesome, thank you!
diff --git a/drivers/scsi/iscsi_tcp.c b/drivers/scsi/iscsi_tcp.c index 9ab8555180a3a0bd159b621a57c99bcb8f0413ae..8e14cea15f980829e99afa2c43bf6872fcfd965c 100644 --- a/drivers/scsi/iscsi_tcp.c +++ b/drivers/scsi/iscsi_tcp.c @@ -724,6 +724,10 @@ iscsi_sw_tcp_conn_bind(struct iscsi_cls_session *cls_session, return -EEXIST; } + err = -EINVAL; + if (!sk_is_tcp(sock->sk)) + goto free_socket; + err = iscsi_conn_bind(cls_session, cls_conn, is_leading); if (err) goto free_socket;