In the Linux kernel, the following vulnerability has been resolved:
net: napi: Prevent overflow of napideferhard_irqs
In commit 6f8b12d661d0 ("net: napi: add hard irqs deferral feature") napideferirqs was added to netdevice and napideferirqscount was added to napi_struct, both as type int.
This value never goes below zero, so there is not reason for it to be a signed int. Change the type for both from int to u32, and add an overflow check to sysfs to limit the value to S32_MAX.
The limit of S32MAX was chosen because the practical limit before this patch was S32MAX (anything larger was an overflow) and thus there are no behavioral changes introduced. If the extra bit is needed in the future, the limit can be raised.
Before this patch:
$ sudo bash -c 'echo 2147483649 > /sys/class/net/eth4/napideferhardirqs' $ cat /sys/class/net/eth4/napideferhardirqs -2147483647
After this patch:
$ sudo bash -c 'echo 2147483649 > /sys/class/net/eth4/napideferhard_irqs' bash: line 0: echo: write error: Numerical result out of range
Similarly, /sys/class/net/XXXXX/txqueuelen is defined as unsigned:
include/linux/netdevice.h: unsigned int txqueuelen;
And has an overflow check:
devchangetxqueuelen(..., unsigned long new_len):
if (newlen != (unsigned int)newlen) return -ERANGE;