Sasha Levin 072f19b4be [SCSI] prevent stack buffer overflow in host_reset
store_host_reset() has tried to re-invent the wheel to compare sysfs strings.
Unfortunately it did so poorly and never bothered to check the input from
userspace before overwriting stack with it, so something simple as:

echo "WoopsieWoopsie" >
/sys/devices/pseudo_0/adapter0/host0/scsi_host/host0/host_reset

would result in:

[  316.310101] Kernel panic - not syncing: stack-protector: Kernel stack is corrupted in: ffffffff81f5bac7
[  316.310101]
[  316.320051] Pid: 6655, comm: sh Tainted: G        W    3.7.0-rc5-next-20121114-sasha-00016-g5c9d68d-dirty #129
[  316.320051] Call Trace:
[  316.340058] pps pps0: PPS event at 1352918752.620355751
[  316.340062] pps pps0: capture assert seq #303
[  316.320051]  [<ffffffff83b3856b>] panic+0xcd/0x1f4
[  316.320051]  [<ffffffff81f5bac7>] ? store_host_reset+0xd7/0x100
[  316.320051]  [<ffffffff8110b996>] __stack_chk_fail+0x16/0x20
[  316.320051]  [<ffffffff81f5bac7>] store_host_reset+0xd7/0x100
[  316.320051]  [<ffffffff81e55bb3>] dev_attr_store+0x13/0x30
[  316.320051]  [<ffffffff812f7db1>] sysfs_write_file+0x101/0x170
[  316.320051]  [<ffffffff8127acc8>] vfs_write+0xb8/0x180
[  316.320051]  [<ffffffff8127ae80>] sys_write+0x50/0xa0
[  316.320051]  [<ffffffff83c03418>] tracesys+0xe1/0xe6

Fix this by uninventing whatever was going on there and just use sysfs_streq.

Bug introduced by 29443691 ("[SCSI] scsi: Added support for adapter and
firmware reset").

[jejb: added necessary const to prevent compile warnings]
Signed-off-by: Sasha Levin <sasha.levin@oracle.com>
Cc: <stable@vger.kernel.org> #3.2+
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-11-30 09:08:16 +00:00
..
2012-11-22 09:14:54 -10:00
2012-10-15 14:45:51 -04:00
2012-11-23 14:32:55 +01:00
2012-10-07 20:55:16 +09:00
2012-10-30 10:05:51 +01:00
2012-09-26 22:28:21 -04:00
2012-11-23 12:11:13 -10:00
2012-10-07 17:29:24 +09:00
2012-10-10 20:15:24 +09:00
2012-10-17 15:53:03 -05:00
2012-10-09 16:11:46 +09:00
2012-10-10 20:15:24 +09:00
2012-11-16 14:33:04 -08:00
2012-10-28 11:13:54 -07:00
2012-11-22 09:14:54 -10:00
2012-11-23 12:01:02 -10:00
2012-10-01 12:09:59 -07:00
2012-11-20 18:52:01 -10:00
2012-10-01 18:46:13 -07:00
2012-10-16 18:07:12 -07:00