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 4A2EE1C6AB; Mon, 4 Mar 2024 21:53:30 +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=1709589210; cv=none; b=AGaHU4emXxnrrrR+cCdFW3VeljXaXkdDTAjr53hY6B6WzDR0Y7UUqlBHyXn2C1g0lsRPtgZfQDz1IqFTQi0agkHxsQyAC0tayq5Ix8b0bw5CIC21xw1szR7bnNQ9p33CHBAzveTTC9Z0Bn8Wmvg1Uqf4RZVmYZy1CoapeJ0g9Yc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709589210; c=relaxed/simple; bh=8CHpIqK/rpacUGC+m4xbwkBq8N/MGtg8SjQlKGBIOlg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c7U1aLhxbs0Rr+OkA7nXisRHhNEq5gsMXdnOJhuH5PStZziR80kvqo+vczqPr10lu3E++jJRlI3ARKXg9LPauWuzWeY0pb9FWW2TfrwsoRZ3F4EWtOUr1RxkBFvdu7Ui7Izz3skor6/H2HIFElsjkruOITjCaQLTHJBxK+QrcjU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=zbqqEDh3; 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="zbqqEDh3" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CF5C0C433C7; Mon, 4 Mar 2024 21:53:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709589210; bh=8CHpIqK/rpacUGC+m4xbwkBq8N/MGtg8SjQlKGBIOlg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zbqqEDh3yZ5agOucUbH2dH1IyRh9idQV3DJvXGfBba//3+UtZ11gJ43/oH5O9nqLP l2mus3KvASKiZOxOJxPsW3K8YLteT0MHgAC/FAd+ceRYalbGDDhzyelYzNm6VGMDMW PFsZ2vLV5TY4nYSCADd91S+yWjv3NF+BPQJmCA8M= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Christian Brauner , David Ahern , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 08/84] ipv6: fix potential "struct net" leak in inet6_rtm_getaddr() Date: Mon, 4 Mar 2024 21:23:41 +0000 Message-ID: <20240304211542.617966502@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240304211542.332206551@linuxfoundation.org> References: <20240304211542.332206551@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: Eric Dumazet [ Upstream commit 10bfd453da64a057bcfd1a49fb6b271c48653cdb ] It seems that if userspace provides a correct IFA_TARGET_NETNSID value but no IFA_ADDRESS and IFA_LOCAL attributes, inet6_rtm_getaddr() returns -EINVAL with an elevated "struct net" refcount. Fixes: 6ecf4c37eb3e ("ipv6: enable IFA_TARGET_NETNSID for RTM_GETADDR") Signed-off-by: Eric Dumazet Cc: Christian Brauner Cc: David Ahern Reviewed-by: David Ahern Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/addrconf.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index c52317184e3e2..968ca078191cd 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -5463,9 +5463,10 @@ static int inet6_rtm_getaddr(struct sk_buff *in_skb, struct nlmsghdr *nlh, } addr = extract_addr(tb[IFA_ADDRESS], tb[IFA_LOCAL], &peer); - if (!addr) - return -EINVAL; - + if (!addr) { + err = -EINVAL; + goto errout; + } ifm = nlmsg_data(nlh); if (ifm->ifa_index) dev = dev_get_by_index(tgt_net, ifm->ifa_index); -- 2.43.0