Skip to content

Commit 690bf64

Browse files
committed
Merge git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf
Pablo Neira Ayuso says: ==================== Netfilter fixes for net The following patchset contains Netfilter fixes for net: 1) Harden set element field checks to avoid out-of-bound memory access, this patch also fixes the type of issue described in 7e6bc1f ("netfilter: nf_tables: stricter validation of element data") in a broader way. 2) Patches to restrict the chain, set, and rule id lookup in the transaction to the corresponding top-level table, patches from Thadeu Lima de Souza Cascardo. 3) Fix incorrect comment in ip6t_LOG.h 4) nft_data_init() performs upfront validation of the expected data. struct nft_data_desc is used to describe the expected data to be received from userspace. The .size field represents the maximum size that can be stored, for bound checks. Then, .len is an input/output field which stores the expected length as input (this is optional, to restrict the checks), as output it stores the real length received from userspace (if it was not specified as input). This patch comes in response to 7e6bc1f ("netfilter: nf_tables: stricter validation of element data") to address this type of issue in a more generic way by avoid opencoded data validation. Next patch requires this as a dependency. 5) Disallow jump to implicit chain from set element, this configuration is invalid. Only allow jump to chain via immediate expression is supported at this stage. 6) Fix possible null-pointer derefence in the error path of table updates, if memory allocation of the transaction fails. From Florian Westphal. * git://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: netfilter: nf_tables: fix null deref due to zeroed list head netfilter: nf_tables: disallow jump to implicit chain from set element netfilter: nf_tables: upfront validation of data via nft_data_init() netfilter: ip6t_LOG: Fix a typo in a comment netfilter: nf_tables: do not allow RULE_ID to refer to another chain netfilter: nf_tables: do not allow CHAIN_ID to refer to another table netfilter: nf_tables: do not allow SET_ID to refer to another table netfilter: nf_tables: validate variable length element extension ==================== Link: https://lore.kernel.org/r/[email protected]/ Signed-off-by: Jakub Kicinski <[email protected]>
2 parents bc3c8fe + 5800778 commit 690bf64

File tree

8 files changed

+222
-138
lines changed

8 files changed

+222
-138
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,18 @@ struct nft_ctx {
221221
bool report;
222222
};
223223

224+
enum nft_data_desc_flags {
225+
NFT_DATA_DESC_SETELEM = (1 << 0),
226+
};
227+
224228
struct nft_data_desc {
225229
enum nft_data_types type;
230+
unsigned int size;
226231
unsigned int len;
232+
unsigned int flags;
227233
};
228234

229-
int nft_data_init(const struct nft_ctx *ctx,
230-
struct nft_data *data, unsigned int size,
235+
int nft_data_init(const struct nft_ctx *ctx, struct nft_data *data,
231236
struct nft_data_desc *desc, const struct nlattr *nla);
232237
void nft_data_hold(const struct nft_data *data, enum nft_data_types type);
233238
void nft_data_release(const struct nft_data *data, enum nft_data_types type);
@@ -651,6 +656,7 @@ extern const struct nft_set_ext_type nft_set_ext_types[];
651656
struct nft_set_ext_tmpl {
652657
u16 len;
653658
u8 offset[NFT_SET_EXT_NUM];
659+
u8 ext_len[NFT_SET_EXT_NUM];
654660
};
655661

656662
/**
@@ -680,7 +686,8 @@ static inline int nft_set_ext_add_length(struct nft_set_ext_tmpl *tmpl, u8 id,
680686
return -EINVAL;
681687

682688
tmpl->offset[id] = tmpl->len;
683-
tmpl->len += nft_set_ext_types[id].len + len;
689+
tmpl->ext_len[id] = nft_set_ext_types[id].len + len;
690+
tmpl->len += tmpl->ext_len[id];
684691

685692
return 0;
686693
}

include/uapi/linux/netfilter_ipv6/ip6t_LOG.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ struct ip6t_log_info {
1717
char prefix[30];
1818
};
1919

20-
#endif /*_IPT_LOG_H*/
20+
#endif /* _IP6T_LOG_H */

0 commit comments

Comments
 (0)