public inbox for llvm@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH net-next v2 0/2] octeontx2: Address some warnings
@ 2024-09-04 18:29 Simon Horman
  2024-09-04 18:29 ` [PATCH net-next v2 1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue() Simon Horman
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Simon Horman @ 2024-09-04 18:29 UTC (permalink / raw)
  To: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
	Hariprasad Kelam, Subbaraya Sundeep
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	netdev, llvm

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/20240903-octeontx2-sparse-v1-0-f190309ecb0a@kernel.org

---
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


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

* [PATCH net-next v2 1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue()
  2024-09-04 18:29 [PATCH net-next v2 0/2] octeontx2: Address some warnings Simon Horman
@ 2024-09-04 18:29 ` Simon Horman
  2024-09-04 18:29 ` [PATCH net-next v2 2/2] octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext() Simon Horman
  2024-09-07  1:30 ` [PATCH net-next v2 0/2] octeontx2: Address some warnings patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-09-04 18:29 UTC (permalink / raw)
  To: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
	Hariprasad Kelam, Subbaraya Sundeep
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	netdev, llvm

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.

Tested-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/net/ethernet/marvell/octeontx2/af/rvu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
index ac7ee3f3598c..1a97fb9032fa 100644
--- a/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
+++ b/drivers/net/ethernet/marvell/octeontx2/af/rvu.c
@@ -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;

-- 
2.45.2


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

* [PATCH net-next v2 2/2] octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext()
  2024-09-04 18:29 [PATCH net-next v2 0/2] octeontx2: Address some warnings Simon Horman
  2024-09-04 18:29 ` [PATCH net-next v2 1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue() Simon Horman
@ 2024-09-04 18:29 ` Simon Horman
  2024-09-07  1:30 ` [PATCH net-next v2 0/2] octeontx2: Address some warnings patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Simon Horman @ 2024-09-04 18:29 UTC (permalink / raw)
  To: Sunil Goutham, Linu Cherian, Geetha sowjanya, Jerin Jacob,
	Hariprasad Kelam, Subbaraya Sundeep
  Cc: David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Nathan Chancellor, Nick Desaulniers, Bill Wendling, Justin Stitt,
	netdev, llvm

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.

Tested-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Simon Horman <horms@kernel.org>
---
 drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
index 3eb85949677a..933e18ba2fb2 100644
--- a/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
+++ b/drivers/net/ethernet/marvell/octeontx2/nic/otx2_txrx.c
@@ -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);

-- 
2.45.2


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

* Re: [PATCH net-next v2 0/2] octeontx2: Address some warnings
  2024-09-04 18:29 [PATCH net-next v2 0/2] octeontx2: Address some warnings Simon Horman
  2024-09-04 18:29 ` [PATCH net-next v2 1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue() Simon Horman
  2024-09-04 18:29 ` [PATCH net-next v2 2/2] octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext() Simon Horman
@ 2024-09-07  1:30 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-07  1:30 UTC (permalink / raw)
  To: Simon Horman
  Cc: sgoutham, lcherian, gakula, jerinj, hkelam, sbhatta, davem,
	edumazet, kuba, pabeni, nathan, ndesaulniers, morbo, justinstitt,
	netdev, llvm

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2024-09-07  1:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-04 18:29 [PATCH net-next v2 0/2] octeontx2: Address some warnings Simon Horman
2024-09-04 18:29 ` [PATCH net-next v2 1/2] octeontx2-af: Pass string literal as format argument of alloc_workqueue() Simon Horman
2024-09-04 18:29 ` [PATCH net-next v2 2/2] octeontx2-pf: Make iplen __be16 in otx2_sqe_add_ext() Simon Horman
2024-09-07  1:30 ` [PATCH net-next v2 0/2] octeontx2: Address some warnings 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