diff options
| author | Al Viro <viro@zeniv.linux.org.uk> | 2016-12-16 13:42:06 -0500 |
|---|---|---|
| committer | Mister Oyster <oysterized@gmail.com> | 2017-07-04 11:51:17 +0200 |
| commit | 3ae371bc0c1ffdf647a56306c09490af25a91b31 (patch) | |
| tree | 815725882f302fd37040e9eede032a7226b07f49 | |
| parent | 5e60f315e035ba0dd42476139bf03d4129fc6923 (diff) | |
| download | android_kernel_m2note-3ae371bc0c1ffdf647a56306c09490af25a91b31.tar.gz | |
sg_write()/bsg_write() is not fit to be called under KERNEL_DS
commit 128394eff343fc6d2f32172f03e24829539c5835 upstream.
Both damn things interpret userland pointers embedded into the payload;
worse, they are actually traversing those. Leaving aside the bad
API design, this is very much _not_ safe to call with KERNEL_DS.
Bail out early if that happens.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Willy Tarreau <w@1wt.eu>
| -rw-r--r-- | drivers/scsi/sg.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index b66ae80b0..207b6cfb7 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c @@ -575,6 +575,9 @@ sg_write(struct file *filp, const char __user *buf, size_t count, loff_t * ppos) if (unlikely(segment_eq(get_fs(), KERNEL_DS))) return -EINVAL; + if (unlikely(segment_eq(get_fs(), KERNEL_DS))) + return -EINVAL; + if ((!(sfp = (Sg_fd *) filp->private_data)) || (!(sdp = sfp->parentdp))) return -ENXIO; SCSI_LOG_TIMEOUT(3, printk("sg_write: %s, count=%d\n", |
