Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1978552pxb; Fri, 5 Mar 2021 04:38:25 -0800 (PST) X-Google-Smtp-Source: ABdhPJzF3GRVKRkbKYA6bkwAPnqcCSVHq5cYW/ka1Gp2lU+c7OKx7dZnkN67W5I+O85q1GEDEhWD X-Received: by 2002:aa7:c78e:: with SMTP id n14mr8741215eds.31.1614947905554; Fri, 05 Mar 2021 04:38:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947905; cv=none; d=google.com; s=arc-20160816; b=O86MDGpX9AGfLRVzrFPYMWsVeibac2Zrz8zHVWlpzPprs0EfQG8QsjOV4spoLsrJ4p jCvllkMAfCFmjifkIdwCGSBApEk/+d0bhx4FPeS9DZFKQiZN/7zUeI7JW41KoJSsfdDa 6ButfwmJERt8szDog8rsB1iRvDTvkHkSuz18ru6hiUeymubFXnGEm5I7BfMcnEl7fYpo TQJSicdbYmOo6qWi66C3bD9skmgTJZGOATyFJdtnPaK+Ncug3Y3iL0znq7n0uSGxpwlz y0tnj41zkjfLQWAiHALQCbPxEKwCPv/UI+olgmmCEb9iN4O++nZ1S4uPLNqsJ9lyCtjn 3R4Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=nUM/s0FbxKWH3QxGrEGMvgQP47egzpsH6WtLOM8K6VQ=; b=hq6dJoPEwr5cr4gRAiFGc1X4Juy8fG6b+2hgvPA31tqfYEHS768eEC2CRssqTPVwCx Vofx7Qsr39JIirJjkwCOYhxDeOqOmBDiim74eU6SRUlDMGJ73wmsUrxjSmj+X+6nRgHJ hj0qjklhEMJuRE8RGeRpObiwpjj6Gxd3xVzUG+g2UTr3bx/khk/jO4f9SP4frO/c2eW4 Fc7qLnNRCAmpjbPg0vxTMX8Y3mLDM2pAEU1UuuK63JYC6VF8xpnt6TmDwjYZ5TPBcPBT NYgW0i3dqUB5vNj2M3G1pu4MQHJj4ot3hVxlNcSb2DdwHoqJ0T4MoKnlK1leUwoe55ag uY1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="H/139ZSw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ay21si1249024ejb.527.2021.03.05.04.38.02; Fri, 05 Mar 2021 04:38:25 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="H/139ZSw"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232889AbhCEMge (ORCPT + 99 others); Fri, 5 Mar 2021 07:36:34 -0500 Received: from mail.kernel.org ([198.145.29.99]:49022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231169AbhCEMgH (ORCPT ); Fri, 5 Mar 2021 07:36:07 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0C3965004; Fri, 5 Mar 2021 12:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947766; bh=YCyo7jLMHyREv5b4CJsE4SH9lBSX6ViiLthbpeXBfPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H/139ZSwg5g62poeKjiKqpjGfbMtDPkY4goF//4CUbNwGOfUKFyRD5lbO5YrDwsGZ KAVFCu5uj/OzpgnpaqYaa1s/vQEvgB3VtypBspYAZXkiGtR/mEY7FZrDhdXYkNrKb0 7UHgvEHh7AnlK/Fjh4uTUkoNxmNzLGzjnc03voeE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Adam Nichols , Chris Leech , Mike Christie , Lee Duncan , "Martin K. Petersen" Subject: [PATCH 5.4 61/72] scsi: iscsi: Restrict sessions and handles to admin capabilities Date: Fri, 5 Mar 2021 13:22:03 +0100 Message-Id: <20210305120900.323493568@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Lee Duncan commit 688e8128b7a92df982709a4137ea4588d16f24aa upstream. Protect the iSCSI transport handle, available in sysfs, by requiring CAP_SYS_ADMIN to read it. Also protect the netlink socket by restricting reception of messages to ones sent with CAP_SYS_ADMIN. This disables normal users from being able to end arbitrary iSCSI sessions. Cc: stable@vger.kernel.org Reported-by: Adam Nichols Reviewed-by: Chris Leech Reviewed-by: Mike Christie Signed-off-by: Lee Duncan Signed-off-by: Martin K. Petersen Signed-off-by: Greg Kroah-Hartman --- drivers/scsi/scsi_transport_iscsi.c | 6 ++++++ 1 file changed, 6 insertions(+) --- a/drivers/scsi/scsi_transport_iscsi.c +++ b/drivers/scsi/scsi_transport_iscsi.c @@ -124,6 +124,9 @@ show_transport_handle(struct device *dev char *buf) { struct iscsi_internal *priv = dev_to_iscsi_internal(dev); + + if (!capable(CAP_SYS_ADMIN)) + return -EACCES; return sprintf(buf, "%llu\n", (unsigned long long)iscsi_handle(priv->iscsi_transport)); } static DEVICE_ATTR(handle, S_IRUGO, show_transport_handle, NULL); @@ -3506,6 +3509,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, s struct iscsi_cls_conn *conn; struct iscsi_endpoint *ep = NULL; + if (!netlink_capable(skb, CAP_SYS_ADMIN)) + return -EPERM; + if (nlh->nlmsg_type == ISCSI_UEVENT_PATH_UPDATE) *group = ISCSI_NL_GRP_UIP; else