Skip to content

Commit 5bbb2ae

Browse files
pebollegregkh
authored andcommitted
raw: test against runtime value of max_raw_minors
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> Cc: stable <stable@vger.kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 269f979 commit 5bbb2ae

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/char/raw.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ static int bind_get(int number, dev_t *dev)
190190
struct raw_device_data *rawdev;
191191
struct block_device *bdev;
192192

193-
if (number <= 0 || number >= MAX_RAW_MINORS)
193+
if (number <= 0 || number >= max_raw_minors)
194194
return -EINVAL;
195195

196196
rawdev = &raw_devices[number];

0 commit comments

Comments
 (0)