netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs
@ 2024-08-06 15:43 Donald Hunter
  2024-08-09  9:02 ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Donald Hunter @ 2024-08-06 15:43 UTC (permalink / raw)
  To: Pablo Neira Ayuso, Jozsef Kadlecsik, David S . Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netfilter-devel,
	netdev
  Cc: donald.hunter, Donald Hunter

Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.

Fixes: bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
---
 net/netfilter/nfnetlink.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
index 4abf660c7baf..932b3ddb34f1 100644
--- a/net/netfilter/nfnetlink.c
+++ b/net/netfilter/nfnetlink.c
@@ -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 {
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs
  2024-08-06 15:43 [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs Donald Hunter
@ 2024-08-09  9:02 ` Simon Horman
  2024-08-09 11:15   ` Donald Hunter
  0 siblings, 1 reply; 4+ messages in thread
From: Simon Horman @ 2024-08-09  9:02 UTC (permalink / raw)
  To: Donald Hunter
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netfilter-devel,
	netdev, donald.hunter

On Tue, Aug 06, 2024 at 04:43:24PM +0100, Donald Hunter wrote:
> Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.
> 
> Fixes: bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
> Signed-off-by: Donald Hunter <donald.hunter@gmail.com>

Hi Donald,

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

> ---
>  net/netfilter/nfnetlink.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/net/netfilter/nfnetlink.c b/net/netfilter/nfnetlink.c
> index 4abf660c7baf..932b3ddb34f1 100644
> --- a/net/netfilter/nfnetlink.c
> +++ b/net/netfilter/nfnetlink.c
> @@ -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 {
> -- 
> 2.45.2
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs
  2024-08-09  9:02 ` Simon Horman
@ 2024-08-09 11:15   ` Donald Hunter
  2024-08-09 15:33     ` Simon Horman
  0 siblings, 1 reply; 4+ messages in thread
From: Donald Hunter @ 2024-08-09 11:15 UTC (permalink / raw)
  To: Simon Horman
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netfilter-devel,
	netdev, donald.hunter

Simon Horman <horms@kernel.org> writes:

> On Tue, Aug 06, 2024 at 04:43:24PM +0100, Donald Hunter wrote:
>> Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.
>> 
>> Fixes: bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
>> Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
>
> 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.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs
  2024-08-09 11:15   ` Donald Hunter
@ 2024-08-09 15:33     ` Simon Horman
  0 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-08-09 15:33 UTC (permalink / raw)
  To: Donald Hunter
  Cc: Pablo Neira Ayuso, Jozsef Kadlecsik, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni, netfilter-devel,
	netdev, donald.hunter

On Fri, Aug 09, 2024 at 12:15:55PM +0100, Donald Hunter wrote:
> Simon Horman <horms@kernel.org> writes:
> 
> > On Tue, Aug 06, 2024 at 04:43:24PM +0100, Donald Hunter wrote:
> >> Add missing extack initialisation when ACKing BATCH_BEGIN and BATCH_END.
> >> 
> >> Fixes: bf2ac490d28c ("netfilter: nfnetlink: Handle ACK flags for batch messages")
> >> Signed-off-by: Donald Hunter <donald.hunter@gmail.com>
> >
> > 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.

Reviewed-by: Simon Horman <horms@kernel.org>


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-09 15:33 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-08-06 15:43 [PATCH nf v1] netfilter: nfnetlink: Initialise extack before use in ACKs Donald Hunter
2024-08-09  9:02 ` Simon Horman
2024-08-09 11:15   ` Donald Hunter
2024-08-09 15:33     ` Simon Horman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).