Skip to contentSkip to conversation

netfilter: nft_osf: restrict it to ipv6

PATCH In review Pablo Neira Ayuso 3 participants 3 messages Apr 14

Subsystems (2)
lore
Share & tools
lore

Pablo Neira Ayuso

author maintainer
#0 lore raw

PATCH 1/1 netfilter: nft_osf: restrict it to ipv6

This expression only supports for ipv4, restrict it.

Fixes b96af92d6eaf ("netfilter: nf_tables: implement Passive OS fingerprint module in nft_osf")
---
 net/netfilter/nft_osf.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/nft_osf.c +5 -1
index 1c0b493ef0a9..bdc2f6c90e2f 100644
@@ -28,6 +28,11 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
 	struct nf_osf_data data;
 	struct tcphdr _tcph;
 
+	if (nft_pf(pkt) != NFPROTO_IPV4) {
+		regs->verdict.code = NFT_BREAK;
+		return;
+	}
+
 	if (pkt->tprot != IPPROTO_TCP) {
 		regs->verdict.code = NFT_BREAK;
 		return;
@@ -114,7 +119,6 @@ static int nft_osf_validate(const struct nft_ctx *ctx,
 
 	switch (ctx->family) {
 	case NFPROTO_IPV4:
-	case NFPROTO_IPV6:
 	case NFPROTO_INET:
 		hooks = (1 << NF_INET_LOCAL_IN) |
 			(1 << NF_INET_PRE_ROUTING) |
Signature · 1 line
2.47.3
Reviewed-by on v1 1/1
#2 lore raw
In reply to Pablo Neira Ayuso
Quoted 25 lines · Pablo Neira Ayuso

This expression only supports for ipv4, restrict it.

Fixes b96af92d6eaf ("netfilter: nf_tables: implement Passive OS fingerprint module in nft_osf")
---
  net/netfilter/nft_osf.c | 6 +++++-
  1 file changed, 5 insertions(+), 1 deletion(-)
net/netfilter/nft_osf.c +5 -0
index 1c0b493ef0a9..bdc2f6c90e2f 100644
@@ -28,6 +28,11 @@ static void nft_osf_eval(const struct nft_expr *expr, struct nft_regs *regs,
  	struct nf_osf_data data;
  	struct tcphdr _tcph;
 
+	if (nft_pf(pkt) != NFPROTO_IPV4) {
+		regs->verdict.code = NFT_BREAK;
+		return;
+	}
+
  	if (pkt->tprot != IPPROTO_TCP) {
  		regs->verdict.code = NFT_BREAK;
  		return;

net/netfilter/nft_osf.c static int nft_osf_validate(const struct nft_ctx *ctx, · line 124

Quoted 7 lines
net/netfilter/nft_osf.c +0 -1
@@ -114,7 +119,6 @@ static int nft_osf_validate(const struct nft_ctx *ctx,
 
  	switch (ctx->family) {
  	case NFPROTO_IPV4:
-	case NFPROTO_IPV6:
  	case NFPROTO_INET:
  		hooks = (1 << NF_INET_LOCAL_IN) |
  			(1 << NF_INET_PRE_ROUTING) |

I have the feeling I should re-review everything I did 7 years ago :-)

Thanks!