diff mbox series

[v1,net,1/1] net: avoid overflow when rose /proc displays timer information.

Message ID Yuk9vq7t7VhmnOXu@electric-eye.fr.zoreil.com (mailing list archive)
State Accepted
Commit df1c941468fca014ad092f76672966bb412c2848
Delegated to: Netdev Maintainers
Headers show
Series [v1,net,1/1] net: avoid overflow when rose /proc displays timer information. | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net
netdev/fixes_present fail Series targets non-next tree, but doesn't contain any Fixes tags
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers warning 2 maintainers not CCed: jreuter@yaina.de ralf@linux-mips.org
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 13 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Francois Romieu Aug. 2, 2022, 3:07 p.m. UTC
rose /proc code does not serialize timer accesses.

Initial report by Bernard F6BVP Pidoux exhibits overflow amounting
to 116 ticks on its HZ=250 system.

Full timer access serialization would imho be overkill as rose /proc
does not enforce consistency between displayed ROSE_STATE_XYZ and
timer values during changes of state.

The patch may also fix similar behavior in ax25 /proc, ax25 ioctl
and netrom /proc as they all exhibit the same timer serialization
policy. This point has not been reported though.

The sole remaining use of ax25_display_timer - ax25 rtt valuation -
may also perform marginally better but I have not analyzed it too
deeply.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Cc: Thomas DL9SAU Osterried <thomas@osterried.de>
Link: https://lore.kernel.org/all/d5e93cc7-a91f-13d3-49a1-b50c11f0f811@free.fr/
---
 net/ax25/ax25_timer.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Bernard, can you formally test and add your "Tested-by:" on this one ?

Comments

F6BVP Aug. 2, 2022, 4:57 p.m. UTC | #1
rose /proc code does not serialize timer accesses.

Initial report by Bernard F6BVP Pidoux exhibits overflow amounting
to 116 ticks on its HZ=250 system.

Full timer access serialization would imho be overkill as rose /proc
does not enforce consistency between displayed ROSE_STATE_XYZ and
timer values during changes of state.

The patch may also fix similar behavior in ax25 /proc, ax25 ioctl
and netrom /proc as they all exhibit the same timer serialization
policy. This point has not been reported though.

The sole remaining use of ax25_display_timer - ax25 rtt valuation -
may also perform marginally better but I have not analyzed it too
deeply.

Signed-off-by: Francois Romieu <romieu@fr.zoreil.com>
Tested-by: Bernard Pidoux <f6bvp@free.fr>
Cc: Thomas DL9SAU Osterried <thomas@osterried.de>
Link: https://lore.kernel.org/all/d5e93cc7-a91f-13d3-49a1-b50c11f0f811@free.fr/
---
  net/ax25/ax25_timer.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)

Bernard, can you formally test and add your "Tested-by:" on this one ?

diff --git a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c
index 85865ebfdfa2..9f7cb0a7c73f 100644
--- a/net/ax25/ax25_timer.c
+++ b/net/ax25/ax25_timer.c
@@ -108,10 +108,12 @@ int ax25_t1timer_running(ax25_cb *ax25)
  
  unsigned long ax25_display_timer(struct timer_list *timer)
  {
+	long delta = timer->expires - jiffies;
+
  	if (!timer_pending(timer))
  		return 0;
  
-	return timer->expires - jiffies;
+	return max(0L, delta);
  }
  
  EXPORT_SYMBOL(ax25_display_timer);
patchwork-bot+netdevbpf@kernel.org Aug. 6, 2022, 2:10 a.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 2 Aug 2022 17:07:42 +0200 you wrote:
> rose /proc code does not serialize timer accesses.
> 
> Initial report by Bernard F6BVP Pidoux exhibits overflow amounting
> to 116 ticks on its HZ=250 system.
> 
> Full timer access serialization would imho be overkill as rose /proc
> does not enforce consistency between displayed ROSE_STATE_XYZ and
> timer values during changes of state.
> 
> [...]

Here is the summary with links:
  - [v1,net,1/1] net: avoid overflow when rose /proc displays timer information.
    https://git.kernel.org/netdev/net/c/df1c941468fc

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/ax25/ax25_timer.c b/net/ax25/ax25_timer.c
index 85865ebfdfa2..9f7cb0a7c73f 100644
--- a/net/ax25/ax25_timer.c
+++ b/net/ax25/ax25_timer.c
@@ -108,10 +108,12 @@  int ax25_t1timer_running(ax25_cb *ax25)
 
 unsigned long ax25_display_timer(struct timer_list *timer)
 {
+	long delta = timer->expires - jiffies;
+
 	if (!timer_pending(timer))
 		return 0;
 
-	return timer->expires - jiffies;
+	return max(0L, delta);
 }
 
 EXPORT_SYMBOL(ax25_display_timer);