mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-21 08:19:28 +00:00
![Kees Cook](/assets/img/avatar_default.png)
Zero-length arrays are deprecated[1]. Replace struct ipv6_rpl_sr_hdr's "segments" union of 0-length arrays with flexible arrays. Detected with GCC 13, using -fstrict-flex-arrays=3: In function 'rpl_validate_srh', inlined from 'rpl_build_state' at ../net/ipv6/rpl_iptunnel.c:96:7: ../net/ipv6/rpl_iptunnel.c:60:28: warning: array subscript <unknown> is outside array bounds of 'struct in6_addr[0]' [-Warray-bounds=] 60 | if (ipv6_addr_type(&srh->rpl_segaddr[srh->segments_left - 1]) & | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ In file included from ../include/net/rpl.h:12, from ../net/ipv6/rpl_iptunnel.c:13: ../include/uapi/linux/rpl.h: In function 'rpl_build_state': ../include/uapi/linux/rpl.h:40:33: note: while referencing 'addr' 40 | struct in6_addr addr[0]; | ^~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Cc: Hideaki YOSHIFUJI <yoshfuji@linux-ipv6.org> Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: David Ahern <dsahern@kernel.org> Link: https://lore.kernel.org/r/20230105221533.never.711-kees@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
48 lines
864 B
C
48 lines
864 B
C
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
|
/*
|
|
* IPv6 RPL-SR implementation
|
|
*
|
|
* Author:
|
|
* (C) 2020 Alexander Aring <alex.aring@gmail.com>
|
|
*/
|
|
|
|
#ifndef _UAPI_LINUX_RPL_H
|
|
#define _UAPI_LINUX_RPL_H
|
|
|
|
#include <asm/byteorder.h>
|
|
#include <linux/types.h>
|
|
#include <linux/in6.h>
|
|
|
|
/*
|
|
* RPL SR Header
|
|
*/
|
|
struct ipv6_rpl_sr_hdr {
|
|
__u8 nexthdr;
|
|
__u8 hdrlen;
|
|
__u8 type;
|
|
__u8 segments_left;
|
|
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
|
__u32 cmpre:4,
|
|
cmpri:4,
|
|
reserved:4,
|
|
pad:4,
|
|
reserved1:16;
|
|
#elif defined(__BIG_ENDIAN_BITFIELD)
|
|
__u32 cmpri:4,
|
|
cmpre:4,
|
|
pad:4,
|
|
reserved:20;
|
|
#else
|
|
#error "Please fix <asm/byteorder.h>"
|
|
#endif
|
|
|
|
union {
|
|
__DECLARE_FLEX_ARRAY(struct in6_addr, addr);
|
|
__DECLARE_FLEX_ARRAY(__u8, data);
|
|
} segments;
|
|
} __attribute__((packed));
|
|
|
|
#define rpl_segaddr segments.addr
|
|
#define rpl_segdata segments.data
|
|
|
|
#endif
|