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 72757388873; Tue, 21 Jul 2026 21:32:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669556; cv=none; b=eECkJ1hJ2OYeHD4Q1OtlGw0HkokF+FgaEgVbhIDuHkoRTAta02nOJz2o1QGQOEa0HGHU1wRWOjyrU1pwWRkJddqNUz0masJsEO6qGIHBEufEmNWX73vAJ7u3aE1QfGfhZ3+OHQ7uLFc6KE4iMA5Pbpocw1sDcON98YfNeOJzWHc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784669556; c=relaxed/simple; bh=Svl0CAtuEcyj2SMkHZgmCaArezc6s8+09vfpDIpq8oc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EwzrrAd+QinhIpUUL39mXBe+xfCWfiJSWD7MFrfYfxGBOxp+a1B+AU0CSi5Az/015+pLIfmVMhRnSP5T2QuSXZimSiSacnVJOpzlZ+UMN/uEdsCkKQeB0WFDMprUmkLycF19AJU0rrTeKLUVWrKYxb04v2dBtu9P9iy9hOQKRc8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=WZ/3b7mG; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="WZ/3b7mG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D2AB41F000E9; Tue, 21 Jul 2026 21:32:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1784669555; bh=AkyCx7FjzNU8UGNIEp5lkbedPkbBpczXf0GqJutrlLU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=WZ/3b7mGn+O+mCgvpxKYjMLTpuc6FVHVgf65+GQk+ie5qt8pBBfXouCiA/gVjZqzT KHeezADii39yrJfrxXZHJVRwa+HJUZtYuznJTLAO+QBl4y9cQQ0FiDGJynqso4X9Wy b7TPnIlsrvzePc+dvoMjVc3d0X393zb7Ph30nBTU= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jozsef Kadlecsik , Pablo Neira Ayuso , Sasha Levin Subject: [PATCH 6.1 0598/1067] netfilter: ipset: fix order of kfree_rcu() and rcu_assign_pointer() Date: Tue, 21 Jul 2026 17:19:59 +0200 Message-ID: <20260721152437.981240072@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260721152424.521567757@linuxfoundation.org> References: <20260721152424.521567757@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Jozsef Kadlecsik [ Upstream commit 3ca9982a8882470aa0ac4e8bb9a552b181d1efcd ] Sashiko pointed out that kfree_rcu() was called before rcu_assign_pointer() in handling the comment extension. Fix the order so that rcu_assign_pointer() called first. Fixes: b57b2d1fa53f ("netfilter: ipset: Prepare the ipset core to use RCU at set level") Signed-off-by: Jozsef Kadlecsik Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/netfilter/ipset/ip_set_core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/netfilter/ipset/ip_set_core.c b/net/netfilter/ipset/ip_set_core.c index d021795f3c609f..1d6579358f9ba2 100644 --- a/net/netfilter/ipset/ip_set_core.c +++ b/net/netfilter/ipset/ip_set_core.c @@ -351,8 +351,8 @@ ip_set_init_comment(struct ip_set *set, struct ip_set_comment *comment, if (unlikely(c)) { set->ext_size -= sizeof(*c) + strlen(c->str) + 1; - kfree_rcu(c, rcu); rcu_assign_pointer(comment->c, NULL); + kfree_rcu(c, rcu); } if (!len) return; @@ -393,8 +393,8 @@ ip_set_comment_free(struct ip_set *set, void *ptr) if (unlikely(!c)) return; set->ext_size -= sizeof(*c) + strlen(c->str) + 1; - kfree_rcu(c, rcu); rcu_assign_pointer(comment->c, NULL); + kfree_rcu(c, rcu); } typedef void (*destroyer)(struct ip_set *, void *); -- 2.53.0