From: Linus Torvalds <torvalds@linux-foundation.org>
To: James Bottomley <James.Bottomley@hansenpartnership.com>
Cc: Jann Horn <jannh@google.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux SCSI List <linux-scsi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [GIT PULL] SCSI fixes for 4.18-rc3
Date: Mon, 9 Jul 2018 17:41:34 -0700 [thread overview]
Message-ID: <CA+55aFwg-2GP4ASTdd1pusmZkF7c8AN9febVDCaioDxzYJSLfw@mail.gmail.com> (raw)
In-Reply-To: <1530940958.3135.4.camel@HansenPartnership.com>
[-- Attachment #1: Type: text/plain, Size: 516 bytes --]
On Fri, Jul 6, 2018 at 10:22 PM James Bottomley
<James.Bottomley@hansenpartnership.com> wrote:
>
> We did discuss removing the r/w interface, but, as you say, it's been
> around for ages so it's not clear what regressions would surface if we
> did.
So since nobody else followed up on this, the attached patch is what I
was thinking of just committing.
It removes the warnings from the access check, and just puts them
(unconditionally) at the top of the read/write function instead.
Hmm?
Linus
[-- Attachment #2: patch.diff --]
[-- Type: text/x-patch, Size: 1955 bytes --]
drivers/scsi/sg.c | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c
index cd2fdac000c9..09325b8fbc9f 100644
--- a/drivers/scsi/sg.c
+++ b/drivers/scsi/sg.c
@@ -222,18 +222,12 @@ static void sg_device_destroy(struct kref *kref);
* This function provides protection for the legacy API by restricting the
* calling context.
*/
-static int sg_check_file_access(struct file *filp, const char *caller)
+static int sg_check_file_access(struct file *filp)
{
- if (filp->f_cred != current_real_cred()) {
- pr_err_once("%s: process %d (%s) changed security contexts after opening file descriptor, this is not allowed.\n",
- caller, task_tgid_vnr(current), current->comm);
+ if (filp->f_cred != current_real_cred())
return -EPERM;
- }
- if (uaccess_kernel()) {
- pr_err_once("%s: process %d (%s) called from kernel context, this is not allowed.\n",
- caller, task_tgid_vnr(current), current->comm);
+ if (uaccess_kernel())
return -EACCES;
- }
return 0;
}
@@ -421,11 +415,14 @@ sg_read(struct file *filp, char __user *buf, size_t count, loff_t * ppos)
struct sg_header *old_hdr = NULL;
int retval = 0;
+ pr_err_once("process %d (%s) does direct read on /dev/sg",
+ task_tgid_vnr(current), current->comm);
+
/*
* This could cause a response to be stranded. Close the associated
* file descriptor to free up any resources being held.
*/
- retval = sg_check_file_access(filp, __func__);
+ retval = sg_check_file_access(filp);
if (retval)
return retval;
@@ -618,7 +615,10 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos)
unsigned char cmnd[SG_MAX_CDB_SIZE];
int retval;
- retval = sg_check_file_access(filp, __func__);
+ pr_err_once("process %d (%s) does direct write on /dev/sg",
+ task_tgid_vnr(current), current->comm);
+
+ retval = sg_check_file_access(filp);
if (retval)
return retval;
next prev parent reply other threads:[~2018-07-10 0:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-06 21:38 [GIT PULL] SCSI fixes for 4.18-rc3 James Bottomley
2018-07-07 2:31 ` Linus Torvalds
2018-07-07 2:39 ` Linus Torvalds
2018-07-07 2:48 ` Linus Torvalds
2018-07-07 5:22 ` James Bottomley
2018-07-10 0:41 ` Linus Torvalds [this message]
2018-07-10 17:36 ` Jann Horn
2018-07-10 17:49 ` Linus Torvalds
2018-07-10 18:04 ` Linus Torvalds
2018-07-10 21:53 ` Tony Battersby
2018-07-10 22:24 ` Linus Torvalds
2018-07-11 0:40 ` Linus Torvalds
2018-07-11 6:45 ` Christoph Hellwig
2018-07-11 13:56 ` Tony Battersby
2018-07-16 16:20 ` Jann Horn
2018-07-07 3:08 ` Jann Horn
2018-07-07 3:25 ` Linus Torvalds
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CA+55aFwg-2GP4ASTdd1pusmZkF7c8AN9febVDCaioDxzYJSLfw@mail.gmail.com \
--to=torvalds@linux-foundation.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=akpm@linux-foundation.org \
--cc=jannh@google.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).