[PATCH] netfilter: nfnetlink_log: remove unnecessary check in __build_packet_message()

Roman Smirnov posted 1 patch 1 year, 6 months ago
net/netfilter/nfnetlink_log.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
[PATCH] netfilter: nfnetlink_log: remove unnecessary check in __build_packet_message()
Posted by Roman Smirnov 1 year, 6 months ago
skb->dev is always non-NULL, the check is unnecessary.

Remove it.

Found by Linux Verification Center (linuxtesting.org) with Svace.

Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
---
 net/netfilter/nfnetlink_log.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/netfilter/nfnetlink_log.c b/net/netfilter/nfnetlink_log.c
index 134e05d31061..ee04a52eaf33 100644
--- a/net/netfilter/nfnetlink_log.c
+++ b/net/netfilter/nfnetlink_log.c
@@ -566,8 +566,7 @@ __build_packet_message(struct nfnl_log_net *log,
 	    nla_put_be32(inst->skb, NFULA_MARK, htonl(skb->mark)))
 		goto nla_put_failure;
 
-	if (indev && skb->dev &&
-	    skb_mac_header_was_set(skb) &&
+	if (indev && skb_mac_header_was_set(skb) &&
 	    skb_mac_header_len(skb) != 0) {
 		struct nfulnl_msg_packet_hw phw;
 		int len;
-- 
2.43.0
Re: [PATCH] netfilter: nfnetlink_log: remove unnecessary check in __build_packet_message()
Posted by Pablo Neira Ayuso 1 year, 5 months ago
On Fri, Aug 09, 2024 at 10:40:35AM +0300, Roman Smirnov wrote:
> skb->dev is always non-NULL, the check is unnecessary.

Same check exists in nfnetlink_queue, these two codebases have many
similarities.

I cannot think of any scenario where skb->dev is NULL in any of the
existing hooks.
Re: [PATCH] netfilter: nfnetlink_log: remove unnecessary check in __build_packet_message()
Posted by Sergey Shtylyov 1 year, 6 months ago
On 8/9/24 10:40 AM, Roman Smirnov wrote:

> skb->dev is always non-NULL, the check is unnecessary.
> 
> Remove it.

   Mhm, I don't think we need that in a separate paragraph...

> Found by Linux Verification Center (linuxtesting.org) with Svace.
> 
> Signed-off-by: Roman Smirnov <r.smirnov@omp.ru>
> Reviewed-by: Sergey Shtylyov <s.shtylyov@omp.ru>
[...]

MBR, Sergey