mirror-linux/arch/um/drivers
Kees Cook d93b6a8a34 um: virt-pci: Avoid GCC non-NULL warning
commit bdc77507fe upstream.

GCC gets confused about the return value of get_cpu_var() possibly
being NULL, so explicitly test for it before calls to memcpy() and
memset(). Avoids warnings like this:

   arch/um/drivers/virt-pci.c: In function 'um_pci_send_cmd':
   include/linux/fortify-string.h:48:33: warning: argument 1 null where non-null expected [-Wnonnull]
      48 | #define __underlying_memcpy     __builtin_memcpy
         |                                 ^
   include/linux/fortify-string.h:438:9: note: in expansion of macro '__underlying_memcpy'
     438 |         __underlying_##op(p, q, __fortify_size);                        \
         |         ^~~~~~~~~~~~~
   include/linux/fortify-string.h:483:26: note: in expansion of macro '__fortify_memcpy_chk'
     483 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
         |                          ^~~~~~~~~~~~~~~~~~~~
   arch/um/drivers/virt-pci.c💯9: note: in expansion of macro 'memcpy'
     100 |         memcpy(buf, cmd, cmd_size);
         |         ^~~~~~

While at it, avoid literal "8" and use stored sizeof(buf->data) in
memset() and um_pci_send_cmd().

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202211271212.SUZSC9f9-lkp@intel.com
Fixes: ba38961a06 ("um: Enable FORTIFY_SOURCE")
Cc: Richard Weinberger <richard@nod.at>
Cc: Anton Ivanov <anton.ivanov@cambridgegreys.com>
Cc: Johannes Berg <johannes@sipsolutions.net>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Cc: Xiu Jianfeng <xiujianfeng@huawei.com>
Cc: Vincent Whitchurch <vincent.whitchurch@axis.com>
Cc: linux-um@lists.infradead.org
Cc: stable@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-01-07 11:11:52 +01:00
..
Kconfig um/drivers: Kconfig: Fix indentation 2022-07-17 23:12:46 +02:00
Makefile um: xterm: Make default terminal emulator configurable 2022-05-27 08:50:07 +02:00
chan.h um: remove unused reactivate_chan() declaration 2022-09-19 23:02:21 +02:00
chan_kern.c um: line: Use separate IRQs per line 2022-05-27 09:03:41 +02:00
chan_user.c um: chan_user: Fix winch_tramp() return value 2022-05-27 09:03:41 +02:00
chan_user.h
cow.h treewide: remove editor modelines and cruft 2021-05-07 00:26:34 -07:00
cow_sys.h
cow_user.c
daemon.h
daemon_kern.c um: daemon: Make default socket configurable 2022-05-27 09:00:40 +02:00
daemon_user.c um: Some fixes to build UML with musl 2020-10-11 23:13:06 +02:00
fd.c
harddog_kern.c
harddog_user.c
hostaudio_kern.c um: Remove unneeded variable 'ret' 2021-04-15 23:10:33 +02:00
line.c um: line: Use separate IRQs per line 2022-05-27 09:03:41 +02:00
line.h um: line: Use separate IRQs per line 2022-05-27 09:03:41 +02:00
mconsole.h
mconsole_kern.c um: Do not initialise statics to 0. 2022-09-19 23:10:07 +02:00
mconsole_kern.h
mconsole_user.c
mmapper_kern.c um: mmaper: add __exit annotations to module exit funcs 2022-09-19 23:01:50 +02:00
net_kern.c um: move from strlcpy with unused retval to strscpy 2022-09-19 22:45:24 +02:00
net_user.c
null.c
pcap_kern.c
pcap_user.c um: Some fixes to build UML with musl 2020-10-11 23:13:06 +02:00
pcap_user.h
port.h
port_kern.c um: Support dynamic IRQ allocation 2020-12-13 22:22:08 +01:00
port_user.c um: port_user: Improve error handling when port-helper is not found 2022-03-11 10:55:55 +01:00
pty.c
random.c um: random: Don't initialise hwrng struct with zero 2022-07-17 23:34:09 +02:00
rtc.h um: add a pseudo RTC 2021-02-12 21:38:52 +01:00
rtc_kern.c um: add a pseudo RTC 2021-02-12 21:38:52 +01:00
rtc_user.c isystem: trim/fixup stdarg.h and other headers 2021-08-19 09:02:55 +09:00
slip.h
slip_common.c
slip_common.h
slip_kern.c
slip_user.c um: fix error return code in slip_open() 2021-06-17 22:10:05 +02:00
slirp.h
slirp_kern.c
slirp_user.c
ssl.c um: Do not initialise statics to 0. 2022-09-19 23:10:07 +02:00
stderr_console.c
stdio_console.c um: Do not initialise statics to 0. 2022-09-19 23:10:07 +02:00
stdio_console.h
tty.c
ubd.h
ubd_kern.c um: Do not initialise statics to 0. 2022-09-19 23:10:07 +02:00
ubd_user.c
umcast.h
umcast_kern.c
umcast_user.c
vde.h
vde_kern.c
vde_user.c
vector_kern.c um: move from strlcpy with unused retval to strscpy 2022-09-19 22:45:24 +02:00
vector_kern.h um: Migrate vector drivers to NAPI 2022-03-11 10:45:21 +01:00
vector_transports.c
vector_user.c uml: net: vector: fix const issue 2022-03-11 10:47:05 +01:00
vector_user.h uml: net: vector: fix const issue 2022-03-11 10:47:05 +01:00
vhost_user.h
virt-pci.c um: virt-pci: Avoid GCC non-NULL warning 2023-01-07 11:11:52 +01:00
virtio_uml.c um: read multiple msg from virtio slave request fd 2022-09-19 22:28:25 +02:00
xterm.c um: xterm: Make default terminal emulator configurable 2022-05-27 08:50:07 +02:00
xterm.h
xterm_kern.c um: Support dynamic IRQ allocation 2020-12-13 22:22:08 +01:00