Skip to content

Commit 962e5a4

Browse files
committed
netfilter: nft_exthdr: break evaluation if setting TCP option fails
Break rule evaluation on malformed TCP options. Fixes: 99d1712 ("netfilter: exthdr: tcp option set support") Signed-off-by: Pablo Neira Ayuso <[email protected]>
1 parent 0de53b0 commit 962e5a4

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

net/netfilter/nft_exthdr.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
236236

237237
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff, &tcphdr_len);
238238
if (!tcph)
239-
return;
239+
goto err;
240240

241241
opt = (u8 *)tcph;
242242
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,
251251
continue;
252252

253253
if (i + optl > tcphdr_len || priv->len + priv->offset > optl)
254-
return;
254+
goto err;
255255

256256
if (skb_ensure_writable(pkt->skb,
257257
nft_thoff(pkt) + i + priv->len))
258-
return;
258+
goto err;
259259

260260
tcph = nft_tcp_header_pointer(pkt, sizeof(buff), buff,
261261
&tcphdr_len);
262262
if (!tcph)
263-
return;
263+
goto err;
264264

265265
offset = i + priv->offset;
266266

@@ -303,6 +303,9 @@ static void nft_exthdr_tcp_set_eval(const struct nft_expr *expr,
303303

304304
return;
305305
}
306+
return;
307+
err:
308+
regs->verdict.code = NFT_BREAK;
306309
}
307310

308311
static void nft_exthdr_sctp_eval(const struct nft_expr *expr,

0 commit comments

Comments
 (0)