diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2024-07-28 17:06:20 -0700 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2024-08-03 08:54:33 +0200 |
commit | 6c0cf6022aeecf8f61279389c9ba7edc2f0986ca (patch) | |
tree | 4cc512253b0c4a894ec5333f2bbea506ef4b7779 /drivers/scsi | |
parent | 34e4dfe838f7a1b9c9825f0e5149d63d5a29f0b2 (diff) | |
download | linux-rpi-6c0cf6022aeecf8f61279389c9ba7edc2f0986ca.tar.gz linux-rpi-6c0cf6022aeecf8f61279389c9ba7edc2f0986ca.tar.bz2 linux-rpi-6c0cf6022aeecf8f61279389c9ba7edc2f0986ca.zip |
minmax: scsi: fix mis-use of 'clamp()' in sr.c
commit 9f499b8c791d2983c0a31a543c51d1b2f15e8755 upstream.
While working on simplifying the minmax functions, and avoiding
excessive macro expansion, it turns out that the sr.c use of the
'clamp()' macro has the arguments the wrong way around.
The clamp logic is
val = clamp(in, low, high);
and it returns the input clamped to the low/high limits. But sr.c ddid
speed = clamp(0, speed, 0xffff / 177);
which clamps the value '0' to the range '[speed, 0xffff / 177]' and ends
up being nonsensical.
Happily, I don't think anybody ever cared.
Fixes: 9fad9d560af5 ("scsi: sr: Fix unintentional arithmetic wraparound")
Cc: Justin Stitt <justinstitt@google.com>
Cc: Kees Cook <keescook@chromium.org>
Cc: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Wentao Guan <guanwentao@uniontech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/scsi')
-rw-r--r-- | drivers/scsi/sr_ioctl.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/scsi/sr_ioctl.c b/drivers/scsi/sr_ioctl.c index a0d2556a27bb..089653018d32 100644 --- a/drivers/scsi/sr_ioctl.c +++ b/drivers/scsi/sr_ioctl.c @@ -431,7 +431,7 @@ int sr_select_speed(struct cdrom_device_info *cdi, unsigned long speed) struct packet_command cgc; /* avoid exceeding the max speed or overflowing integer bounds */ - speed = clamp(0, speed, 0xffff / 177); + speed = clamp(speed, 0, 0xffff / 177); if (speed == 0) speed = 0xffff; /* set to max */ |