mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-03-22 07:27:12 +08:00
netfilter: x_tables: guard option walkers against 1-byte tail reads
When the last byte of options is a non-single-byte option kind, walkers
that advance with i += op[i + 1] ? : 1 can read op[i + 1] past the end
of the option area.
Add an explicit i == optlen - 1 check before dereferencing op[i + 1]
in xt_tcpudp and xt_dccp option walkers.
Fixes: 2e4e6a17af ("[NETFILTER] x_tables: Abstraction layer for {ip,ip6,arp}_tables")
Signed-off-by: David Dull <monderasdor@gmail.com>
Signed-off-by: Florian Westphal <fw@strlen.de>
This commit is contained in:
committed by
Florian Westphal
parent
d6d8cd2db2
commit
cfe770220a
@@ -62,10 +62,10 @@ dccp_find_option(u_int8_t option,
|
||||
return true;
|
||||
}
|
||||
|
||||
if (op[i] < 2)
|
||||
if (op[i] < 2 || i == optlen - 1)
|
||||
i++;
|
||||
else
|
||||
i += op[i+1]?:1;
|
||||
i += op[i + 1] ? : 1;
|
||||
}
|
||||
|
||||
spin_unlock_bh(&dccp_buflock);
|
||||
|
||||
@@ -59,8 +59,10 @@ tcp_find_option(u_int8_t option,
|
||||
|
||||
for (i = 0; i < optlen; ) {
|
||||
if (op[i] == option) return !invert;
|
||||
if (op[i] < 2) i++;
|
||||
else i += op[i+1]?:1;
|
||||
if (op[i] < 2 || i == optlen - 1)
|
||||
i++;
|
||||
else
|
||||
i += op[i + 1] ? : 1;
|
||||
}
|
||||
|
||||
return invert;
|
||||
|
||||
Reference in New Issue
Block a user