Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ethtool: fix string set id check

Syzbot reported a shift of a u32 by more than 31 in strset_parse_request()
which is undefined behavior. This is caused by range check of string set id
using variable ret (which is always 0 at this point) instead of id (string
set id from request).

Fixes: 71921690f974 ("ethtool: provide string sets with STRSET_GET request")
Reported-by: syzbot+96523fb438937cd01220@syzkaller.appspotmail.com
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Link: https://lore.kernel.org/r/b54ed5c5fd972a59afea3e1badfb36d86df68799.1607952208.git.mkubecek@suse.cz
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Michal Kubecek and committed by
Jakub Kicinski
efb796f5 f87675b8

+1 -1
+1 -1
net/ethtool/strset.c
··· 182 182 ret = strset_get_id(attr, &id, extack); 183 183 if (ret < 0) 184 184 return ret; 185 - if (ret >= ETH_SS_COUNT) { 185 + if (id >= ETH_SS_COUNT) { 186 186 NL_SET_ERR_MSG_ATTR(extack, attr, 187 187 "unknown string set id"); 188 188 return -EOPNOTSUPP;