Bug 116741 - Double-Fetch bug in Linux-4.5/drivers/s390/char/sclp_ctl.c
Summary: Double-Fetch bug in Linux-4.5/drivers/s390/char/sclp_ctl.c
Status: NEW
Alias: None
Product: Drivers
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 high
Assignee: drivers_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-04-19 21:33 UTC by Pengfei Wang
Modified: 2016-04-25 16:21 UTC (History)
1 user (show)

See Also:
Kernel Version: 4.5
Subsystem:
Regression: No
Bisected commit-id:


Attachments
source file (2.76 KB, application/octet-stream)
2016-04-25 16:21 UTC, Pengfei Wang
Details

Description Pengfei Wang 2016-04-19 21:33:05 UTC
Hi,

I found this Double-Fetch bug in Linux-4.5/drivers/s390/char/sclp_ctl.c when I was examining the source code. 

In function sclp_ctl_ioctl_sccb(), the driver fetches user space data by pointer ctl_sccb.sccb via copy_from_user(), and this happens twice at line 68 and line 74 respectively. The first fetched value (stored in sccb) is used to get the length element (sccb->length) so as to copy the whole message later at line 74, which means the copy size of the whole message is based on the old value that came from the first fetch. Besides, the whole message copied in the  second fetch also contains sccb->length.

However, when the function copies the whole message back to user space after the second fetch at line 78, it uses sccb->length that came from the second fetch, which might be different from the one came from the first fetch as well as copied the message from user space to driver. 

If the sccb->length is modified by a user thread under race condition between the fetch operations, for example changing to a very large value, this will lead to consequence like over-boundary access on the buffer, information leakage.

I am looking forward to a reply on this, thank you!

Kind regards
Pengfei
Comment 1 Pengfei Wang 2016-04-25 16:21:55 UTC
Created attachment 214101 [details]
source file

Note You need to log in before you can comment on or make changes to this bug.