Skip to content

Commit 4d26ab0

Browse files
author
Florian Westphal
committed
netfilter: nf_tables: mask out non-verdict bits when checking return value
nftables trace infra must mask out the non-verdict bit parts of the return value, else followup changes that 'return errno << 8 | NF_STOLEN' will cause breakage. Signed-off-by: Florian Westphal <[email protected]>
1 parent e15e502 commit 4d26ab0

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

net/netfilter/nf_tables_core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static noinline void __nft_trace_verdict(const struct nft_pktinfo *pkt,
115115
{
116116
enum nft_trace_types type;
117117

118-
switch (regs->verdict.code) {
118+
switch (regs->verdict.code & NF_VERDICT_MASK) {
119119
case NFT_CONTINUE:
120120
case NFT_RETURN:
121121
type = NFT_TRACETYPE_RETURN;

net/netfilter/nf_tables_trace.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,17 +258,21 @@ void nft_trace_notify(const struct nft_pktinfo *pkt,
258258
case __NFT_TRACETYPE_MAX:
259259
break;
260260
case NFT_TRACETYPE_RETURN:
261-
case NFT_TRACETYPE_RULE:
261+
case NFT_TRACETYPE_RULE: {
262+
unsigned int v;
263+
262264
if (nft_verdict_dump(skb, NFTA_TRACE_VERDICT, verdict))
263265
goto nla_put_failure;
264266

265267
/* pkt->skb undefined iff NF_STOLEN, disable dump */
266-
if (verdict->code == NF_STOLEN)
268+
v = verdict->code & NF_VERDICT_MASK;
269+
if (v == NF_STOLEN)
267270
info->packet_dumped = true;
268271
else
269272
mark = pkt->skb->mark;
270273

271274
break;
275+
}
272276
case NFT_TRACETYPE_POLICY:
273277
mark = pkt->skb->mark;
274278

0 commit comments

Comments
 (0)