raw: test against runtime value of max_raw_minors
authorPaul Bolle <pebolle@tiscali.nl>
Tue, 4 Feb 2014 22:23:12 +0000 (23:23 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 22 Feb 2014 18:32:45 +0000 (10:32 -0800)
commite24cfb1b4f4942681c3ce382e83cc090f0ad1550
treef76ef4cbcc279ba32a47feb047d0f407ab53c450
parent566d9875cb708d907f8a0b3c2a0dffb96dcb973c
raw: test against runtime value of max_raw_minors

commit 5bbb2ae3d6f896f8d2082d1eceb6131c2420b7cf upstream.

bind_get() checks the device number it is called with. It uses
MAX_RAW_MINORS for the upper bound. But MAX_RAW_MINORS is set at compile
time while the actual number of raw devices can be set at runtime. This
means the test can either be too strict or too lenient. And if the test
ends up being too lenient bind_get() might try to access memory beyond
what was allocated for "raw_devices".

So check against the runtime value (max_raw_minors) in this function.

Signed-off-by: Paul Bolle <pebolle@tiscali.nl>
Acked-by: Jan Kara <jack@suse.cz>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/raw.c