]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
iscsi-target: Fix wrong buffer / buffer overrun in iscsi_change_param_value()
authorRoland Dreier <roland@purestorage.com>
Thu, 29 May 2014 20:32:30 +0000 (13:32 -0700)
committerJiri Slaby <jslaby@suse.cz>
Thu, 9 Apr 2015 12:13:27 +0000 (14:13 +0200)
commit0a8212ca85d0d9dc64faaf23b9fce5ca0b2c2fd2
tree98f84a589ed831b98343626192078252fbb5bc05
parent2b4adc0309ebf94aca809c0bb5e366d5e9e49530
iscsi-target: Fix wrong buffer / buffer overrun in iscsi_change_param_value()

commit 79d59d08082dd0a0a18f8ceb78c99f9f321d72aa upstream.

In non-leading connection login, iscsi_login_non_zero_tsih_s1() calls
iscsi_change_param_value() with the buffer it uses to hold the login
PDU, not a temporary buffer.  This leads to the login header getting
corrupted and login failing for non-leading connections in MC/S.

Fix this by adding a wrapper iscsi_change_param_sprintf() that handles
the temporary buffer itself to avoid confusion.  Also handle sending a
reject in case of failure in the wrapper, which lets the calling code
get quite a bit smaller and easier to read.

Finally, bump the size of the temporary buffer from 32 to 64 bytes to be
safe, since "MaxRecvDataSegmentLength=" by itself is 25 bytes; with a
trailing NUL, a value >= 1M will lead to a buffer overrun.  (This isn't
the default but we don't need to run right at the ragged edge here)

Reported-by: Santosh Kulkarni <santosh.kulkarni@calsoftinc.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Jiri Slaby <jslaby@suse.cz>
drivers/target/iscsi/iscsi_target_login.c