Skip to contentSkip to conversation

octeontx2: Address some warnings

PATCH Applied Simon Horman 2 participants 4 messages Sep 4, 2024 – Sep 7, 2024

Subsystems (4)
lore
Share & tools
lore

Simon Horman

author reviewer
#0 lore raw

v2 cover octeontx2: Address some warnings

Hi,

This patchset addresses some warnings flagged by Sparse, gcc-14, and clang-18 in files touched by recent patch submissions.

Although these changes do not alter the functionality of the code, by addressing them real problems introduced in future which are flagged by Sparse will stand out more readily.

Compile tested only.

---
Changes in v2:
- Updated cover letter - it incorrectly claimed both patches
addressed issues flagged by Sparse
- Added Tested-by tags from Geetha sowjanya. Thanks!
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Simon Horman (2):
octeontx2-af: Pass string literal as format argument of alloc_workqueue()
octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext()

 drivers/net/ethernet/marvell/octeontx2/af/rvu.c        | 4 ++--
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

base-commit: 54f1a107bd034e8d9052f5642280876090ebe31c

author reviewer
#1 lore raw

PATCH v2 1/2 octeontx2-af: Pass string literal as format argument of alloc_workqueue()

Recently I noticed that both gcc-14 and clang-18 report that passing a non-string literal as the format argument of alloc_workqueue() is potentially insecure.

E.g. clang-18 says:

.../rvu.c:2493:32: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
2493 | mw->mbox_wq = alloc_workqueue(name,
| ^~~~
.../rvu.c:2493:32: note: treat the string as an argument to avoid this

 2493 |         mw->mbox_wq = alloc_workqueue(name,
      |                                       ^
      |                                       "%s",

It is always the case where the contents of name is safe to pass as the format argument. That is, in my understanding, it never contains any format escape sequences.

But, it seems better to be safe than sorry. And, as a bonus, compiler output becomes less verbose by addressing this issue as suggested by clang-18.

Compile tested only by author.

---
 drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/marvell/octeontx2/af/rvu.c +2 -2
index ac7ee3f3598c..1a97fb9032fa 100644
@@ -2479,9 +2479,9 @@ static int rvu_mbox_init(struct rvu *rvu, struct mbox_wq_info *mw,
 		goto free_regions;
 	}
 
-	mw->mbox_wq = alloc_workqueue(name,
+	mw->mbox_wq = alloc_workqueue("%s",
 				      WQ_UNBOUND | WQ_HIGHPRI | WQ_MEM_RECLAIM,
-				      num);
+				      num, name);
 	if (!mw->mbox_wq) {
 		err = -ENOMEM;
 		goto unmap_regions;
Signature · 1 line
2.45.2
author reviewer
#2 lore raw

PATCH v2 2/2 octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext()

In reply to Simon Horman

In otx2_sqe_add_ext() iplen is used to hold a 16-bit big-endian value, but it's type is u16, indicating a host byte order integer.

Address this mismatch by changing the type of iplen to __be16.

Flagged by Sparse as:

.../otx2_txrx.c:699:31: warning: incorrect type in assignment (different base types)
.../otx2_txrx.c:699:31: expected unsigned short [usertype] iplen
.../otx2_txrx.c:699:31: got restricted __be16 [usertype]
.../otx2_txrx.c:701:54: warning: incorrect type in assignment (different base types)
.../otx2_txrx.c:701:54: expected restricted __be16 [usertype] tot_len
.../otx2_txrx.c:701:54: got unsigned short [usertype] iplen
.../otx2_txrx.c:704:60: warning: incorrect type in assignment (different base types)
.../otx2_txrx.c:704:60: expected restricted __be16 [usertype] payload_len
.../otx2_txrx.c:704:60: got unsigned short [usertype] iplen

Introduced in
commit dc1a9bf2c816 ("octeontx2-pf: Add UDP segmentation offload support")

No functional change intended.
Compile tested only by author.

---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c +1 -1
index 3eb85949677a..933e18ba2fb2 100644
@@ -687,7 +687,7 @@ static void otx2_sqe_add_ext(struct otx2_nic *pfvf, struct otx2_snd_queue *sq,
 		} else if (skb_shinfo(skb)->gso_type & SKB_GSO_UDP_L4) {
 			__be16 l3_proto = vlan_get_protocol(skb);
 			struct udphdr *udph = udp_hdr(skb);
-			u16 iplen;
+			__be16 iplen;
 
 			ext->lso_sb = skb_transport_offset(skb) +
 					sizeof(struct udphdr);
Signature · 1 line
2.45.2
#3 lore raw
In reply to Simon Horman
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 10 lines · On Wed, 04 Sep 2024 19:29:35 +0100 you wrote:

Hi,

This patchset addresses some warnings flagged by Sparse, gcc-14, and clang-18 in files touched by recent patch submissions.

Although these changes do not alter the functionality of the code, by addressing them real problems introduced in future which are flagged by Sparse will stand out more readily.

[...]

Here is the summary with links:
- [net-next,v2,1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue()

    https://git.kernel.org/netdev/net-next/c/92218f108f51
  - [net-next,v2,2/2] octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext()
    https://git.kernel.org/netdev/net-next/c/7baa90c616e5

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html