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 E9B1618801A; Tue, 30 Jul 2024 16:58:40 +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=1722358721; cv=none; b=qhHHWEbSry+HlZiMwru9apFK2341IFhYX7dFzgQXSB0mkztyWKYYarTmFKBAoT6cXS/tNB/vg9PTpvzoAdcGaC54TSk7RWSwpu3a4UZWQ8hCoTv7IitNGz6jHGE8kSupR9YWXn3nimVXN2gKgPWVaUKw3Nm0S+5IyyNCBMdA18I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722358721; c=relaxed/simple; bh=rXaKpUl8VD5hJU7iwQ9tXpCkGgl/IEwfEwp4o8gNn2E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Csyn9V0nig3MIL4Zfbq5D9g3MsJ9sLFDNWGUjdxXwZwdTTyRJ5EBSqISnljOCKPqaA2aeEi9KHmZYhRtn+DSdGnUxhgneY5cbIhliMKLrdqClfytWW0+tpc6bJjyak1qV8d1EPPy4vaKu+oQ0qtYi904uj7aMZTWpqBWAuDFqgQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=gbZ8QmeX; 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="gbZ8QmeX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5459AC32782; Tue, 30 Jul 2024 16:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1722358720; bh=rXaKpUl8VD5hJU7iwQ9tXpCkGgl/IEwfEwp4o8gNn2E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gbZ8QmeX0xnsAGajUcCWQTGEFHRde8jHjN0LQOyScIeEHJxZp1luUpKygTzpoCQUh ZHMWOtyt5uzFHUsY8/lv/5DWMWoDjOKE2qkNBBdmGCYRF1OywZL/4+2NBfFaeFMh/D sFLJJOIE+cEfG41VpU30QwFT5ZnaUg0defbSkDm4= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Petr Machata , Ido Schimmel , Eric Dumazet , "David S. Miller" , Sasha Levin Subject: [PATCH 6.1 416/440] net: nexthop: Initialize all fields in dumped nexthops Date: Tue, 30 Jul 2024 17:50:49 +0200 Message-ID: <20240730151632.037356611@linuxfoundation.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240730151615.753688326@linuxfoundation.org> References: <20240730151615.753688326@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 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Petr Machata [ Upstream commit 6d745cd0e9720282cd291d36b9db528aea18add2 ] struct nexthop_grp contains two reserved fields that are not initialized by nla_put_nh_group(), and carry garbage. This can be observed e.g. with strace (edited for clarity): # ip nexthop add id 1 dev lo # ip nexthop add id 101 group 1 # strace -e recvmsg ip nexthop get id 101 ... recvmsg(... [{nla_len=12, nla_type=NHA_GROUP}, [{id=1, weight=0, resvd1=0x69, resvd2=0x67}]] ...) = 52 The fields are reserved and therefore not currently used. But as they are, they leak kernel memory, and the fact they are not just zero complicates repurposing of the fields for new ends. Initialize the full structure. Fixes: 430a049190de ("nexthop: Add support for nexthop groups") Signed-off-by: Petr Machata Reviewed-by: Ido Schimmel Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv4/nexthop.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c index be5498f5dd319..bba955d82f723 100644 --- a/net/ipv4/nexthop.c +++ b/net/ipv4/nexthop.c @@ -676,9 +676,10 @@ static int nla_put_nh_group(struct sk_buff *skb, struct nh_group *nhg) p = nla_data(nla); for (i = 0; i < nhg->num_nh; ++i) { - p->id = nhg->nh_entries[i].nh->id; - p->weight = nhg->nh_entries[i].weight - 1; - p += 1; + *p++ = (struct nexthop_grp) { + .id = nhg->nh_entries[i].nh->id, + .weight = nhg->nh_entries[i].weight - 1, + }; } if (nhg->resilient && nla_put_nh_group_res(skb, nhg)) -- 2.43.0