Received: by 10.223.164.197 with SMTP id h5csp392202wrb; Sat, 4 Nov 2017 13:29:50 -0700 (PDT) X-Google-Smtp-Source: ABhQp+TC6JdS4DTPXaAEE5skj9yuB8skJ8KAhYtFxEBCQoGhEzhzsjNDcRXxQmwpgSeyEaM2C46b X-Received: by 10.98.202.131 with SMTP id y3mr11960392pfk.199.1509827390427; Sat, 04 Nov 2017 13:29:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509827390; cv=none; d=google.com; s=arc-20160816; b=iUxYmyjjKdJ8BXafP9PJYpprBz2hhib3TlHds+HBUo3drWpyyzfkx7C5A+34hJa06S dCO2jH04QTEqF/eXVH1fc7Id3AwqfeJHxGzbfefb92IaDMYXlTvii3fdSt/lsxgG8c+h v3e1nySwvdOi7TWpmfJyfvikNnANGgnDQImZRE3QIqXcOdGTzTV0JpNEET3rU8K5w2Bk uRezcZJKzsyR1ON5ymO8wMyGWu+GMc0nXX3OgpmtyWrWLbBMJiQqJsZKGGXHnH1lB3L5 qq6Al5rrB/QjC325qET0vsyCB8ZofroaDm1oXUF+HU6mX6X1QdL5GkC8xtC0ruKEBl1C fDUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=OHTI30ZPt5srgI2/NqC4kINbh9IqdEWJyGpURmeJwRc=; b=DlRq6C3aot62tCAR5b0ClaxN9VQa8ePKMmge/X8PuESTFm2AHeInozBDQ9janwq2y5 HoTIKPEA5YExyjLRWwONzeygqtLedDgrKJBT6Fqaoq32SnX6d44Jv+KY0Q/b6qtXV51Q KYnS9VfmgwPhVY8rWADgHPU+ZfcPY+4yMRsqA1s4UEt2CqfxnHgpxbRZhi1Z8HpqXEC1 xYRAH9bTd2/GUVXn6wr4CT7IwJHQG8bTikKfwyHS92QFp8Q9KX3maG6iQrCd3JLUCZAU DIDv2xSBpYQft71V1iecaYR6tDoK1sOVesrOW9nUvvzB9++kZwpooz+cjEmOMaJQ9y7t tDwQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f15si9696469pfh.149.2017.11.04.13.29.36; Sat, 04 Nov 2017 13:29:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752775AbdKDU1U (ORCPT + 94 others); Sat, 4 Nov 2017 16:27:20 -0400 Received: from mx2.suse.de ([195.135.220.15]:34294 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752569AbdKDU1R (ORCPT ); Sat, 4 Nov 2017 16:27:17 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 311EBAC58; Sat, 4 Nov 2017 20:27:16 +0000 (UTC) From: Aleksa Sarai To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, containers@lists.linux-foundation.org, Valentin Rothberg , cyphar@cyphar.com, Aleksa Sarai , stable@vger.kernel.org, "Eric W. Biederman" Subject: [PATCH v2] scsi: require CAP_SYS_ADMIN to write to procfs interface Date: Sun, 5 Nov 2017 07:26:24 +1100 Message-Id: <20171104202624.6605-1-asarai@suse.de> X-Mailer: git-send-email 2.14.3 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Previously, the only capability effectively required to operate on the /proc/scsi interface was CAP_DAC_OVERRIDE (or for some other files, having an fsuid of GLOBAL_ROOT_UID was enough). This means that semi-privileged processes could interfere with core components of a system (such as causing a DoS by removing the underlying SCSI device of the host's / mount). Cc: Cc: "Eric W. Biederman" Signed-off-by: Aleksa Sarai --- drivers/scsi/scsi_proc.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_proc.c b/drivers/scsi/scsi_proc.c index 480a597b3877..8c891ab16b11 100644 --- a/drivers/scsi/scsi_proc.c +++ b/drivers/scsi/scsi_proc.c @@ -51,7 +51,10 @@ static ssize_t proc_scsi_host_write(struct file *file, const char __user *buf, struct Scsi_Host *shost = PDE_DATA(file_inode(file)); ssize_t ret = -ENOMEM; char *page; - + + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (count > PROC_BLOCK_SIZE) return -EOVERFLOW; @@ -313,6 +316,9 @@ static ssize_t proc_scsi_write(struct file *file, const char __user *buf, char *buffer, *p; int err; + if (!capable(CAP_SYS_ADMIN)) + return -EPERM; + if (!buf || length > PAGE_SIZE) return -EINVAL; -- 2.14.3 From 1583168660320892828@xxx Sat Nov 04 20:28:09 +0000 2017 X-GM-THRID: 1583163148146352510 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread