mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-10-02 15:18:19 +00:00
0b5dfa35da
Zero-length arrays are deprecated[1]. Replace struct ioam6_trace_hdr's "data" 0-length array with a flexible array. Detected with GCC 13, using -fstrict-flex-arrays=3: net/ipv6/ioam6_iptunnel.c: In function 'ioam6_build_state': net/ipv6/ioam6_iptunnel.c:194:37: warning: array subscript <unknown> is outside array bounds of '__u8[0]' {aka 'unsigned char[]'} [-Warray-bounds=] 194 | tuninfo->traceh.data[trace->remlen * 4] = IPV6_TLV_PADN; | ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~ In file included from include/linux/ioam6.h:11, from net/ipv6/ioam6_iptunnel.c:13: include/uapi/linux/ioam6.h:130:17: note: while referencing 'data' 130 | __u8 data[0]; | ^~~~ [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#zero-length-and-one-element-arrays Signed-off-by: Kees Cook <keescook@chromium.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Reviewed-by: Justin Iurman <justin.iurman@uliege.be> Tested-by: Justin Iurman <justin.iurman@uliege.be> Link: https://lore.kernel.org/r/20230105222115.never.661-kees@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
133 lines
2.3 KiB
C
133 lines
2.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0+ WITH Linux-syscall-note */
|
|
/*
|
|
* IPv6 IOAM implementation
|
|
*
|
|
* Author:
|
|
* Justin Iurman <justin.iurman@uliege.be>
|
|
*/
|
|
|
|
#ifndef _UAPI_LINUX_IOAM6_H
|
|
#define _UAPI_LINUX_IOAM6_H
|
|
|
|
#include <asm/byteorder.h>
|
|
#include <linux/types.h>
|
|
|
|
#define IOAM6_U16_UNAVAILABLE U16_MAX
|
|
#define IOAM6_U32_UNAVAILABLE U32_MAX
|
|
#define IOAM6_U64_UNAVAILABLE U64_MAX
|
|
|
|
#define IOAM6_DEFAULT_ID (IOAM6_U32_UNAVAILABLE >> 8)
|
|
#define IOAM6_DEFAULT_ID_WIDE (IOAM6_U64_UNAVAILABLE >> 8)
|
|
#define IOAM6_DEFAULT_IF_ID IOAM6_U16_UNAVAILABLE
|
|
#define IOAM6_DEFAULT_IF_ID_WIDE IOAM6_U32_UNAVAILABLE
|
|
|
|
/*
|
|
* IPv6 IOAM Option Header
|
|
*/
|
|
struct ioam6_hdr {
|
|
__u8 opt_type;
|
|
__u8 opt_len;
|
|
__u8 :8; /* reserved */
|
|
#define IOAM6_TYPE_PREALLOC 0
|
|
__u8 type;
|
|
} __attribute__((packed));
|
|
|
|
/*
|
|
* IOAM Trace Header
|
|
*/
|
|
struct ioam6_trace_hdr {
|
|
__be16 namespace_id;
|
|
|
|
#if defined(__LITTLE_ENDIAN_BITFIELD)
|
|
|
|
__u8 :1, /* unused */
|
|
:1, /* unused */
|
|
overflow:1,
|
|
nodelen:5;
|
|
|
|
__u8 remlen:7,
|
|
:1; /* unused */
|
|
|
|
union {
|
|
__be32 type_be32;
|
|
|
|
struct {
|
|
__u32 bit7:1,
|
|
bit6:1,
|
|
bit5:1,
|
|
bit4:1,
|
|
bit3:1,
|
|
bit2:1,
|
|
bit1:1,
|
|
bit0:1,
|
|
bit15:1, /* unused */
|
|
bit14:1, /* unused */
|
|
bit13:1, /* unused */
|
|
bit12:1, /* unused */
|
|
bit11:1,
|
|
bit10:1,
|
|
bit9:1,
|
|
bit8:1,
|
|
bit23:1, /* reserved */
|
|
bit22:1,
|
|
bit21:1, /* unused */
|
|
bit20:1, /* unused */
|
|
bit19:1, /* unused */
|
|
bit18:1, /* unused */
|
|
bit17:1, /* unused */
|
|
bit16:1, /* unused */
|
|
:8; /* reserved */
|
|
} type;
|
|
};
|
|
|
|
#elif defined(__BIG_ENDIAN_BITFIELD)
|
|
|
|
__u8 nodelen:5,
|
|
overflow:1,
|
|
:1, /* unused */
|
|
:1; /* unused */
|
|
|
|
__u8 :1, /* unused */
|
|
remlen:7;
|
|
|
|
union {
|
|
__be32 type_be32;
|
|
|
|
struct {
|
|
__u32 bit0:1,
|
|
bit1:1,
|
|
bit2:1,
|
|
bit3:1,
|
|
bit4:1,
|
|
bit5:1,
|
|
bit6:1,
|
|
bit7:1,
|
|
bit8:1,
|
|
bit9:1,
|
|
bit10:1,
|
|
bit11:1,
|
|
bit12:1, /* unused */
|
|
bit13:1, /* unused */
|
|
bit14:1, /* unused */
|
|
bit15:1, /* unused */
|
|
bit16:1, /* unused */
|
|
bit17:1, /* unused */
|
|
bit18:1, /* unused */
|
|
bit19:1, /* unused */
|
|
bit20:1, /* unused */
|
|
bit21:1, /* unused */
|
|
bit22:1,
|
|
bit23:1, /* reserved */
|
|
:8; /* reserved */
|
|
} type;
|
|
};
|
|
|
|
#else
|
|
#error "Please fix <asm/byteorder.h>"
|
|
#endif
|
|
|
|
#define IOAM6_TRACE_DATA_SIZE_MAX 244
|
|
__u8 data[];
|
|
} __attribute__((packed));
|
|
|
|
#endif /* _UAPI_LINUX_IOAM6_H */
|