mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: "Jérémy Jean" <Jeremy.Jean@oss.cyber.gouv.fr>
Cc: Jamal Hadi Salim <jhs@mojatatu.com>,
	Jiri Pirko <jiri@resnulli.us>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	stable@vger.kernel.org
Subject: Re: [PATCH net] net/sched: fix use-after-free in __tcf_action_put()
Date: Wed, 7 Oct 2026 17:35:03 -0700	[thread overview]
Message-ID: <20261007173503.588b9c7f@kernel.org> (raw)
In-Reply-To: <20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr>

On Wed, 30 Sep 2026 21:18:40 +0000 Jérémy Jean wrote:
>  {
>  	struct tcf_idrinfo *idrinfo = p->idrinfo;
>  
> -	if (refcount_dec_and_mutex_lock(&p->tcfa_refcnt, &idrinfo->lock)) {
> -		if (bind)
> -			atomic_dec(&p->tcfa_bindcnt);
> -		idr_remove(&idrinfo->action_idr, p->tcfa_index);
> +	mutex_lock(&idrinfo->lock);
> +	if (bind)
> +		atomic_dec(&p->tcfa_bindcnt);
> +	if (!refcount_dec_and_test(&p->tcfa_refcnt)) {
>  		mutex_unlock(&idrinfo->lock);
> -
> -		tcf_action_cleanup(p);
> -		return 1;
> +		return 0;
>  	}
>  
> -	if (bind)
> -		atomic_dec(&p->tcfa_bindcnt);
> +	idr_remove(&idrinfo->action_idr, p->tcfa_index);
> +	mutex_unlock(&idrinfo->lock);
>  
> -	return 0;
> +	tcf_action_cleanup(p);
> +	return 1;
>  }

Why did you decide to invert the condition?
If nothing else the diff would be more readable without that
-- 
pw-bot: cr

  parent reply	other threads:[~2026-10-08  0:35 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-30 21:18 Jérémy Jean
2026-09-30 21:24 ` netdev-bot+sinfo
2026-10-08  0:35 ` Jakub Kicinski [this message]
2026-10-08  9:03   ` Jérémy Jean

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261007173503.588b9c7f@kernel.org \
    --to=kuba@kernel.org \
    --cc=Jeremy.Jean@oss.cyber.gouv.fr \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®