Skip to content
/ linux Public

Commit eaedc0b

Browse files
Florian WestphalSasha Levin
authored andcommitted
netfilter: xt_tcpmss: check remaining length before reading optlen
[ Upstream commit 735ee85 ] Quoting reporter: In net/netfilter/xt_tcpmss.c (lines 53-68), the TCP option parser reads op[i+1] directly without validating the remaining option length. If the last byte of the option field is not EOL/NOP (0/1), the code attempts to index op[i+1]. In the case where i + 1 == optlen, this causes an out-of-bounds read, accessing memory past the optlen boundary (either reading beyond the stack buffer _opt or the following payload). Reported-by: sungzii <sungzii@pm.me> Signed-off-by: Florian Westphal <fw@strlen.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 0cf4fc3 commit eaedc0b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/netfilter/xt_tcpmss.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ tcpmss_mt(const struct sk_buff *skb, struct xt_action_param *par)
6161
return (mssval >= info->mss_min &&
6262
mssval <= info->mss_max) ^ info->invert;
6363
}
64-
if (op[i] < 2)
64+
if (op[i] < 2 || i == optlen - 1)
6565
i++;
6666
else
6767
i += op[i+1] ? : 1;

0 commit comments

Comments
 (0)