Skip to content

Replace remaining strlcat() call sites with snprintf()/seq_buf()

Bill Wendling brcm80211 dri-devel intel-wired-lan intel-xe linux-devicetree linux-edac linux-fsdevel linux-gpio linux-hardening linux-input linux-media linux-mips linux-nfs linux-parisc linux-samsung-soc linux-scsi linux-sound linux-wireless lkml loongarch netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest28 patches 20 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/28ALSA: ac97: Refactor snd_ac97_get_name() to use snprintf()sound/pci/ac97/ac97_codec.c+6 -32 replies
2/28sunrpc: Refactor rpc_sockaddr2uaddr() to use snprintf() instead of strlcat()net/sunrpc/addr.c+8 -81 reply
3/28ARM: atags: Replace strlcat() with snprintf() for cmdline extendarch/arm/kernel/atags_parse.c+4 -32 replies
4/28scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init()drivers/scsi/bfa/bfa_fcs.c+7 -240 replies
5/28ALSA: usb-audio: Refactor usb_audio_make_longname() to use seq_bufsound/usb/card.c+39 -190 replies
6/28comedi: comedi_bond: Refactor strlcat() to seq_buf in do_dev_config()drivers/comedi/drivers/comedi_bond.c+7 -90 replies
7/28scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()drivers/scsi/bfa/bfa_fcs.c+13 -360 replies
8/28devlink: Refactor strlcat() to seq_buf in __devlink_compat_running_version()net/devlink/dev.c+6 -20 replies
9/28drm/dp_mst: Refactor build_mst_prop_path() to use seq_bufdrivers/gpu/drm/display/drm_dp_mst_topology.c+9 -61 reply
10/28of/fdt: Replace strlcat() with snprintf() in early_init_dt_scan_chosen()drivers/of/fdt.c+9 -21 reply
11/28wifi: brcmfmac: Replace strlcat() with snprintf() in brcmf_fw_alloc_request()drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c+8 -130 replies
12/28fortify: Convert strlcat() to snprintf() in strcat()include/linux/fortify-string.h+6 -10 replies
13/28i40e: Replace strlcat() with snprintf() in i40e_nvm_version_str()drivers/net/ethernet/intel/i40e/i40e.h+11 -40 replies
14/28ALSA: usb-audio: Refactor append_ctl_name() to use snprintf()sound/usb/mixer.c+6 -20 replies
15/28orangefs: Use seq_buf for debug help string generationfs/orangefs/orangefs-debugfs.c+14 -221 reply
16/28pinctrl: samsung: Use snprintf() to construct pin bank namesdrivers/pinctrl/samsung/pinctrl-samsung.c+1 -21 reply
17/28MIPS: cmdline: Refactor bootcmdline_append() to use snprintf()arch/mips/kernel/setup.c+18 -30 replies
18/28LoongArch: Refactor bootcmdline_init() to use seq_buf instead of strlcat()arch/loongarch/kernel/setup.c+15 -70 replies
19/28x86/setup: Use snprintf() to concatenate builtin and boot command linesarch/x86/kernel/setup.c+5 -30 replies
20/28parisc: Refactor strlcat() to seq_buf in setup_cmdline()arch/parisc/kernel/setup.c+10 -60 replies
21/28NFS: nfsroot: Refactor root_nfs_cat() to use snprintf()fs/nfs/nfsroot.c+7 -42 replies
22/28media: si2165: Use snprintf() to format frontend namedrivers/media/dvb-frontends/si2165.c+7 -101 reply
23/28Input: synaptics_usb - use seq_buf and snprintf() for name and physdrivers/input/mouse/synaptics_usb.c+17 -120 replies
24/28EDAC/thunderx: Fix stale error context in thunderx_l2c_threaded_isr()drivers/edac/thunderx_edac.c+3 -01 reply
25/28EDAC/thunderx: Replace strlcat() with seq_bufdrivers/edac/thunderx_edac.c+39 -253 replies
26/28wifi: wil6210: Refactor resume_triggers2string() to use seq_bufdrivers/net/wireless/ath/wil6210/wmi.c+21 -170 replies
27/28drm/xe/pf: Convert strlcat() to seq_buf in control_read()drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c+5 -41 reply
28/28drm/xe/pf: Refactor strlcat() to seq_buf in sched_group_engines_read()drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c+8 -71 reply

Reviews trailers per patch

5 of 28 patches have a Reviewed-by or Acked-by.

PatchJeff LaytonAleksandr LoktionovLyude Paul
1/28
2/28R-b
3/28
4/28
5/28
6/28
7/28
8/28
9/28R-b
10/28
11/28
12/28
13/28
14/28
15/28
16/28R-b
17/28
18/28
19/28
20/28
21/28
22/28R-b
23/28
24/28R-b
25/28
26/28
27/28
28/28

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/28] Replace remaining strlcat() call sites with snprintf()/seq_buf()

strlcat() is deprecated: like strcat(), it requires re-scanning the destination string from the beginning on every call, which is O(n^2) when used to build up a string incrementally, and its truncation behavior is easy to get wrong. See:

https://github.com/KSPP/linux/issues/370

This series removes the remaining strlcat() call sites in the tree (plus the one inside fortify-string.h's strcat() implementation itself), replacing each with snprintf(), scnprintf(), or the seq_buf() API, whichever best fits the surrounding code.

One unrelated fix is included. While auditing drivers/edac/thunderx_edac.c for its strlcat() conversion, "EDAC/thunderx: Fix stale error context in thunderx_l2c_threaded_isr()" addresses a pre-existing bug, present since the driver's original 2017 commit: thunderx_l2c_threaded_isr() computes its ring "tail"/"ctx" once before its drain loop and never recomputes them per iteration, unlike the analogous OCX handlers in the same file, so it re-reports the same ring entry for every queued error instead of draining the ring. It's split out as its own patch, ahead of the strlcat() conversion for that file, so it can be reviewed and backported independently of the rest of this series.

Bill Wendling (28):
ALSA: ac97: Refactor snd_ac97_get_name() to use snprintf()
sunrpc: Refactor rpc_sockaddr2uaddr() to use snprintf() instead of
strlcat()
ARM: atags: Replace strlcat() with snprintf() for cmdline extend
scsi: bfa: Use snprintf() in bfa_fcs_fabric_nsymb_init()
ALSA: usb-audio: Refactor usb_audio_make_longname() to use seq_buf
comedi: comedi_bond: Refactor strlcat() to seq_buf in do_dev_config()
scsi: bfa: Use snprintf() in bfa_fcs_fabric_psymb_init()
devlink: Refactor strlcat() to seq_buf in
__devlink_compat_running_version()
drm/dp_mst: Refactor build_mst_prop_path() to use seq_buf of/fdt: Replace strlcat() with snprintf() in
early_init_dt_scan_chosen()
wifi: brcmfmac: Replace strlcat() with snprintf() in
brcmf_fw_alloc_request()
fortify: Convert strlcat() to snprintf() in strcat()
i40e: Replace strlcat() with snprintf() in i40e_nvm_version_str()
ALSA: usb-audio: Refactor append_ctl_name() to use snprintf()
orangefs: Use seq_buf for debug help string generation
pinctrl: samsung: Use snprintf() to construct pin bank names
MIPS: cmdline: Refactor bootcmdline_append() to use snprintf()
LoongArch: Refactor bootcmdline_init() to use seq_buf instead of
strlcat()
x86/setup: Use snprintf() to concatenate builtin and boot command
lines
parisc: Refactor strlcat() to seq_buf in setup_cmdline()
NFS: nfsroot: Refactor root_nfs_cat() to use snprintf()
media: si2165: Use snprintf() to format frontend name
Input: synaptics_usb - use seq_buf and snprintf() for name and phys EDAC/thunderx: Fix stale error context in thunderx_l2c_threaded_isr() EDAC/thunderx: Replace strlcat() with seq_buf
wifi: wil6210: Refactor resume_triggers2string() to use seq_buf drm/xe/pf: Convert strlcat() to seq_buf in control_read() drm/xe/pf: Refactor strlcat() to seq_buf in sched_group_engines_read()

 arch/arm/kernel/atags_parse.c                 |  7 +-
 arch/loongarch/kernel/setup.c                 | 22 +++--
 arch/mips/kernel/setup.c                      | 21 ++++-
 arch/parisc/kernel/setup.c                    | 16 ++--
 arch/x86/kernel/setup.c                       |  8 +-
 drivers/comedi/drivers/comedi_bond.c          | 16 ++--
 drivers/edac/thunderx_edac.c                  | 67 ++++++++++------
 drivers/gpu/drm/display/drm_dp_mst_topology.c | 15 ++--
 drivers/gpu/drm/xe/xe_gt_sriov_pf_debugfs.c   | 24 +++---
 drivers/input/mouse/synaptics_usb.c           | 29 ++++---
 drivers/media/dvb-frontends/si2165.c          | 17 ++--
 drivers/net/ethernet/intel/i40e/i40e.h        | 15 +++-
 drivers/net/wireless/ath/wil6210/wmi.c        | 38 +++++----
 .../broadcom/brcm80211/brcmfmac/firmware.c    | 21 ++---
 drivers/of/fdt.c                              | 11 ++-
 drivers/pinctrl/samsung/pinctrl-samsung.c     |  3 +-
 drivers/scsi/bfa/bfa_fcs.c                    | 80 +++++--------------
 fs/nfs/nfsroot.c                              | 11 ++-
 fs/orangefs/orangefs-debugfs.c                | 36 ++++-----
 include/linux/fortify-string.h                |  7 +-
 net/devlink/dev.c                             |  8 +-
 net/sunrpc/addr.c                             | 16 ++--
 sound/pci/ac97/ac97_codec.c                   |  9 ++-
 sound/usb/card.c                              | 58 +++++++++-----
 sound/usb/mixer.c                             |  8 +-
 25 files changed, 309 insertions(+), 254 deletions(-)

---
Cc: Russell King <[email protected]>
Cc: Huacai Chen <[email protected]>
Cc: WANG Xuerui <[email protected]>
Cc: Thomas Bogendoerfer <[email protected]>
Cc: "James E.J. Bottomley" <[email protected]>
Cc: Helge Deller <[email protected]>
Cc: Thomas Gleixner <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Borislav Petkov <[email protected]>
Cc: Dave Hansen <[email protected]>
Cc: [email protected]
Cc: "H. Peter Anvin" <[email protected]>
Cc: Ian Abbott <[email protected]>
Cc: H Hartley Sweeten <[email protected]>
Cc: Tony Luck <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: Thomas Zimmermann <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: Matthew Brost <[email protected]>
Cc: "Thomas Hellström" <[email protected]>
Cc: Rodrigo Vivi <[email protected]>
Cc: Dmitry Torokhov <[email protected]>
Cc: Matthias Schwarzott <[email protected]>
Cc: Mauro Carvalho Chehab <[email protected]>
Cc: Tony Nguyen <[email protected]>
Cc: Przemek Kitszel <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>
Cc: Arend van Spriel <[email protected]>
Cc: Rob Herring <[email protected]>
Cc: Saravana Kannan <[email protected]>
Cc: Krzysztof Kozlowski <[email protected]>
Cc: Sylwester Nawrocki <[email protected]>
Cc: Peter Griffin <[email protected]>
Cc: Alim Akhtar <[email protected]>
Cc: Linus Walleij <[email protected]>
Cc: Anil Gurumurthy <[email protected]>
Cc: Sudarsana Kalluru <[email protected]>
Cc: "Martin K. Petersen" <[email protected]>
Cc: Trond Myklebust <[email protected]>
Cc: Anna Schumaker <[email protected]>
Cc: Mike Marshall <[email protected]>
Cc: Martin Brandenburg <[email protected]>
Cc: Kees Cook <[email protected]>
Cc: Jiri Pirko <[email protected]>
Cc: Simon Horman <[email protected]>
Cc: Chuck Lever <[email protected]>
Cc: Jeff Layton <[email protected]>
Cc: NeilBrown <[email protected]>
Cc: Olga Kornievskaia <[email protected]>
Cc: Dai Ngo <[email protected]>
Cc: Tom Talpey <[email protected]>
Cc: Jaroslav Kysela <[email protected]>
Cc: Takashi Iwai <[email protected]>
Cc: Bill Wendling <[email protected]>
Cc: Andrew Morton <[email protected]>
Cc: "Mike Rapoport (Microsoft)" <[email protected]>
Cc: Kanglong Wang <[email protected]>
Cc: Tiezhu Yang <[email protected]>
Cc: Qiang Ma <[email protected]>
Cc: Randy Dunlap <[email protected]>
Cc: Pengpeng Hou <[email protected]>
Cc: Ard Biesheuvel <[email protected]>
Cc: Breno Leitao <[email protected]>
Cc: Thorsten Blum <[email protected]>
Cc: Harshit Mogalapalli <[email protected]>
Cc: Greg Kroah-Hartman <[email protected]>
Cc: Lyude Paul <[email protected]>
Cc: Ashutosh Desai <[email protected]>
Cc: Imre Deak <[email protected]>
Cc: Dmitry Baryshkov <[email protected]>
Cc: Johan Hovold <[email protected]>
Cc: Johannes Berg <[email protected]>
Cc: Miri Korenblit <[email protected]>
Cc: Alexander Stein <[email protected]>
Cc: Cryolitia PukNgae <[email protected]>
Cc: Jiaming Zhang <[email protected]>
Cc: Will Porter <[email protected]>
Cc: Cen Zhang <[email protected]>
Cc: "Cássio Gabriel" <[email protected]>
Cc: Rong Zhang <[email protected]>
Cc: Arun Raghavan <[email protected]>
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]

Signature · 1 line
2.47.3