OSDN Git Service

hv_sock: Extract hvs_send_data() helper that takes only header
authorKees Cook <keescook@chromium.org>
Tue, 7 Dec 2021 06:32:17 +0000 (22:32 -0800)
committerJakub Kicinski <kuba@kernel.org>
Wed, 8 Dec 2021 05:49:19 +0000 (21:49 -0800)
commitc0e084e342a8046d06c4172b6ccb4db5d7633156
tree4500af470ff9e3e23b652da6547283f7ffaad70e
parente44aecc709ad3945e152c120693127d468e6487c
hv_sock: Extract hvs_send_data() helper that takes only header

When building under -Warray-bounds, the compiler is especially
conservative when faced with casts from a smaller object to a larger
object. While this has found many real bugs, there are some cases that
are currently false positives (like here). With this as one of the last
few instances of the warning in the kernel before -Warray-bounds can be
enabled globally, rearrange the functions so that there is a header-only
version of hvs_send_data(). Silences this warning:

net/vmw_vsock/hyperv_transport.c: In function 'hvs_shutdown_lock_held.constprop':
net/vmw_vsock/hyperv_transport.c:231:32: warning: array subscript 'struct hvs_send_buf[0]' is partly outside array bounds of 'struct vmpipe_proto_header[1]' [-Warray-bounds]
  231 |         send_buf->hdr.pkt_type = 1;
      |         ~~~~~~~~~~~~~~~~~~~~~~~^~~
net/vmw_vsock/hyperv_transport.c:465:36: note: while referencing 'hdr'
  465 |         struct vmpipe_proto_header hdr;
      |                                    ^~~

This change results in no executable instruction differences.

Signed-off-by: Kees Cook <keescook@chromium.org>
Acked-by: Wei Liu <wei.liu@kernel.org>
Link: https://lore.kernel.org/r/20211207063217.2591451-1-keescook@chromium.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
net/vmw_vsock/hyperv_transport.c