Revert "netfilter: Replace zero-length array with flexible-array member"

This reverts commit 9857e028d4 which is
commit 6daf14140129d30207ed6a0a69851fa6a3636bda upstream.

It breaks the Android kernel abi and can be brought back in the future
in an abi-safe way if it is really needed.

Bug: 161946584
Change-Id: I72ea16907de19ad38a993363ae45bab25f67d57a
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
Greg Kroah-Hartman 2025-01-14 17:17:17 +00:00
parent 196c9546b3
commit b9aba1f4e2
21 changed files with 31 additions and 31 deletions

View file

@ -98,7 +98,7 @@ struct ip_set_counter {
struct ip_set_comment_rcu {
struct rcu_head rcu;
char str[];
char str[0];
};
struct ip_set_comment {

View file

@ -264,7 +264,7 @@ struct xt_table_info {
unsigned int stacksize;
void ***jumpstack;
unsigned char entries[] __aligned(8);
unsigned char entries[0] __aligned(8);
};
int xt_register_target(struct xt_target *target);
@ -464,7 +464,7 @@ struct compat_xt_entry_match {
} kernel;
u_int16_t match_size;
} u;
unsigned char data[];
unsigned char data[0];
};
struct compat_xt_entry_target {
@ -480,7 +480,7 @@ struct compat_xt_entry_target {
} kernel;
u_int16_t target_size;
} u;
unsigned char data[];
unsigned char data[0];
};
/* FIXME: this works only on 32 bit tasks
@ -494,7 +494,7 @@ struct compat_xt_counters {
struct compat_xt_counters_info {
char name[XT_TABLE_MAXNAMELEN];
compat_uint_t num_counters;
struct compat_xt_counters counters[];
struct compat_xt_counters counters[0];
};
struct _compat_xt_align {

View file

@ -68,7 +68,7 @@ struct compat_arpt_entry {
__u16 next_offset;
compat_uint_t comefrom;
struct compat_xt_counters counters;
unsigned char elems[];
unsigned char elems[0];
};
static inline struct xt_entry_target *

View file

@ -85,7 +85,7 @@ struct ebt_table_info {
/* room to maintain the stack used for jumping from and into udc */
struct ebt_chainstack **chainstack;
char *entries;
struct ebt_counter counters[] ____cacheline_aligned;
struct ebt_counter counters[0] ____cacheline_aligned;
};
struct ebt_table {

View file

@ -76,7 +76,7 @@ struct compat_ipt_entry {
__u16 next_offset;
compat_uint_t comefrom;
struct compat_xt_counters counters;
unsigned char elems[];
unsigned char elems[0];
};
/* Helper functions */

View file

@ -43,7 +43,7 @@ struct compat_ip6t_entry {
__u16 next_offset;
compat_uint_t comefrom;
struct compat_xt_counters counters;
unsigned char elems[];
unsigned char elems[0];
};
static inline struct xt_entry_target *

View file

@ -46,7 +46,7 @@ struct nf_ct_ext {
struct rcu_head rcu;
u8 offset[NF_CT_EXT_NUM];
u8 len;
char data[];
char data[0];
};
static inline bool __nf_ct_ext_exist(const struct nf_ct_ext *ext, u8 id)

View file

@ -14,7 +14,7 @@
struct nf_ct_timeout {
__u16 l3num;
const struct nf_conntrack_l4proto *l4proto;
char data[];
char data[0];
};
struct ctnl_timeout {

View file

@ -226,7 +226,7 @@ int nft_parse_register_store(const struct nft_ctx *ctx,
*/
struct nft_userdata {
u8 len;
unsigned char data[];
unsigned char data[0];
};
/**
@ -581,7 +581,7 @@ struct nft_set_ext_tmpl {
struct nft_set_ext {
u8 genmask;
u8 offset[NFT_SET_EXT_NUM];
char data[];
char data[0];
} __aligned(BITS_PER_LONG / 8);
static inline void nft_set_ext_prepare(struct nft_set_ext_tmpl *tmpl)
@ -1360,7 +1360,7 @@ struct nft_trans {
int msg_type;
bool put_net;
struct nft_ctx ctx;
char data[];
char data[0];
};
struct nft_trans_rule {

View file

@ -40,7 +40,7 @@ struct ebt_mac_wormhash_tuple {
struct ebt_mac_wormhash {
int table[257];
int poolsize;
struct ebt_mac_wormhash_tuple pool[];
struct ebt_mac_wormhash_tuple pool[0];
};
#define ebt_mac_wormhash_size(x) ((x) ? sizeof(struct ebt_mac_wormhash) \

View file

@ -1581,7 +1581,7 @@ struct compat_ebt_entry_mwt {
compat_uptr_t ptr;
} u;
compat_uint_t match_size;
compat_uint_t data[] __aligned(__alignof__(struct compat_ebt_replace));
compat_uint_t data[0] __attribute__ ((aligned (__alignof__(struct compat_ebt_replace))));
};
/* account for possible padding between match_size and ->data */

View file

@ -1057,7 +1057,7 @@ struct compat_arpt_replace {
u32 underflow[NF_ARP_NUMHOOKS];
u32 num_counters;
compat_uptr_t counters;
struct compat_arpt_entry entries[];
struct compat_arpt_entry entries[0];
};
static inline void compat_release_entry(struct compat_arpt_entry *e)
@ -1385,7 +1385,7 @@ static int compat_copy_entries_to_user(unsigned int total_size,
struct compat_arpt_get_entries {
char name[XT_TABLE_MAXNAMELEN];
compat_uint_t size;
struct compat_arpt_entry entrytable[];
struct compat_arpt_entry entrytable[0];
};
static int compat_get_entries(struct net *net,

View file

@ -1211,7 +1211,7 @@ struct compat_ipt_replace {
u32 underflow[NF_INET_NUMHOOKS];
u32 num_counters;
compat_uptr_t counters; /* struct xt_counters * */
struct compat_ipt_entry entries[];
struct compat_ipt_entry entries[0];
};
static int
@ -1564,7 +1564,7 @@ compat_do_ipt_set_ctl(struct sock *sk, int cmd, void __user *user,
struct compat_ipt_get_entries {
char name[XT_TABLE_MAXNAMELEN];
compat_uint_t size;
struct compat_ipt_entry entrytable[];
struct compat_ipt_entry entrytable[0];
};
static int

View file

@ -1228,7 +1228,7 @@ struct compat_ip6t_replace {
u32 underflow[NF_INET_NUMHOOKS];
u32 num_counters;
compat_uptr_t counters; /* struct xt_counters * */
struct compat_ip6t_entry entries[];
struct compat_ip6t_entry entries[0];
};
static int
@ -1574,7 +1574,7 @@ compat_do_ip6t_set_ctl(struct sock *sk, int cmd, void __user *user,
struct compat_ip6t_get_entries {
char name[XT_TABLE_MAXNAMELEN];
compat_uint_t size;
struct compat_ip6t_entry entrytable[];
struct compat_ip6t_entry entrytable[0];
};
static int

View file

@ -46,7 +46,7 @@ struct bitmap_ip {
u8 netmask; /* subnet netmask */
struct timer_list gc; /* garbage collection */
struct ip_set *set; /* attached to this ip_set */
unsigned char extensions[] /* data extensions */
unsigned char extensions[0] /* data extensions */
__aligned(__alignof__(u64));
};

View file

@ -49,7 +49,7 @@ struct bitmap_ipmac {
size_t memsize; /* members size */
struct timer_list gc; /* garbage collector */
struct ip_set *set; /* attached to this ip_set */
unsigned char extensions[] /* MAC + data extensions */
unsigned char extensions[0] /* MAC + data extensions */
__aligned(__alignof__(u64));
};

View file

@ -37,7 +37,7 @@ struct bitmap_port {
size_t memsize; /* members size */
struct timer_list gc; /* garbage collection */
struct ip_set *set; /* attached to this ip_set */
unsigned char extensions[] /* data extensions */
unsigned char extensions[0] /* data extensions */
__aligned(__alignof__(u64));
};

View file

@ -76,7 +76,7 @@ struct hbucket {
DECLARE_BITMAP(used, AHASH_MAX_TUNED);
u8 size; /* size of the array */
u8 pos; /* position of the first free entry */
unsigned char value[] /* the array of the values */
unsigned char value[0] /* the array of the values */
__aligned(__alignof__(u64));
};
@ -109,7 +109,7 @@ struct htable {
u8 htable_bits; /* size of hash table == 2^htable_bits */
u32 maxelem; /* Maxelem per region */
struct ip_set_region *hregion; /* Region locks and ext sizes */
struct hbucket __rcu *bucket[]; /* hashtable buckets */
struct hbucket __rcu *bucket[0]; /* hashtable buckets */
};
#define hbucket(h, i) ((h)->bucket[i])

View file

@ -33,7 +33,7 @@ struct nf_acct {
refcount_t refcnt;
char name[NFACCT_NAME_MAX];
struct rcu_head rcu_head;
char data[];
char data[0];
};
struct nfacct_filter {

View file

@ -132,7 +132,7 @@ struct xt_hashlimit_htable {
const char *name;
struct net *net;
struct hlist_head hash[]; /* hashtable itself */
struct hlist_head hash[0]; /* hashtable itself */
};
static int

View file

@ -71,7 +71,7 @@ struct recent_entry {
u_int8_t ttl;
u_int8_t index;
u_int16_t nstamps;
unsigned long stamps[];
unsigned long stamps[0];
};
struct recent_table {
@ -82,7 +82,7 @@ struct recent_table {
unsigned int entries;
u8 nstamps_max_mask;
struct list_head lru_list;
struct list_head iphash[];
struct list_head iphash[0];
};
struct recent_net {