Article View: linux.kernel.netdev
Article #389Re: [PATCH net] net/sched: fix use-after-free in __tcf_action_put()
From: Jakub Kicinski
Date: Thu, 08 Oct 2026 00:35
Date: Thu, 08 Oct 2026 00:35
34 lines
6198 bytes
6198 bytes
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
Technical Details
Message-ID:
<20261007173503.588b9c7f@kernel.org>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342604-linux-kernel-netdev=dewy.ruReferences:
<20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-342604-linux-kernel-netdev=dewy.ru From: kuba@kernel.org (Jakub Kicinski) Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net] net/sched: fix use-after-free in __tcf_action_put() Date: Wed, 7 Oct 2026 17:35:03 -0700 Organization: Usenet Network Message-ID: <20261007173503.588b9c7f@kernel.org> References: <20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Injection-Info: usenet.network; logging-data="769544"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:EhIfwmLhlATzO8kY8xsiDtCy05k= sha256:FcFXUgsVmcavimafbkMLVa3s+GCljTxMVObbFVsgHzQ= sha1:ToOsVwn3vZTl9wFoU10z+KJwveQ= sha256:lbnbskBoMZxV48YzmAkfZVaIwTh89jMM5flNd0ca3VE= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id 196D510F28F; Thu, 8 Oct 2026 03:35:19 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.641 X-Spam-Status: No, score=-3.641 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.241, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HOP_4sJee1yu; Thu, 8 Oct 2026 03:35:15 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-342604-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114]) by mail.dewy.ru (Postfix) with ESMTPS id 607D110F26B; Thu, 8 Oct 2026 03:35:10 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1]) by tor.lore.kernel.org (Postfix) with ESMTP id 4B6012A775; Thu, 8 Oct 2026 00:35:08 +0000 (UTC) X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C66C023E358; Thu, 8 Oct 2026 00:35:05 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SVFYUk+Q" X-Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D4F75381AF; Thu, 8 Oct 2026 00:35:04 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791419705; cv=none; b=febPr6qKjdKCiFYKlUeDV9WmcXwBMN8wz4/HCrdH7HLjrUCDAzep7sBlIWmNAy3OMw/33EEjAuXimSIhD+wGeznGw4v+mQaS5swoOdS9h3JZJGcm4h2z+vwq0KnEZzBR74t8v0Ho8VGAeubls+hPo3Fn4yIqVkV59ZTkSWmJ3qs= X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791419705; c=relaxed/simple; bh=bAY7R70u8yCxhxt5vzGfOpTXCpQ0LLpJKoIammqUgIk=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Kl5/H1S3C44LGi9qyf5Nl7jlFmZKvQOMDBjWYAHsDPSmWc9Y5ux9K8Uq7WCuLoJmdGXonvnln2f0rHFnXrBNYP+giSn//aX5QknsDnNrbIVsJYXfFvG92J2FHUjtx+cx4ykLhFajC2wO3c1V1wkUeo/eNlYqmHSVTbJYnFNJ6gE= X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SVFYUk+Q; arc=none smtp.client-ip=100.103.45.18 X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3F3CD1F000FF; Thu, 8 Oct 2026 00:35:04 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1791419704; bh=8YQPEMMo0JLlEBVIBy0jUTyHpziLsNDBp9vaxg54cdI=; h=Date:From:To:Cc:Subject:In-Reply-To:References; b=SVFYUk+QE5fhlcq0nkVUyz8Kv+0EpPJ2g3VGxyx9rcMgzbM5qONusDjxTNcD11I48 iM3QeuHHHmGncebJfIxIR8FbGuDJg6dexnEwdiblVBM3FIysr03XDCH99AL89bUus/ BkXV5gVxpiIm5c3+LU2p/jeLE3ERZznaRzKh6yLnTyA7nqbMEYykwMzN5GgC8M0Hn4 Jl3IHaw9Z/h84gs/TcirdOUf6aizsTYfxmTqLQfG2M0A0acZB20ERqQd6vAlb/Fu9D hYcEUNg//PM7/woXRYJCTaCyXYi8o+iTumXih3iyNlKN9n6/eLVXY8W4QJlEwutJs2 XbJA4wqBy0kXA== X-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 X-In-Reply-To: <20260930211839.620410-2-Jeremy.Jean@oss.cyber.gouv.fr> X-Precedence: bulk X-Mailing-List: netdev@vger.kernel.org X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>