Skip to content

Commit

Permalink
net/sched: cbs: Fix integer overflow in cbs_set_port_rate()
Browse files Browse the repository at this point in the history
The subsequent calculation of port_rate = speed * 1000 * BYTES_PER_KBIT,
where the BYTES_PER_KBIT is of type LL, may cause an overflow.
At least when speed = SPEED_20000, the expression to the left of port_rate
will be greater than INT_MAX.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Elena Salomatkina <esalomatkina@ispras.ru>
Link: https://patch.msgid.link/20241013124529.1043-1-esalomatkina@ispras.ru
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
  • Loading branch information
Elena Salomatkina authored and Jakub Kicinski committed Oct 16, 2024
1 parent 95b3120 commit 397006b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion net/sched/sch_cbs.c
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ static void cbs_set_port_rate(struct net_device *dev, struct cbs_sched_data *q)
{
struct ethtool_link_ksettings ecmd;
int speed = SPEED_10;
int port_rate;
s64 port_rate;
int err;

err = __ethtool_get_link_ksettings(dev, &ecmd);
Expand Down

0 comments on commit 397006b

Please sign in to comment.