diff mbox series

[net-next] net: psample: fix flag being set in wrong skb

Message ID 20240709203437.1257952-1-amorenoz@redhat.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: psample: fix flag being set in wrong skb | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit fail Errors and warnings before: 18 this patch: 18
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 821 this patch: 821
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 821 this patch: 821
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Adrián Moreno July 9, 2024, 8:34 p.m. UTC
A typo makes PSAMPLE_ATTR_SAMPLE_RATE netlink flag be added to the wrong
sk_buff.

Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
---
 net/psample/psample.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Ilya Maximets July 9, 2024, 10:57 p.m. UTC | #1
On 7/9/24 22:34, Adrian Moreno wrote:
> A typo makes PSAMPLE_ATTR_SAMPLE_RATE netlink flag be added to the wrong
> sk_buff.
> 
> Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> ---
>  net/psample/psample.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/net/psample/psample.c b/net/psample/psample.c
> index f48b5b9cd409..11b7533067b8 100644
> --- a/net/psample/psample.c
> +++ b/net/psample/psample.c
> @@ -498,7 +498,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
>  		goto error;
>  
>  	if (md->rate_as_probability)
> -		nla_put_flag(skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
> +		nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
>  
>  	genlmsg_end(nl_skb, data);
>  	genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,

Uff.  Nasty.

I'd say we should change the function argument to 'const' to avoid such
issues in the future.  There is no reason for this function to modify
the original packet.  What do you think?

Best regards, Ilya Maximets.
Adrián Moreno July 9, 2024, 11:11 p.m. UTC | #2
On Wed, Jul 10, 2024 at 12:57:14AM GMT, Ilya Maximets wrote:
> On 7/9/24 22:34, Adrian Moreno wrote:
> > A typo makes PSAMPLE_ATTR_SAMPLE_RATE netlink flag be added to the wrong
> > sk_buff.
> >
> > Fixes: 7b1b2b60c63f ("net: psample: allow using rate as probability")
> > Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
> > ---
> >  net/psample/psample.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/net/psample/psample.c b/net/psample/psample.c
> > index f48b5b9cd409..11b7533067b8 100644
> > --- a/net/psample/psample.c
> > +++ b/net/psample/psample.c
> > @@ -498,7 +498,7 @@ void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
> >  		goto error;
> >
> >  	if (md->rate_as_probability)
> > -		nla_put_flag(skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
> > +		nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
> >
> >  	genlmsg_end(nl_skb, data);
> >  	genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,
>
> Uff.  Nasty.
>
> I'd say we should change the function argument to 'const' to avoid such
> issues in the future.  There is no reason for this function to modify
> the original packet.  What do you think?
>

Yes, that's probably a good idea.

Adrián.

> Best regards, Ilya Maximets.
>
diff mbox series

Patch

diff --git a/net/psample/psample.c b/net/psample/psample.c
index f48b5b9cd409..11b7533067b8 100644
--- a/net/psample/psample.c
+++ b/net/psample/psample.c
@@ -498,7 +498,7 @@  void psample_sample_packet(struct psample_group *group, struct sk_buff *skb,
 		goto error;
 
 	if (md->rate_as_probability)
-		nla_put_flag(skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
+		nla_put_flag(nl_skb, PSAMPLE_ATTR_SAMPLE_PROBABILITY);
 
 	genlmsg_end(nl_skb, data);
 	genlmsg_multicast_netns(&psample_nl_family, group->net, nl_skb, 0,