Skip to content

Manual replacement of all strlcpy in favor of strscpy

Romain Perier alsa-devel cgroups dri-devel kernel-hardening linux-crypto linux-hwmon linux-integrity linux-m68k linux-media linux-nfs linux-s390 linux-scsi linux-usb linux-watchdog lkml netdev oe-kbuild-all target-devel 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest20 patches 24 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/20cgroup: Manual replacement of the deprecated strlcpy() with return valueskernel/cgroup/cgroup.c+1 -12 replies
2/20crypto: Manual replacement of the deprecated strlcpy() with return valuescrypto/lrw.c crypto/xts.c+6 -62 replies
3/20devlink: Manual replacement of the deprecated strlcpy() with return valuesnet/core/devlink.c+3 -31 reply
4/20dma-buf: Manual replacement of the deprecated strlcpy() with return valuesdrivers/dma-buf/dma-buf.c+2 -20 replies
5/20kobject: Manual replacement of the deprecated strlcpy() with return valueslib/kobject_uevent.c+3 -30 replies
6/20ima: Manual replacement of the deprecated strlcpy() with return valuessecurity/integrity/ima/ima_policy.c+7 -11 reply
7/20SUNRPC: Manual replacement of the deprecated strlcpy() with return valuesnet/sunrpc/clnt.c+5 -12 replies
8/20kernfs: Manual replacement of the deprecated strlcpy() with return valuesfs/kernfs/dir.c+14 -130 replies
9/20m68k/atari: Manual replacement of the deprecated strlcpy() with return valuesarch/m68k/emu/natfeat.c+3 -30 replies
10/20module: Manual replacement of the deprecated strlcpy() with return valueskernel/module.c+3 -10 replies
11/20hwmon: Manual replacement of the deprecated strlcpy() with return valuesdrivers/hwmon/pmbus/max20730.c+35 -313 replies
12/20s390/hmcdrv: Manual replacement of the deprecated strlcpy() with return valuesdrivers/s390/char/diag_ftp.c drivers/s390/char/sclp_ftp.c+5 -50 replies
13/20scsi: zfcp: Manual replacement of the deprecated strlcpy() with return valuesdrivers/s390/scsi/zfcp_fc.c+5 -31 reply
14/20target: Manual replacement of the deprecated strlcpy() with return valuesdrivers/target/target_core_configfs.c+9 -241 reply
15/20ALSA: usb-audio: Manual replacement of the deprecated strlcpy() with return valuessound/usb/card.c+1 -11 reply
16/20tracing/probe: Manual replacement of the deprecated strlcpy() with return valueskernel/trace/trace_uprobe.c+5 -62 replies
17/20vt: Manual replacement of the deprecated strlcpy() with return valuesdrivers/tty/vt/keyboard.c+4 -12 replies
18/20usb: gadget: f_midi: Manual replacement of the deprecated strlcpy() with return valuesdrivers/usb/gadget/function/f_midi.c drivers/usb/gadget/function/f_printer.c+6 -60 replies
19/20usbip: usbip_host: Manual replacement of the deprecated strlcpy() with return valuesdrivers/usb/usbip/stub_main.c+3 -33 replies
20/20s390/watchdog: Manual replacement of the deprecated strlcpy() with return valuesdrivers/watchdog/diag288_wdt.c+8 -41 reply

Reviews trailers per patch

2 of 20 patches have a Reviewed-by or Acked-by.

PatchShuah KhanMimi Zohar
1/20
2/20
3/20
4/20
5/20
6/20A-b
7/20
8/20
9/20
10/20
11/20
12/20
13/20
14/20
15/20
16/20
17/20
18/20
19/20A-b
20/20

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 00/20] Manual replacement of all strlcpy in favor of strscpy

strlcpy() copy a C-String into a sized buffer, the result is always a valid NULL-terminated that fits in the buffer, howerver it has severals issues. It reads the source buffer first, which is dangerous if it is non NULL-terminated or if the corresponding buffer is unbounded. Its safe replacement is strscpy(), as suggested in the deprecated interface [1].

We plan to make this contribution in two steps:
- Firsly all cases of strlcpy's return value are manually replaced by the corresponding calls of strscpy() with the new handling of the return value (as the return code is different in case of error).
- Then all other cases are automatically replaced by using coccinelle.

This series covers manual replacements.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#strlcpy

Romain Perier (20):
cgroup: Manual replacement of the deprecated strlcpy() with return
values
crypto: Manual replacement of the deprecated strlcpy() with return
values
devlink: Manual replacement of the deprecated strlcpy() with return
values
dma-buf: Manual replacement of the deprecated strlcpy() with return
values
kobject: Manual replacement of the deprecated strlcpy() with return
values
ima: Manual replacement of the deprecated strlcpy() with return values
SUNRPC: Manual replacement of the deprecated strlcpy() with return
values
kernfs: Manual replacement of the deprecated strlcpy() with return
values
m68k/atari: Manual replacement of the deprecated strlcpy() with return
values
module: Manual replacement of the deprecated strlcpy() with return
values
hwmon: Manual replacement of the deprecated strlcpy() with return
values
s390/hmcdrv: Manual replacement of the deprecated strlcpy() with
return values
scsi: zfcp: Manual replacement of the deprecated strlcpy() with return
values
target: Manual replacement of the deprecated strlcpy() with return
values
ALSA: usb-audio: Manual replacement of the deprecated strlcpy() with
return values
tracing/probe: Manual replacement of the deprecated strlcpy() with
return values
vt: Manual replacement of the deprecated strlcpy() with return values
usb: gadget: f_midi: Manual replacement of the deprecated strlcpy()
with return values
usbip: usbip_host: Manual replacement of the deprecated strlcpy() with
return values
s390/watchdog: Manual replacement of the deprecated strlcpy() with
return values

 arch/m68k/emu/natfeat.c                 |  6 +--
 crypto/lrw.c                            |  6 +--
 crypto/xts.c                            |  6 +--
 drivers/dma-buf/dma-buf.c               |  4 +-
 drivers/hwmon/pmbus/max20730.c          | 66 +++++++++++++------------
 drivers/s390/char/diag_ftp.c            |  4 +-
 drivers/s390/char/sclp_ftp.c            |  6 +--
 drivers/s390/scsi/zfcp_fc.c             |  8 +--
 drivers/target/target_core_configfs.c   | 33 ++++---------
 drivers/tty/vt/keyboard.c               |  5 +-
 drivers/usb/gadget/function/f_midi.c    |  4 +-
 drivers/usb/gadget/function/f_printer.c |  8 +--
 drivers/usb/usbip/stub_main.c           |  6 +--
 drivers/watchdog/diag288_wdt.c          | 12 +++--
 fs/kernfs/dir.c                         | 27 +++++-----
 kernel/cgroup/cgroup.c                  |  2 +-
 kernel/module.c                         |  4 +-
 kernel/trace/trace_uprobe.c             | 11 ++---
 lib/kobject_uevent.c                    |  6 +--
 net/core/devlink.c                      |  6 +--
 net/sunrpc/clnt.c                       |  6 ++-
 security/integrity/ima/ima_policy.c     |  8 ++-
 sound/usb/card.c                        |  4 +-
 23 files changed, 129 insertions(+), 119 deletions(-)
Signature · 1 line
2.20.1