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