ptp: Add a upper bound on max_vclocks
syzbot reported WARNING in max_vclocks_store.
This occurs when the argument max is too large for kcalloc to handle.
Extend the guard to guard against values that are too large for
kcalloc
Reported-by: syzbot+94d20db923b9f51be0df@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=94d20db923b9f51be0df
Tested-by: syzbot+94d20db923b9f51be0df@syzkaller.appspotmail.com
Fixes: 73f37068d5 ("ptp: support ptp physical/virtual clocks conversion")
Signed-off-by: I Viswanath <viswanathiyyappan@gmail.com>
Acked-by: Richard Cochran <richardcochran@gmail.com>
Link: https://patch.msgid.link/20250925155908.5034-1-viswanathiyyappan@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
pull/1354/merge
parent
958baf5eae
commit
e9f35294e1
|
|
@ -22,6 +22,7 @@
|
|||
#define PTP_MAX_TIMESTAMPS 128
|
||||
#define PTP_BUF_TIMESTAMPS 30
|
||||
#define PTP_DEFAULT_MAX_VCLOCKS 20
|
||||
#define PTP_MAX_VCLOCKS_LIMIT (KMALLOC_MAX_SIZE/(sizeof(int)))
|
||||
#define PTP_MAX_CHANNELS 2048
|
||||
|
||||
enum {
|
||||
|
|
|
|||
|
|
@ -284,7 +284,7 @@ static ssize_t max_vclocks_store(struct device *dev,
|
|||
size_t size;
|
||||
u32 max;
|
||||
|
||||
if (kstrtou32(buf, 0, &max) || max == 0)
|
||||
if (kstrtou32(buf, 0, &max) || max == 0 || max > PTP_MAX_VCLOCKS_LIMIT)
|
||||
return -EINVAL;
|
||||
|
||||
if (max == ptp->max_vclocks)
|
||||
|
|
|
|||
Loading…
Reference in New Issue