From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752913AbdKDUUw (ORCPT ); Sat, 4 Nov 2017 16:20:52 -0400 Received: from merlin.infradead.org ([205.233.59.134]:33440 "EHLO merlin.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751709AbdKDUUt (ORCPT ); Sat, 4 Nov 2017 16:20:49 -0400 Subject: Re: [PATCH] scsi: require CAP_SYS_ADMIN to write to procfs interface To: Aleksa Sarai , "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, stable@vger.kernel.org, "Eric W. Biederman" References: <20171104185913.10658-1-asarai@suse.de> From: Randy Dunlap Message-ID: <7595538b-c203-0af4-810e-e3f97334a314@infradead.org> Date: Sat, 4 Nov 2017 13:20:43 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <20171104185913.10658-1-asarai@suse.de> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/04/2017 11:59 AM, Aleksa Sarai wrote: > 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..486aedce2f05 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 did that build without a trailing ';' ? > + > 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; > > -- ~Randy