From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DF2BF17FD; Thu, 13 Jun 2024 12:44:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282664; cv=none; b=l4k9JNrjSUxwcZYG7gF8/zadEe8mds9rOTDXm68xHfL3PAtnBJXjgCoYF0YU8oHxhyP4UGUVSiNIFVziPRDZe6rSQCGrCI9xfJc6c6ki0r3rv/EelR9ei3LrXsAsAyxWJvwFJcqhA3ZefOZautmeyjsBCV3mHu+t7nkWzsP5y78= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718282664; c=relaxed/simple; bh=9LukZfHQNCzwY/KuXgaTfKVnE65hL6vKhg3+q23HgVU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YSb6z1CloqOHeBehUDnQuUeKwTk7j4J6SkNYCw94g8I37LIx+vL8LILEshfMstcQiOwGnRzFml+CjWFQHgPrYZ/D+MESbrNXz7CBJ8WNEjxth2ZX/0LUTAlaKnCuvFzbWl4/fgLur3ZdeuGZsSP2E/EB7WK3l0DMmrpcRFf9/bs= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=FaEiUmhg; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="FaEiUmhg" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 63F6CC2BBFC; Thu, 13 Jun 2024 12:44:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718282663; bh=9LukZfHQNCzwY/KuXgaTfKVnE65hL6vKhg3+q23HgVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FaEiUmhgvVRl8Fhi1XwLCO35kOlmrI4ezWkNlOBxQ8u0Knpla1rDp07ON2QsGD1lW RM35yHS55ugYwdhpTSzQhCc4Pv7eAv50oEFPcJPtxBFsuyRtbTifHkfCqUogECmg2h ilyU4xRHPXbpRiH65elRxdOcetub7MSebU8MTTIc= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Florian Westphal , Pablo Neira Ayuso , Sasha Levin , syzbot+b94a6818504ea90d7661@syzkaller.appspotmail.com Subject: [PATCH 5.15 323/402] netfilter: tproxy: bail out if IP has been disabled on the device Date: Thu, 13 Jun 2024 13:34:40 +0200 Message-ID: <20240613113314.736853084@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240613113302.116811394@linuxfoundation.org> References: <20240613113302.116811394@linuxfoundation.org> User-Agent: quilt/0.67 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Florian Westphal [ Upstream commit 21a673bddc8fd4873c370caf9ae70ffc6d47e8d3 ] syzbot reports: general protection fault, probably for non-canonical address 0xdffffc0000000003: 0000 [#1] PREEMPT SMP KASAN PTI KASAN: null-ptr-deref in range [0x0000000000000018-0x000000000000001f] [..] RIP: 0010:nf_tproxy_laddr4+0xb7/0x340 net/ipv4/netfilter/nf_tproxy_ipv4.c:62 Call Trace: nft_tproxy_eval_v4 net/netfilter/nft_tproxy.c:56 [inline] nft_tproxy_eval+0xa9a/0x1a00 net/netfilter/nft_tproxy.c:168 __in_dev_get_rcu() can return NULL, so check for this. Reported-and-tested-by: syzbot+b94a6818504ea90d7661@syzkaller.appspotmail.com Fixes: cc6eb4338569 ("tproxy: use the interface primary IP address as a default value for --on-ip") Signed-off-by: Florian Westphal Signed-off-by: Pablo Neira Ayuso Signed-off-by: Sasha Levin --- net/ipv4/netfilter/nf_tproxy_ipv4.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/ipv4/netfilter/nf_tproxy_ipv4.c b/net/ipv4/netfilter/nf_tproxy_ipv4.c index 61cb2341f50fe..7c1a0cd9f4359 100644 --- a/net/ipv4/netfilter/nf_tproxy_ipv4.c +++ b/net/ipv4/netfilter/nf_tproxy_ipv4.c @@ -58,6 +58,8 @@ __be32 nf_tproxy_laddr4(struct sk_buff *skb, __be32 user_laddr, __be32 daddr) laddr = 0; indev = __in_dev_get_rcu(skb->dev); + if (!indev) + return daddr; in_dev_for_each_ifa_rcu(ifa, indev) { if (ifa->ifa_flags & IFA_F_SECONDARY) -- 2.43.0