]> git.baikalelectronics.ru Git - kernel.git/commitdiff
scsi: iscsi: Restrict sessions and handles to admin capabilities
authorLee Duncan <lduncan@suse.com>
Tue, 23 Feb 2021 21:06:24 +0000 (13:06 -0800)
committerMartin K. Petersen <martin.petersen@oracle.com>
Fri, 5 Mar 2021 01:09:50 +0000 (20:09 -0500)
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 <adam@grimm-co.com>
Reviewed-by: Chris Leech <cleech@redhat.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Lee Duncan <lduncan@suse.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_transport_iscsi.c

index 969d24d580e29b46a23d4df097bd19121e837c18..69a1f55499ef9c3cef9a4ba63f0b8683ba378dc1 100644 (file)
@@ -132,6 +132,9 @@ show_transport_handle(struct device *dev, struct device_attribute *attr,
                      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);
@@ -3621,6 +3624,9 @@ iscsi_if_recv_msg(struct sk_buff *skb, struct nlmsghdr *nlh, uint32_t *group)
        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