From mboxrd@z Thu Jan 1 00:00:00 1970 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 67C7633E36A; Sat, 30 May 2026 17:27:32 +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=1780162053; cv=none; b=ji1FB+IEf7ZBj4x/moFWET+6teEvQM3zL89zYfY7Pst8aUdvX/4pVxy4Jnl5S7qlb8AmNfNmfChiRb4gTpaAgrhgs9MrmNjY56nvUhidtz1ZvI/pBf7/keroKMkr3H1QO6it8bIdpdgXCH7qMncDLE/1pUbf5c8kOZceUwElGf8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780162053; c=relaxed/simple; bh=/+V3/2GRayl2Fjl4bTPj90YOtCjgFPMDQf9AZ+ES5Fs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D4Gw9UdG5RG7idM1+3AIpiGkAFbAfPsnxgwtCz8jM4VcWp9inA4sXzgtLlrwEIH5Zm0M4UW3FKOoni3N3R3kuQO5i3uCSzlSFdeYEcg6m9b4XUI4f2JHncbt3FiH+3vocG+Cg/N78NPJnHZdnu2yqDWGWrE2OfCxAFMhWqJVtnc= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=y4Gd8kd5; 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="y4Gd8kd5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81B001F00893; Sat, 30 May 2026 17:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1780162052; bh=VfZp4mNj/Z7uckElyz0qWp9HABMawbfg5VHei9opVu4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=y4Gd8kd5N35g5TzuEG7Tco76QPC/H8uEapiv4YGLS0wO9hGjXOGZ5P0k3ka4KTU0J Zlr2PSJdnpdjd1ONjsPnSiSRaDAYq2CxQJxiQ3hRaC96Qt69b4B/I8nnJz+VPfhH0i UbkXbRRGz+FSz6KzjYcChnLZ+LcsCtg4dg72qgTI= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Li Xiasong , Pablo Neira Ayuso Subject: [PATCH 6.1 807/969] netfilter: nf_conntrack_sip: get helper before allocating expectation Date: Sat, 30 May 2026 18:05:31 +0200 Message-ID: <20260530160322.916931038@linuxfoundation.org> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260530160300.485627683@linuxfoundation.org> References: <20260530160300.485627683@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: Li Xiasong commit eb6317739b1ea3ab28791e1f91b24781905fa815 upstream. process_register_request() allocates an expectation and then checks whether a conntrack helper is available. If helper lookup fails, the function returns early and the allocated expectation is left behind. Reorder the code to fetch and validate helper before calling nf_ct_expect_alloc(). This keeps the logic simpler and removes the leak path while preserving existing behavior. Fixes: e14575fa7529 ("netfilter: nf_conntrack: use rcu accessors where needed") Cc: stable@vger.kernel.org Signed-off-by: Li Xiasong Signed-off-by: Pablo Neira Ayuso Signed-off-by: Greg Kroah-Hartman --- net/netfilter/nf_conntrack_sip.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/net/netfilter/nf_conntrack_sip.c +++ b/net/netfilter/nf_conntrack_sip.c @@ -1367,6 +1367,10 @@ static int process_register_request(stru goto store_cseq; } + helper = rcu_dereference(nfct_help(ct)->helper); + if (!helper) + return NF_DROP; + exp = nf_ct_expect_alloc(ct); if (!exp) { nf_ct_helper_log(skb, ct, "cannot alloc expectation"); @@ -1377,10 +1381,6 @@ static int process_register_request(stru if (sip_direct_signalling) saddr = &ct->tuplehash[!dir].tuple.src.u3; - helper = rcu_dereference(nfct_help(ct)->helper); - if (!helper) - return NF_DROP; - nf_ct_expect_init(exp, SIP_EXPECT_SIGNALLING, nf_ct_l3num(ct), saddr, &daddr, proto, NULL, &port); exp->timeout.expires = sip_timeout * HZ;