Commit 4f59652
netfilter: ebtables: compat: reject all padding in matches/watchers
BugLink: https://bugs.launchpad.net/bugs/1860816
commit e608f63 upstream.
syzbot reported following splat:
BUG: KASAN: vmalloc-out-of-bounds in size_entry_mwt net/bridge/netfilter/ebtables.c:2063 [inline]
BUG: KASAN: vmalloc-out-of-bounds in compat_copy_entries+0x128b/0x1380 net/bridge/netfilter/ebtables.c:2155
Read of size 4 at addr ffffc900004461f4 by task syz-executor267/7937
CPU: 1 PID: 7937 Comm: syz-executor267 Not tainted 5.5.0-rc1-syzkaller #0
size_entry_mwt net/bridge/netfilter/ebtables.c:2063 [inline]
compat_copy_entries+0x128b/0x1380 net/bridge/netfilter/ebtables.c:2155
compat_do_replace+0x344/0x720 net/bridge/netfilter/ebtables.c:2249
compat_do_ebt_set_ctl+0x22f/0x27e net/bridge/netfilter/ebtables.c:2333
[..]
Because padding isn't considered during computation of ->buf_user_offset,
"total" is decremented by fewer bytes than it should.
Therefore, the first part of
if (*total < sizeof(*entry) || entry->next_offset < sizeof(*entry))
will pass, -- it should not have. This causes oob access:
entry->next_offset is past the vmalloced size.
Reject padding and check that computed user offset (sum of ebt_entry
structure plus all individual matches/watchers/targets) is same
value that userspace gave us as the offset of the next entry.
Reported-by: [email protected]
Fixes: 81e675c ("netfilter: ebtables: add CONFIG_COMPAT support")
Signed-off-by: Florian Westphal <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Kamal Mostafa <[email protected]>
Signed-off-by: Khalid Elmously <[email protected]>1 parent 91f0673 commit 4f59652
1 file changed
+16
-17
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1867 | 1867 | | |
1868 | 1868 | | |
1869 | 1869 | | |
1870 | | - | |
| 1870 | + | |
1871 | 1871 | | |
1872 | 1872 | | |
1873 | 1873 | | |
| |||
1901 | 1901 | | |
1902 | 1902 | | |
1903 | 1903 | | |
1904 | | - | |
| 1904 | + | |
1905 | 1905 | | |
1906 | 1906 | | |
1907 | 1907 | | |
| |||
1979 | 1979 | | |
1980 | 1980 | | |
1981 | 1981 | | |
1982 | | - | |
| 1982 | + | |
1983 | 1983 | | |
1984 | 1984 | | |
1985 | 1985 | | |
| 1986 | + | |
1986 | 1987 | | |
1987 | | - | |
1988 | 1988 | | |
1989 | 1989 | | |
1990 | 1990 | | |
1991 | 1991 | | |
1992 | | - | |
1993 | | - | |
1994 | | - | |
| 1992 | + | |
1995 | 1993 | | |
1996 | 1994 | | |
1997 | 1995 | | |
| 1996 | + | |
| 1997 | + | |
| 1998 | + | |
1998 | 1999 | | |
1999 | 2000 | | |
2000 | 2001 | | |
| |||
2031 | 2032 | | |
2032 | 2033 | | |
2033 | 2034 | | |
2034 | | - | |
2035 | | - | |
2036 | | - | |
2037 | | - | |
2038 | 2035 | | |
2039 | | - | |
| 2036 | + | |
2040 | 2037 | | |
2041 | 2038 | | |
2042 | 2039 | | |
2043 | 2040 | | |
2044 | 2041 | | |
2045 | | - | |
| 2042 | + | |
2046 | 2043 | | |
2047 | 2044 | | |
2048 | 2045 | | |
2049 | | - | |
| 2046 | + | |
2050 | 2047 | | |
2051 | 2048 | | |
2052 | 2049 | | |
| |||
2132 | 2129 | | |
2133 | 2130 | | |
2134 | 2131 | | |
2135 | | - | |
| 2132 | + | |
| 2133 | + | |
| 2134 | + | |
2136 | 2135 | | |
2137 | | - | |
| 2136 | + | |
2138 | 2137 | | |
2139 | | - | |
| 2138 | + | |
2140 | 2139 | | |
2141 | 2140 | | |
2142 | 2141 | | |
| |||
0 commit comments