Skip to contentSkip to conversation

netfilter: nf_conncount: fix wrong variable type

PATCH Superseded Yunjian Wang 2 participants 6 messages May 29, 2024 – May 30, 2024

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 netfilter: nf_conncount: fix wrong variable type

'keylen' is supposed to be unsigned int, not u8, so fix it.

Fixes 2ba39118c10a ("netfilter: nf_conncount: Move locking into count_tree()")
Fixes c80f10bc973a ("netfilter: nf_conncount: speculative garbage collection on empty lists")
---
 net/netfilter/nf_conncount.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
net/netfilter/nf_conncount.c +2 -2
index 8715617b02fe..4554f4b093fa 100644
@@ -321,7 +321,7 @@ insert_tree(struct net *net,
 	struct nf_conncount_rb *rbconn;
 	struct nf_conncount_tuple *conn;
 	unsigned int count = 0, gc_count = 0;
-	u8 keylen = data->keylen;
+	unsigned int keylen = data->keylen;
 	bool do_gc = true;
 
 	spin_lock_bh(&nf_conncount_locks[hash]);
@@ -403,7 +403,7 @@ count_tree(struct net *net,
 	struct rb_node *parent;
 	struct nf_conncount_rb *rbconn;
 	unsigned int hash;
-	u8 keylen = data->keylen;
+	unsigned int keylen = data->keylen;
 
 	hash = jhash2(key, data->keylen, conncount_rnd) % CONNCOUNT_SLOTS;
 	root = &data->root[hash];
Signature · 1 line
2.33.0
maintainer
#1 lore raw
Quoted 1 line · Yunjian Wang

'keylen' is supposed to be unsigned int, not u8, so fix it.

Its limited to 5, so u8 works fine.

#2 lore raw
Quoted 9 lines

-----Original Message-----
From: Florian Westphal [mailto:[email protected]]
Sent: Wednesday, May 29, 2024 8:03 PM
To: wangyunjian <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; xudingke <[email protected]>
Subject: Re: [PATCH net] netfilter: nf_conncount: fix wrong variable type

Quoted 4 lines
Quoted 1 line · Yunjian Wang

'keylen' is supposed to be unsigned int, not u8, so fix it.

Its limited to 5, so u8 works fine.

Currently, it does not affect the functionality. The main issue is that code checks will report a warning: implicit narrowing conversion from type 'unsigned int' to small type 'u8'.

maintainer
#3 lore raw
Quoted 9 lines · wangyunjian
Quoted 9 lines

-----Original Message-----
From: Florian Westphal [mailto:[email protected]]
Sent: Wednesday, May 29, 2024 8:03 PM
To: wangyunjian <[email protected]>
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; xudingke <[email protected]>
Subject: Re: [PATCH net] netfilter: nf_conncount: fix wrong variable type

Quoted 8 lines
Quoted 4 lines
Quoted 1 line · Yunjian Wang

'keylen' is supposed to be unsigned int, not u8, so fix it.

Its limited to 5, so u8 works fine.

Currently, it does not affect the functionality. The main issue is that code checks will report a warning: implicit narrowing conversion from type 'unsigned int' to small type 'u8'.

Then please quote the exact warning in the commit message and remove the u8 temporary variable in favor of data->keylen.

#4 lore raw
Quoted 25 lines

-----Original Message-----
From: Florian Westphal [mailto:[email protected]]
Sent: Thursday, May 30, 2024 3:52 PM
To: wangyunjian <[email protected]>
Cc: Florian Westphal <[email protected]>; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; xudingke <[email protected]>
Subject: Re: [PATCH net] netfilter: nf_conncount: fix wrong variable type

Quoted 5 lines · wangyunjian
Quoted 5 lines

-----Original Message-----
From: Florian Westphal [mailto:[email protected]]
Sent: Wednesday, May 29, 2024 8:03 PM
To: wangyunjian <[email protected]>
Cc: [email protected]; [email protected];

[email protected];

Quoted 1 line
Quoted 1 line

[email protected]; [email protected]; [email protected];

xudingke

Quoted 6 lines
Quoted 6 lines

<[email protected]>
Subject: Re: [PATCH net] netfilter: nf_conncount: fix wrong variable type

Quoted 1 line · Yunjian Wang

'keylen' is supposed to be unsigned int, not u8, so fix it.

Quoted 8 lines
Quoted 5 lines
Quoted 1 line

Its limited to 5, so u8 works fine.

Currently, it does not affect the functionality. The main issue is that code checks will report a warning: implicit narrowing conversion from type 'unsigned int' to small type 'u8'.

Then please quote the exact warning in the commit message and remove the u8 temporary variable in favor of data->keylen.

OK, I will update it. This is not a bugfix, only considered for net-next?

Thanks.

maintainer
#5 lore raw
Quoted 4 lines · wangyunjian
Quoted 2 lines

Then please quote the exact warning in the commit message and remove the u8 temporary variable in favor of data->keylen.

OK, I will update it. This is not a bugfix, only considered for net-next?

nf-next, yes.