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 183B21419B3; Tue, 27 Feb 2024 14:12:06 +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=1709043127; cv=none; b=dQMvTjj/+b+EMKj6QLLUc4N7PzE26z1McnT2pIySEcx1UyUjfp75+Nuqj9NLx+tzzCKuQlk2tN57gdivZ6tg+FdQlhKjW7/+WgL+6TCXTF4tre434f0D7mU/Qz2DM5EcrJW+JkfSJg8tB+uaqm+TdauRc9Wq0CkU/UaiDzyFGY8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709043127; c=relaxed/simple; bh=bqxgm4oBKc9vgV7Wo+EMpXj4A+YEfvqp8z4myplcmZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VYqidyqeF7qH9KQBMh5eVaIxe4MZXF9Q6JX4ftRGGwdivN24pwWLiJ47t05A1Pgvnua6mDenAJ8X2i86dDuWZPMnqW44upTF3w0j2Id+IR058zHGUVRuhJanuenT6jzp2DXzdxWwGk/IIk3/eDQU5o6p4CrIqrA9VF5OgWV+pEU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=sKYITz2/; 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="sKYITz2/" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4263EC433C7; Tue, 27 Feb 2024 14:12:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1709043126; bh=bqxgm4oBKc9vgV7Wo+EMpXj4A+YEfvqp8z4myplcmZg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=sKYITz2/8kxSTkTkUL91SxKXJaqeXYl+2f9fVuGYN/CX9cVePAjQpl0zGROwcbT7Q 1na8VJX3s6RBPgF8P6+/aRok9441jiNyiefpp+m/PaGxkTDYX+sjuGT7G8KHTfrtSs BKPN0lXriiUJOiiRbe5713AG6DMYD71iVnoFfn6o= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Eric Dumazet , Nicolas Dichtel , "David S. Miller" , Sasha Levin Subject: [PATCH 5.15 216/245] ipv6: properly combine dev_base_seq and ipv6.dev_addr_genid Date: Tue, 27 Feb 2024 14:26:44 +0100 Message-ID: <20240227131622.225347410@linuxfoundation.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240227131615.098467438@linuxfoundation.org> References: <20240227131615.098467438@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 e898e4cd1aab271ca414f9ac6e08e4c761f6913c ] net->dev_base_seq and ipv6.dev_addr_genid are monotonically increasing. If we XOR their values, we could miss to detect if both values were changed with the same amount. Fixes: 63998ac24f83 ("ipv6: provide addr and netconf dump consistency info") Signed-off-by: Eric Dumazet Cc: Nicolas Dichtel Signed-off-by: Eric Dumazet Acked-by: Nicolas Dichtel Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/ipv6/addrconf.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c index 1e4eedf7f2129..c52317184e3e2 100644 --- a/net/ipv6/addrconf.c +++ b/net/ipv6/addrconf.c @@ -707,6 +707,22 @@ static int inet6_netconf_get_devconf(struct sk_buff *in_skb, return err; } +/* Combine dev_addr_genid and dev_base_seq to detect changes. + */ +static u32 inet6_base_seq(const struct net *net) +{ + u32 res = atomic_read(&net->ipv6.dev_addr_genid) + + net->dev_base_seq; + + /* Must not return 0 (see nl_dump_check_consistent()). + * Chose a value far away from 0. + */ + if (!res) + res = 0x80000000; + return res; +} + + static int inet6_netconf_dump_devconf(struct sk_buff *skb, struct netlink_callback *cb) { @@ -740,8 +756,7 @@ static int inet6_netconf_dump_devconf(struct sk_buff *skb, idx = 0; head = &net->dev_index_head[h]; rcu_read_lock(); - cb->seq = atomic_read(&net->ipv6.dev_addr_genid) ^ - net->dev_base_seq; + cb->seq = inet6_base_seq(net); hlist_for_each_entry_rcu(dev, head, index_hlist) { if (idx < s_idx) goto cont; @@ -5316,7 +5331,7 @@ static int inet6_dump_addr(struct sk_buff *skb, struct netlink_callback *cb, } rcu_read_lock(); - cb->seq = atomic_read(&tgt_net->ipv6.dev_addr_genid) ^ tgt_net->dev_base_seq; + cb->seq = inet6_base_seq(tgt_net); for (h = s_h; h < NETDEV_HASHENTRIES; h++, s_idx = 0) { idx = 0; head = &tgt_net->dev_index_head[h]; -- 2.43.0