linux-stable/drivers/s390/cio
Justin Stitt 991a211aa9 s390/cio: replace deprecated strncpy with strscpy
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

We expect both `params` and `id` to be NUL-terminated based on their
usage with format strings:

	format_node_data(iuparams, iunodeid, &lir->incident_node);
	format_node_data(auparams, aunodeid, &lir->attached_node);

	switch (lir->iq.class) {
	case LIR_IQ_CLASS_DEGRADED:
		pr_warn("Link degraded: RS=%02x RSID=%04x IC=%02x "
			"IUPARAMS=%s IUNODEID=%s AUPARAMS=%s AUNODEID=%s\n",
			sei_area->rs, sei_area->rsid, lir->ic, iuparams,
			iunodeid, auparams, aunodeid);

NUL-padding is not required as both `params` and `id` have been memset
to 0:

	memset(params, 0, PARAMS_LEN);
	memset(id, 0, NODEID_LEN);

Considering the above, a suitable replacement is `strscpy` [2] due to
the fact that it guarantees NUL-termination on the destination buffer
without unnecessarily NUL-padding.

Note that there's no overread bugs in the current implementation as the
string literal "n/a" has a size much smaller than PARAMS_LEN or
NODEID_LEN. Nonetheless, let's favor strscpy().

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2]
Link: https://github.com/KSPP/linux/issues/90
Cc: linux-hardening@vger.kernel.org
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231023-strncpy-drivers-s390-cio-chsc-c-v1-1-8b76a7b83260@google.com
Signed-off-by: Vasily Gorbik <gor@linux.ibm.com>
2023-10-25 15:08:30 +02:00
..
airq.c s390/airq: remove lsi_mask from airq_struct 2023-08-30 11:03:28 +02:00
blacklist.c s390/cio: avoid excessive path-verification requests 2021-09-27 13:54:38 +02:00
blacklist.h
ccwgroup.c s390: fix various typos 2023-07-03 11:19:42 +02:00
ccwreq.c
chp.c s390/cio: export CMG value as decimal 2023-10-25 15:08:29 +02:00
chp.h
chsc.c s390/cio: replace deprecated strncpy with strscpy 2023-10-25 15:08:30 +02:00
chsc.h s390/cio: replace zero-length array with flexible-array member 2023-04-13 17:36:29 +02:00
chsc_sch.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
chsc_sch.h
cio.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
cio.h s390/cio: Use driver_set_override() instead of open-coding 2022-04-22 17:13:54 +02:00
cio_debug.h
cio_debugfs.c
cio_inject.c
cio_inject.h
cmf.c s390/cmf: get rid of register asm 2021-06-28 11:18:28 +02:00
crw.c s390: use control register bit defines 2023-09-19 13:26:57 +02:00
css.c Driver core changes for 6.3-rc1 2023-02-24 12:58:55 -08:00
css.h s390/cio: evaluate devices with non-operational paths 2023-01-22 18:42:34 +01:00
device.c s390: fix various typos 2023-07-03 11:19:42 +02:00
device.h
device_fsm.c s390: fix various typos 2023-07-03 11:19:42 +02:00
device_id.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
device_ops.c s390/cio: make ccw_device_dma_* more robust 2021-10-26 15:21:30 +02:00
device_pgid.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
device_status.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
eadm_sch.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
eadm_sch.h
fcx.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
idset.c
idset.h
io_sch.h
ioasm.c s390/extable: move EX_TABLE define to asm-extable.h 2022-03-08 00:33:00 +01:00
ioasm.h
isc.c s390/ctlreg: add local and system prefix to some functions 2023-09-19 13:26:56 +02:00
itcw.c s390/cio: sort out physical vs virtual pointers usage 2022-12-01 10:58:04 +01:00
Makefile
orb.h
qdio.h s390/qdio: fix do_sqbs() inline assembly constraint 2023-05-17 15:20:17 +02:00
qdio_debug.c s390: move from strlcpy with unused retval to strscpy 2022-08-30 22:00:33 +02:00
qdio_debug.h
qdio_main.c s390/qdio: remove unneeded sanity check in qdio_do_sqbs() 2021-12-06 14:42:26 +01:00
qdio_setup.c s390/qdio: clarify handler logic for qdio_handle_activate_check() 2021-12-06 14:42:25 +01:00
qdio_thinint.c s390/airq: pass more TPI info to airq handlers 2022-07-11 09:54:10 +02:00
scm.c driver core: make struct bus_type.uevent() take a const * 2023-01-27 13:45:52 +01:00
trace.c
trace.h s390: use struct tpi_info in lowcore.h 2021-06-07 17:07:01 +02:00
vfio_ccw_async.c vfio/ccw: Remove private->mdev 2022-07-07 14:06:12 -06:00
vfio_ccw_chp.c vfio/ccw: remove private->sch 2022-11-10 11:11:25 -07:00
vfio_ccw_cp.c s390: fix various typos 2023-07-03 11:19:42 +02:00
vfio_ccw_cp.h vfio/ccw: simplify the cp_get_orb interface 2023-01-09 14:34:07 +01:00
vfio_ccw_drv.c vfio/ccw: use struct_size() helper 2023-06-01 17:07:56 +02:00
vfio_ccw_fsm.c vfio/ccw: simplify the cp_get_orb interface 2023-01-09 14:34:07 +01:00
vfio_ccw_ops.c vfio-iommufd: Add detach_ioas support for emulated VFIO devices 2023-07-25 10:19:18 -06:00
vfio_ccw_private.h vfio/ccw: replace one-element array with flexible-array member 2023-06-01 17:07:55 +02:00
vfio_ccw_trace.c
vfio_ccw_trace.h