netfilter: nft_exthdr: break evaluation if setting TCP option fails
[ Upstream commit 962e5a40358787105f126ab1dc01604da3d169e9 ]
Break rule evaluation on malformed TCP options.
Fixes: 99d1712bc4
("netfilter: exthdr: tcp option set support")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Stable-dep-of: 28427f368f0e ("netfilter: nft_exthdr: Fix non-linear header modification")
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:

committed by
Greg Kroah-Hartman

parent
45b3eb6afc
commit
10670abe11
@@ -236,7 +236,7 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
|
|||||||
|
|
||||||
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len);
|
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len);
|
||||||
if (!tcph)
|
if (!tcph)
|
||||||
return;
|
goto err;
|
||||||
|
|
||||||
opt = (u8 *)tcph;
|
opt = (u8 *)tcph;
|
||||||
for (i = sizeof(*tcph); i < tcphdr_len - 1; i += optl) {
|
for (i = sizeof(*tcph); i < tcphdr_len - 1; i += optl) {
|
||||||
@@ -251,16 +251,16 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
|
if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
|
||||||
return;
|
goto err;
|
||||||
|
|
||||||
if (skb_ensure_writable(pkt->skb,
|
if (skb_ensure_writable(pkt->skb,
|
||||||
nft_thoff(pkt) + i + priv->len))
|
nft_thoff(pkt) + i + priv->len))
|
||||||
return;
|
goto err;
|
||||||
|
|
||||||
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff,
|
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff,
|
||||||
&tcphdr_len);
|
&tcphdr_len);
|
||||||
if (!tcph)
|
if (!tcph)
|
||||||
return;
|
goto err;
|
||||||
|
|
||||||
offset = i + priv->offset;
|
offset = i + priv->offset;
|
||||||
|
|
||||||
@@ -303,6 +303,9 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
|
|||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
return;
|
||||||
|
err:
|
||||||
|
regs->verdict.code = NFT_BREAK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void nft_exthdr_sctp_eval(const struct nft_expr *expr,
|
static void nft_exthdr_sctp_eval(const struct nft_expr *expr,
|
||||||
|
Reference in New Issue
Block a user