Skip to contentSkip to conversation

netfilter: nfnetlink: Initialise extack before use in ACKs

PATCH In review Donald Hunter 2 participants 4 messages Aug 6, 2024 – Aug 9, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nfnetlink: Initialise extack before use in ACKs

Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.

Fixes bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
---
 net/netfilter/nfnetlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/netfilter/nfnetlink.c +4 -1
index 4abf660c7baf..932b3ddb34f1 100644
@@ -427,8 +427,10 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	nfnl_unlock(subsys_id);
 
-	if (nlh->nlmsg_flags & NLM_F_ACK)
+	if (nlh->nlmsg_flags & NLM_F_ACK) {
+		memset(&extack, 0, sizeof(extack));
 		nfnl_err_add(&err_list, nlh, 0, &extack);
+	}
 
 	while (skb->len >= nlmsg_total_size(0)) {
 		int msglen, type;
@@ -577,6 +579,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
 			ss->abort(net, oskb, NFNL_ABORT_NONE);
 			netlink_ack(oskb, nlmsg_hdr(oskb), err, NULL);
 		} else if (nlh->nlmsg_flags & NLM_F_ACK) {
+			memset(&extack, 0, sizeof(extack));
 			nfnl_err_add(&err_list, nlh, 0, &extack);
 		}
 	} else {
Signature · 1 line
2.45.2
reviewer
#1 lore raw
Quoted 4 lines · Donald Hunter

Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.

Fixes bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")

Hi Donald,

I see two other places that extack is used in nfnetlink_rcv_batch(). Is it safe to leave them as-is?

Quoted 32 lines
---
 net/netfilter/nfnetlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
net/netfilter/nfnetlink.c +4 -1
index 4abf660c7baf..932b3ddb34f1 100644
@@ -427,8 +427,10 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
 
 	nfnl_unlock(subsys_id);
 
-	if (nlh->nlmsg_flags & NLM_F_ACK)
+	if (nlh->nlmsg_flags & NLM_F_ACK) {
+		memset(&extack, 0, sizeof(extack));
 		nfnl_err_add(&err_list, nlh, 0, &extack);
+	}
 
 	while (skb->len >= nlmsg_total_size(0)) {
 		int msglen, type;
@@ -577,6 +579,7 @@ static void nfnetlink_rcv_batch(struct sk_buff *skb, struct nlmsghdr *nlh,
 			ss->abort(net, oskb, NFNL_ABORT_NONE);
 			netlink_ack(oskb, nlmsg_hdr(oskb), err, NULL);
 		} else if (nlh->nlmsg_flags & NLM_F_ACK) {
+			memset(&extack, 0, sizeof(extack));
 			nfnl_err_add(&err_list, nlh, 0, &extack);
 		}
 	} else {
Signature · 1 line
2.45.2
#2 lore raw
Quoted 10 lines · Simon Horman
Quoted 4 lines · Donald Hunter

Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.

Fixes bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")

Hi Donald,

I see two other places that extack is used in nfnetlink_rcv_batch(). Is it safe to leave them as-is?

There is a memset at the start of the main while loop that zeroes extack for those two cases.

reviewer Reviewed-by
#3 lore raw
Quoted 8 lines · Donald Hunter
Quoted 6 lines · Simon Horman
Quoted 4 lines · Donald Hunter

Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.

Fixes bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
Quoted 7 lines
Quoted 4 lines

Hi Donald,

I see two other places that extack is used in nfnetlink_rcv_batch(). Is it safe to leave them as-is?

There is a memset at the start of the main while loop that zeroes extack for those two cases.

Thanks Donald,

I missed that.

I was wondering if it might be best to clear extack at the beginning of the function. But if the loop needs to clear it on each iteration, then I think your solution is good.