Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1980805pxb; Fri, 5 Mar 2021 04:41:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJzQjow2/W9xn4dUAinV30Hg4CkJwTUFO9QLo/G7ZhH0HZwkkfILfNkQYsHOEb8F92RnO4Cc X-Received: by 2002:a17:906:1d44:: with SMTP id o4mr1914538ejh.130.1614948117650; Fri, 05 Mar 2021 04:41:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614948117; cv=none; d=google.com; s=arc-20160816; b=jwMu1+dy9ih/XnzDmVjI/CvUOUtgQepDlkzh2Qw7SIY6Jhd8CxiWyzQhmhamyAYEHH 7km33sxDSCRBdCailnQ0BAUH+M0vOtHdgTkdWfLXMQyetsLRW7VhqKcKKO53X6ZjCFSe i9Txmil1swSNEavcEfkr7rQCr0HNiAWgR8Z4+ufXOtckeHkIdDB26DMCEiU+BBJ5u8OF O96yNciDl3F25uG3Hck2YZqWC7Bsc4ybOQ3XJe8x0g1/uXR5WpiGyLhYBuoDRFaPPJDl xpwnK56nDs/E2YDj8SXSKML2VFtZDcvZWQMorocjRJYgph7vbYQ6A/lro8YNtwBoF7RG U3MA== 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=Nc1LxJJd2OMvnu8d3pOvwg71qW4krS90Dl5SqdXCRng=; b=a8I65WV3NK7WKHbIVYIeNlLovt/6l57sNQA/4MHy1yT1sSGWfLp++QebBtjO8aCI1r 4GAHWEirs+eAAyQ4tpW6m9aCyBWEV35jE9vDgHnr6NEnNYr8GMecVHOun3Brr9ZYg0ue i04KQsd2RuynaNw6ZCoy+2K2RV9DBVNtmBaWLB/AgjPYszJG1UNOhSozbYTHabTc0+QC 2yqTe3T93ldMjpfUxea47bqkkN6Zt/B4IBNo34u1Kacq7llKe+q1JN3uNhhRdTkdedTL kJGfk6SstwfWBk7j2o9Zbkd+Y34MD26mUiAZmbkjNe3hp1cbdP8kKnbRA3oFSO3h6Smk RYOQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=dLTY18j1; 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 q11si1312550ejr.604.2021.03.05.04.41.34; Fri, 05 Mar 2021 04:41:57 -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=dLTY18j1; 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 S233070AbhCEMig (ORCPT + 99 others); Fri, 5 Mar 2021 07:38:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:51028 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232392AbhCEMhu (ORCPT ); Fri, 5 Mar 2021 07:37:50 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id E899365004; Fri, 5 Mar 2021 12:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947870; bh=n3oIJCLNUHWb8VSxGI+nsLCbsNS1pQFAIDyNjQMveao=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=dLTY18j1HTCcMF/3+Vjig+5ZSdsFuZBCDNPtrEjBAsUQL1nR/OT8OJ9FLwOHpbaWG FDX5sTykfeh8QYJqOm2mmjI8Hqc/+bJqC9cCl082Kb5jMwWyt8M78xXHbH83jx0Cp7 OOeVORXRpJcp/t6e69GQW8E5iQLYJobFJa86wOUY= 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 4.19 42/52] scsi: iscsi: Restrict sessions and handles to admin capabilities Date: Fri, 5 Mar 2021 13:22:13 +0100 Message-Id: <20210305120855.721450507@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120853.659441428@linuxfoundation.org> References: <20210305120853.659441428@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 @@ -119,6 +119,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); @@ -3504,6 +3507,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