ethtool: fix stack overflow in ethnl_parse_bitset()
authorMichal Kubecek <mkubecek@suse.cz>
Tue, 8 Dec 2020 22:13:51 +0000 (23:13 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 21 Dec 2020 12:28:17 +0000 (13:28 +0100)
commitd8d50009dadaa7f4d179af59e9796628c7487cf8
treef1efefc76cd324cd6e7cefc3b06f39fb3a055401
parent5c5d11d7a22e355655c61b7254e7d74cc51cb0fd
ethtool: fix stack overflow in ethnl_parse_bitset()

[ Upstream commit a770bf515613c6e12ae904c3593e26016de99448 ]

Syzbot reported a stack overflow in bitmap_from_arr32() called from
ethnl_parse_bitset() when bitset from netlink message is longer than
target bitmap length. While ethnl_compact_sanity_checks() makes sure that
trailing part is all zeros (i.e. the request does not try to touch bits
kernel does not recognize), we also need to cap change_bits to nbits so
that we don't try to write past the prepared bitmaps.

Fixes: 88db6d1e4f62 ("ethtool: add ethnl_parse_bitset() helper")
Reported-by: syzbot+9d39fa49d4df294aab93@syzkaller.appspotmail.com
Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
Link: https://lore.kernel.org/r/3487ee3a98e14cd526f55b6caaa959d2dcbcad9f.1607465316.git.mkubecek@suse.cz
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
net/ethtool/bitset.c