Netdev List
 help / color / mirror / Atom feed
* [PATCH net] tipc: compute the rekeying delay without wrapping
@ 2026-11-24 13:32 Kyuwon Cho
  2026-11-26  7:44 ` Tung Quang Nguyen
  2026-11-30  3:50 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Kyuwon Cho @ 2026-11-24 13:32 UTC (permalink / raw)
  To: Jon Maloy, Tung Quang Nguyen
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, Tuong Lien, netdev,
	tipc-discussion

tipc_crypto_rekeying_sched() converts the rekeying interval, given in
minutes, to milliseconds in 32 bits:

	delay = (now) ? 0 : tx->rekeying_intv * 60 * 1000;

TIPC_NLA_NODE_REKEYING accepts any u32, so intervals of 71583 minutes
and more wrap. An interval of 134217728 minutes gives a delay of 0. The
TX rekeying work then requeues itself without delay, and while its new
key waits for a peer to take it, each run goes straight back to the
requeue: a kworker spins until the key is flushed or the interval is
changed.

Compute the delay in jiffies in 64 bits and cap it at MAX_JIFFY_OFFSET,
the largest delay msecs_to_jiffies() returns.

Fixes: 23700da29b83 ("tipc: add automatic rekeying for encryption key")
Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
---
The issue was found by an LLM-guided test generator that we are
developing as a research prototype. A reproducer, which runs as any
user with iproute2's tipc tool:

$ unshare -Urn sh -e <<'END'
tipc node set identity 1111111111111111
tipc node set key this_is_a_master_key master
tipc node set key rekeying 134217728
sleep 3
END

Without the patch, a kworker keeps one CPU busy until the namespace
goes away (about 300 ticks of system time in three seconds on a 2-CPU
VM, against 2 before the last command); with it, the system time stays
at the idle level.

The patch was written with LLM assistance; we reviewed and tested it.

 net/tipc/crypto.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c
index 4409bdb70fe9..ef08524ce2ca 100644
--- a/net/tipc/crypto.c
+++ b/net/tipc/crypto.c
@@ -2417,8 +2417,9 @@ void tipc_crypto_rekeying_sched(struct tipc_crypto *tx, bool changed,
 	}
 
 	if (tx->rekeying_intv || now) {
-		delay = (now) ? 0 : tx->rekeying_intv * 60 * 1000;
-		queue_delayed_work(tx->wq, &tx->work, msecs_to_jiffies(delay));
+		delay = now ? 0 : min_t(u64, (u64)tx->rekeying_intv * 60 * HZ,
+					MAX_JIFFY_OFFSET);
+		queue_delayed_work(tx->wq, &tx->work, delay);
 	}
 }
 
-- 
2.43.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [PATCH net] tipc: compute the rekeying delay without wrapping
  2026-11-24 13:32 [PATCH net] tipc: compute the rekeying delay without wrapping Kyuwon Cho
@ 2026-11-26  7:44 ` Tung Quang Nguyen
  2026-11-30  3:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Tung Quang Nguyen @ 2026-11-26  7:44 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Willem de Bruijn, Simon Horman, netdev@vger.kernel.org,
	tipc-discussion@lists.sourceforge.net, Jon Maloy

>Subject: [PATCH net] tipc: compute the rekeying delay without wrapping
>
>tipc_crypto_rekeying_sched() converts the rekeying interval, given in minutes,
>to milliseconds in 32 bits:
>
>	delay = (now) ? 0 : tx->rekeying_intv * 60 * 1000;
>
>TIPC_NLA_NODE_REKEYING accepts any u32, so intervals of 71583 minutes
>and more wrap. An interval of 134217728 minutes gives a delay of 0. The TX
>rekeying work then requeues itself without delay, and while its new key waits
>for a peer to take it, each run goes straight back to the
>requeue: a kworker spins until the key is flushed or the interval is changed.
>
>Compute the delay in jiffies in 64 bits and cap it at MAX_JIFFY_OFFSET, the
>largest delay msecs_to_jiffies() returns.
>
>Fixes: 23700da29b83 ("tipc: add automatic rekeying for encryption key")
>Signed-off-by: Kyuwon Cho <kyuwoncho18@gmail.com>
>---
>The issue was found by an LLM-guided test generator that we are developing
>as a research prototype. A reproducer, which runs as any user with iproute2's
>tipc tool:
>
>$ unshare -Urn sh -e <<'END'
>tipc node set identity 1111111111111111
>tipc node set key this_is_a_master_key master tipc node set key rekeying
>134217728 sleep 3 END
>
>Without the patch, a kworker keeps one CPU busy until the namespace goes
>away (about 300 ticks of system time in three seconds on a 2-CPU VM, against
>2 before the last command); with it, the system time stays at the idle level.
>
>The patch was written with LLM assistance; we reviewed and tested it.
>
> net/tipc/crypto.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
>diff --git a/net/tipc/crypto.c b/net/tipc/crypto.c index
>4409bdb70fe9..ef08524ce2ca 100644
>--- a/net/tipc/crypto.c
>+++ b/net/tipc/crypto.c
>@@ -2417,8 +2417,9 @@ void tipc_crypto_rekeying_sched(struct tipc_crypto
>*tx, bool changed,
> 	}
>
> 	if (tx->rekeying_intv || now) {
>-		delay = (now) ? 0 : tx->rekeying_intv * 60 * 1000;
>-		queue_delayed_work(tx->wq, &tx->work,
>msecs_to_jiffies(delay));
>+		delay = now ? 0 : min_t(u64, (u64)tx->rekeying_intv * 60 * HZ,
>+					MAX_JIFFY_OFFSET);
>+		queue_delayed_work(tx->wq, &tx->work, delay);
> 	}
> }
>
>--
>2.43.0

Reviewed-by: Tung Nguyen <tung.quang.nguyen@est.tech>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH net] tipc: compute the rekeying delay without wrapping
  2026-11-24 13:32 [PATCH net] tipc: compute the rekeying delay without wrapping Kyuwon Cho
  2026-11-26  7:44 ` Tung Quang Nguyen
@ 2026-11-30  3:50 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-11-30  3:50 UTC (permalink / raw)
  To: Kyuwon Cho
  Cc: jmaloy, tung.quang.nguyen, davem, edumazet, kuba, pabeni, willemb,
	horms, tuong.t.lien, netdev, tipc-discussion

Hello:

This patch was applied to netdev/net.git (main)
by Willem de Bruijn <willemb@google.com>:

On Tue, 24 Nov 2026 22:32:16 +0900 you wrote:
> tipc_crypto_rekeying_sched() converts the rekeying interval, given in
> minutes, to milliseconds in 32 bits:
> 
> 	delay = (now) ? 0 : tx->rekeying_intv * 60 * 1000;
> 
> TIPC_NLA_NODE_REKEYING accepts any u32, so intervals of 71583 minutes
> and more wrap. An interval of 134217728 minutes gives a delay of 0. The
> TX rekeying work then requeues itself without delay, and while its new
> key waits for a peer to take it, each run goes straight back to the
> requeue: a kworker spins until the key is flushed or the interval is
> changed.
> 
> [...]

Here is the summary with links:
  - [net] tipc: compute the rekeying delay without wrapping
    https://git.kernel.org/netdev/net/c/e2fb9368a416

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-30  3:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-24 13:32 [PATCH net] tipc: compute the rekeying delay without wrapping Kyuwon Cho
2026-11-26  7:44 ` Tung Quang Nguyen
2026-11-30  3:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox