net: ipv6/addrconf: ensure that temporary addresses' preferred lifetimes are in the valid range
Subsystems (4)
v2 cover net: ipv6/addrconf: ensure that temporary addresses' preferred lifetimes are in the valid range
No changes from v2, but there are only four patches now because the first patch has already been applied.
https://lore.kernel.org/all/[email protected]/
Alex Henrie (4):
net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
net: ipv6/addrconf: clamp preferred_lft to the minimum required
Documentation: networking: explain what happens if temp_valid_lft is
too small
Documentation: networking: explain what happens if temp_prefered_lft
is too small or too large
Documentation/networking/ip-sysctl.rst | 10 ++++++++-- net/ipv6/addrconf.c | 19 ++++++++++++++----- 2 files changed, 22 insertions(+), 7 deletions(-)
Signature · 1 line
2.42.0
PATCH v2 1/4 net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
Without this patch, there is nothing to stop the preferred lifetime of a temporary address from being greater than its valid lifetime. If that was the case, the valid lifetime was effectively ignored.
--- net/ipv6/addrconf.c | 1 + 1 file changed, 1 insertion(+)
net/ipv6/addrconf.c +1 -0
@@ -1399,6 +1399,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block) idev->cnf.temp_valid_lft + age); cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor; cfg.preferred_lft =min_t (__u32, ifp->prefered_lft, cfg.preferred_lft); + cfg.preferred_lft =min_t (__u32, cfg.valid_lft, cfg.preferred_lft); cfg.plen = ifp->prefix_len; tmp_tstamp = ifp->tstamp;
Signature · 1 line
2.42.0
Re: [PATCH net-next v2 1/4] net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
Quoted 4 lines · Tue, Oct 24, 2023 at 11:23:07PM CEST, [email protected] wrote:
Without this patch, there is nothing to stop the preferred lifetime of a temporary address from being greater than its valid lifetime. If that was the case, the valid lifetime was effectively ignored.
Sounds like a bugfix, correct? In that case, could you please provide a proper Fixes tag and target -net tree?
Quoted 21 lines
Signed-off-by Alex Henrie <[email protected]>---
net/ipv6/addrconf.c| 1 +1 file changed, 1 insertion(+)net/ipv6/addrconf.c +1
-0@@ -1399,6 +1399,7 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block) idev->cnf.temp_valid_lft + age); cfg.preferred_lft = cnf_temp_preferred_lft + age - idev->desync_factor; cfg.preferred_lft =min_t (__u32, ifp->prefered_lft, cfg.preferred_lft); + cfg.preferred_lft =min_t (__u32, cfg.valid_lft, cfg.preferred_lft); cfg.plen = ifp->prefix_len; tmp_tstamp = ifp->tstamp;Signature · 1 line
2.42.0
Re: [PATCH net-next v2 1/4] net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
Quoted 9 lines · Jiri Pirko
Quoted 4 lines · Tue, Oct 24, 2023 at 11:23:07PM CEST, [email protected] wrote:
Without this patch, there is nothing to stop the preferred lifetime of a temporary address from being greater than its valid lifetime. If that was the case, the valid lifetime was effectively ignored.
Sounds like a bugfix, correct? In that case, could you please provide a proper Fixes tag and target -net tree?
Paolo requested no Fixes tag, and Jakub seemed to agree:
https://lore.kernel.org/all/[email protected]/
https://lore.kernel.org/all/[email protected]/
Which is fine by me. These changes are not important enough to backport.
-Alex
Jiri Pirko
Reviewed-byRe: [PATCH net-next v2 1/4] net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
Quoted 8 lines · Wed, Oct 25, 2023 at 06:28:00PM CEST, [email protected] wrote:
Quoted 7 lines · Jiri Pirko
Quoted 4 lines · Tue, Oct 24, 2023 at 11:23:07PM CEST, [email protected] wrote:
Without this patch, there is nothing to stop the preferred lifetime of a temporary address from being greater than its valid lifetime. If that was the case, the valid lifetime was effectively ignored.
Quoted 6 lines
Quoted 2 lines
Sounds like a bugfix, correct? In that case, could you please provide a proper Fixes tag and target -net tree?
Paolo requested no Fixes tag, and Jakub seemed to agree:
Okay, makes sense.
Re: [PATCH net-next v2 1/4] net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
In reply to Alex HenrieQuoted 9 lines · Alex Henrie
Without this patch, there is nothing to stop the preferred lifetime of a temporary address from being greater than its valid lifetime. If that was the case, the valid lifetime was effectively ignored.
Signed-off-by Alex Henrie <[email protected]>--- net/ipv6/addrconf.c | 1 + 1 file changed, 1 insertion(+)
PATCH v2 2/4 net: ipv6/addrconf: clamp preferred_lft to the minimum required
In reply to Alex HenrieIf the preferred lifetime was less than the minimum required lifetime, ipv6_create_tempaddr would error out without creating any new address. On my machine and network, this error happened immediately with the preferred lifetime set to 1 second, after a few minutes with the preferred lifetime set to 4 seconds, and not at all with the preferred lifetime set to 5 seconds. During my investigation, I found a Stack Exchange post from another person who seems to have had the same
problem: They stopped getting new addresses if they lowered the preferred lifetime below 3 seconds, and they didn't really know why.
The preferred lifetime is a preference, not a hard requirement. The kernel does not strictly forbid new connections on a deprecated address, nor does it guarantee that the address will be disposed of the instant its total valid lifetime expires. So rather than disable IPv6 privacy extensions altogether if the minimum required lifetime swells above the preferred lifetime, it is more in keeping with the user's intent to increase the temporary address's lifetime to the minimum necessary for the current network conditions.
With these fixes, setting the preferred lifetime to 3 or 4 seconds "just works" because the extra fraction of a second is practically unnoticeable. It's even possible to reduce the time before deprecation to 1 or 2 seconds by also disabling duplicate address detection (setting /proc/sys/net/ipv6/conf/*/dad_transmits to 0). I realize that that is a pretty niche use case, but I know at least one person who would gladly sacrifice performance and convenience to be sure that they are getting the maximum possible level of privacy.
--- net/ipv6/addrconf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
net/ipv6/addrconf.c +13 -5
@@ -1407,15 +1407,23 @@ static int ipv6_create_tempaddr(struct inet6_ifaddr *ifp, bool block)write_unlock_bh (&idev->lock); -/* A temporary address is created only if this calculated Preferred -* Lifetime is greater than REGEN_ADVANCE time units. In particular, -* an implementation must not create a temporary address with a zero -* Preferred Lifetime. +/* From RFC 4941: +* +* A temporary address is created only if this calculated Preferred +* Lifetime is greater than REGEN_ADVANCE time units. In +* particular, an implementation must not create a temporary address +* with a zero Preferred Lifetime. +* +* Clamp the preferred lifetime to a minimum of regen_advance, unless +* that would exceed valid_lft. +* * Use age calculation as in addrconf_verify to avoid unnecessary * temporary addresses being generated. */ age = (now - tmp_tstamp +ADDRCONF_TIMER_FUZZ_MINUS ) /HZ ; -if (cfg.preferred_lft <= regen_advance + age) { +if (cfg.preferred_lft <= regen_advance + age) + cfg.preferred_lft = regen_advance + age +1 ; +if (cfg.preferred_lft > cfg.valid_lft) {in6_ifa_put (ifp);in6_dev_put (idev); ret =-1 ;
Signature · 1 line
2.42.0
Re: [PATCH net-next v2 2/4] net: ipv6/addrconf: clamp preferred_lft to the minimum required
Quoted 28 lines · Tue, Oct 24, 2023 at 11:23:08PM CEST, [email protected] wrote:
If the preferred lifetime was less than the minimum required lifetime,
ipv6_create_tempaddrwould error out without creating any new address. On my machine and network, this error happened immediately with the preferred lifetime set to 1 second, after a few minutes with the preferred lifetime set to 4 seconds, and not at all with the preferred lifetime set to 5 seconds. During my investigation, I found a Stack Exchange post from another person who seems to have had the same
problem: They stopped getting new addresses if they lowered the preferred lifetime below 3 seconds, and they didn't really know why.The preferred lifetime is a preference, not a hard requirement. The kernel does not strictly forbid new connections on a deprecated address, nor does it guarantee that the address will be disposed of the instant its total valid lifetime expires. So rather than disable IPv6 privacy extensions altogether if the minimum required lifetime swells above the preferred lifetime, it is more in keeping with the user's intent to increase the temporary address's lifetime to the minimum necessary for the current network conditions.
With these fixes, setting the preferred lifetime to 3 or 4 seconds "just works" because the extra fraction of a second is practically unnoticeable. It's even possible to reduce the time before deprecation to 1 or 2 seconds by also disabling duplicate address detection (setting
/proc/sys/net/ipv6/conf/*/dad_transmitsto 0). I realize that that is a pretty niche use case, but I know at least one person who would gladly sacrifice performance and convenience to be sure that they are getting the maximum possible level of privacy.
Quoted 2 lines
Signed-off-by Alex Henrie <[email protected]>
Again, Fixes tag and send to -net tree?
Re: [PATCH net-next v2 2/4] net: ipv6/addrconf: clamp preferred_lft to the minimum required
In reply to Alex HenrieQuoted 28 lines · Alex Henrie
If the preferred lifetime was less than the minimum required lifetime,
ipv6_create_tempaddrwould error out without creating any new address. On my machine and network, this error happened immediately with the preferred lifetime set to 1 second, after a few minutes with the preferred lifetime set to 4 seconds, and not at all with the preferred lifetime set to 5 seconds. During my investigation, I found a Stack Exchange post from another person who seems to have had the same
problem: They stopped getting new addresses if they lowered the preferred lifetime below 3 seconds, and they didn't really know why.The preferred lifetime is a preference, not a hard requirement. The kernel does not strictly forbid new connections on a deprecated address, nor does it guarantee that the address will be disposed of the instant its total valid lifetime expires. So rather than disable IPv6 privacy extensions altogether if the minimum required lifetime swells above the preferred lifetime, it is more in keeping with the user's intent to increase the temporary address's lifetime to the minimum necessary for the current network conditions.
With these fixes, setting the preferred lifetime to 3 or 4 seconds "just works" because the extra fraction of a second is practically unnoticeable. It's even possible to reduce the time before deprecation to 1 or 2 seconds by also disabling duplicate address detection (setting
/proc/sys/net/ipv6/conf/*/dad_transmitsto 0). I realize that that is a pretty niche use case, but I know at least one person who would gladly sacrifice performance and convenience to be sure that they are getting the maximum possible level of privacy.
Quoted 6 lines
Signed-off-by Alex Henrie <[email protected]>--- net/ipv6/addrconf.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
PATCH v2 3/4 Documentation: networking: explain what happens if temp_valid_lft is too small
In reply to Alex Henrie--- Documentation/networking/ip-sysctl.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.rst +3 -1
@@ -2502,7 +2502,9 @@ use_tempaddr - INTEGER * -1 (for point-to-point devices and loopback devices) temp_valid_lft - INTEGER - valid lifetime (in seconds) for temporary addresses. + valid lifetime (in seconds) for temporary addresses. If less than the + minimum required lifetime (typically 5 seconds), temporary addresses + will not be created. Default: 172800 (2 days)
Signature · 1 line
2.42.0
Re: [PATCH net-next v2 3/4] Documentation: networking: explain what happens if temp_valid_lft is too small
Quoted 5 lines · Alex Henrie
Signed-off-by Alex Henrie <[email protected]>--- Documentation/networking/ip-sysctl.rst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
PATCH v2 4/4 Documentation: networking: explain what happens if temp_prefered_lft is too small or too large
In reply to Alex Henrie--- Documentation/networking/ip-sysctl.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Documentation/networking/ip-sysctl.rst +5 -1
@@ -2509,7 +2509,11 @@ temp_valid_lft - INTEGER Default: 172800 (2 days) temp_prefered_lft - INTEGER - Preferred lifetime (in seconds) for temporary addresses. + Preferred lifetime (in seconds) for temporary addresses. If + temp_prefered_lft is less than the minimum required lifetime (typically + 5 seconds), the preferred lifetime is the minimum required. If + temp_prefered_lft is greater than temp_valid_lft, the preferred lifetime + is temp_valid_lft. Default: 86400 (1 day)
Signature · 1 line
2.42.0
Re: [PATCH net-next v2 4/4] Documentation: networking: explain what happens if temp_prefered_lft is too small or too large
Quoted 5 lines · Alex Henrie
Signed-off-by Alex Henrie <[email protected]>--- Documentation/networking/ip-sysctl.rst | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This series was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 13 lines · On Tue, 24 Oct 2023 15:23:06 -0600 you wrote:
No changes from v2, but there are only four patches now because the first patch has already been applied.
https://lore.kernel.org/all/[email protected]/
Alex Henrie (4):
net: ipv6/addrconf: clamppreferred_lftto the maximum allowed
net: ipv6/addrconf: clamppreferred_lftto the minimum required
Documentation: networking: explain what happens iftemp_valid_lftis
too small
Documentation: networking: explain what happens iftemp_prefered_lft
is too small or too large
Quoted 1 line
[...]
Here is the summary with links:
- [net-next,v2,1/4] net: ipv6/addrconf: clamp preferred_lft to the maximum allowed
https://git.kernel.org/netdev/net-next/c/bfbf81b31093 - [net-next,v2,2/4] net: ipv6/addrconf: clamp preferred_lft to the minimum required https://git.kernel.org/netdev/net-next/c/629df6701c8a - [net-next,v2,3/4] Documentation: networking: explain what happens if temp_valid_lft is too small https://git.kernel.org/netdev/net-next/c/433d6c8048cb - [net-next,v2,4/4] Documentation: networking: explain what happens if temp_prefered_lft is too small or too large https://git.kernel.org/netdev/net-next/c/ec575f885e3e
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html