All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@nvidia.com>
To: zhuorao yang <alex000young@gmail.com>
Cc: David Ahern <dsahern@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Willem de Bruijn <willemb@google.com>,
	netdev@vger.kernel.org
Subject: Re: [PATCH net] ipv6: reject permanent flag on temporary addresses
Date: Tue, 1 Dec 2026 17:14:54 +0200	[thread overview]
Message-ID: <20261201151454.GA2164524@shredder> (raw)
In-Reply-To: <20261201122605.8080-1-alex000young@gmail.com>

On Tue, Dec 01, 2026 at 08:26:05PM +0800, zhuorao yang wrote:
> RTM_NEWADDR always adds IFA_F_PERMANENT to cfg->ifa_flags.

The review bots are allergic to "always" and will most likely complain
that the flag is not added when user space specifies a finite valid
lifetime.

> inet6_addr_modify() clears the permanent bit on the existing address,
> then ORs the requested flags back, but leaves IFA_F_TEMPORARY set. This
> can create a temporary address with permanent semantics.
> 
> If keep_addr_on_down is enabled, addrconf_ifdown() first removes the
> address from tempaddr_list and then preserves it because it is marked
> permanent. A later RTM_DELADDR calls ipv6_del_addr(), which deletes the
> already poisoned tmp_list node and crashes the kernel.

Please include a trimmed backtrace in the commit message. See commit
aa1799e93f5e ("ipmr, ip6mr: validate packets injected into the register
vif on xmit") for example.

> Reject attempts to change a temporary address to permanent semantics.
> Temporary addresses are managed through their public prefix.

[...]

> diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
> index d9d13e78bf13..0942bffbae97 100644
> --- a/net/ipv6/addrconf.c
> +++ b/net/ipv6/addrconf.c
> @@ -4921,6 +4921,10 @@ static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp,
>  
>  	ASSERT_RTNL_NET(net);
>  
> +	if ((ifp->flags & IFA_F_TEMPORARY) &&
> +	    (cfg->ifa_flags & IFA_F_PERMANENT))
> +		return -EINVAL;
> +

It's possible that no one is replacing temporary addresses without
specifying a finite valid lifetime, but if there are such users, then
this change will break them.

A safer change is to simply clear the permanent flag from cfg->ifa_flags
when the address is temporary:

diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 656bf1ea26da..50e00805e5ae 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -4930,6 +4930,10 @@ static int inet6_addr_modify(struct net *net, struct inet6_ifaddr *ifp,
 	if (!(ifp->flags & IFA_F_TENTATIVE) || ifp->flags & IFA_F_DADFAILED)
 		cfg->ifa_flags &= ~IFA_F_OPTIMISTIC;
 
+	/* Temporary addresses are never permanent */
+	if (ifp->flags & IFA_F_TEMPORARY)
+		cfg->ifa_flags &= ~IFA_F_PERMANENT;
+
 	if (cfg->peer_pfx &&
 	    memcmp(&ifp->peer_addr, cfg->peer_pfx, sizeof(struct in6_addr))) {
 		if (!ipv6_addr_any(&ifp->peer_addr))

Please wait for the AI review and at least 24 hours (see
Documentation/process/maintainer-netdev.rst) before submitting v2.

  reply	other threads:[~2026-12-01 15:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 12:26 [PATCH net] ipv6: reject permanent flag on temporary addresses zhuorao yang
2026-12-01 15:14 ` Ido Schimmel [this message]
     [not found] ` <69abf63fb4834193b3cea20ee57d2151@kernelpatch.local>
     [not found]   ` <axEqL4y2QHIaJ8T2@hovoldconsulting.com>
2026-12-04  2:27     ` [PATCH net v2] " zhuorao yang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261201151454.GA2164524@shredder \
    --to=idosch@nvidia.com \
    --cc=alex000young@gmail.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=willemb@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.