Skip to content

Commit e7577a0

Browse files
author
Paolo Abeni
committed
Florian Westphal says: ==================== netfilter: updates for net The following patchset contains Netfilter fixes for *net*: 1) Fix UaF when netfilter bpf link goes away while nfnetlink dumps current hook list, we have to wait until rcu readers are gone. 2) Fix UaF when flowtable fails to register all devices, similar bug as 1). From Pablo Neira Ayuso. 3) nfnetlink_osf fails to properly validate option length fields. From Weiming Shi. netfilter pull request nf-26-03-19 * tag 'nf-26-03-19' of https://git.kernel.org/pub/scm/linux/kernel/git/netfilter/nf: nfnetlink_osf: validate individual option lengths in fingerprints netfilter: nf_tables: release flowtable after rcu grace period on error netfilter: bpf: defer hook memory release until rcu readers are done ==================== Link: https://patch.msgid.link/[email protected] Signed-off-by: Paolo Abeni <[email protected]>
2 parents d75ec7e + dbdfaae commit e7577a0

3 files changed

Lines changed: 15 additions & 1 deletion

File tree

net/netfilter/nf_bpf_link.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ static int bpf_nf_link_update(struct bpf_link *link, struct bpf_prog *new_prog,
170170

171171
static const struct bpf_link_ops bpf_nf_link_lops = {
172172
.release = bpf_nf_link_release,
173-
.dealloc = bpf_nf_link_dealloc,
173+
.dealloc_deferred = bpf_nf_link_dealloc,
174174
.detach = bpf_nf_link_detach,
175175
.show_fdinfo = bpf_nf_link_show_info,
176176
.fill_link_info = bpf_nf_link_fill_link_info,

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9203,6 +9203,7 @@ static int nf_tables_newflowtable(struct sk_buff *skb,
92039203
return 0;
92049204

92059205
err_flowtable_hooks:
9206+
synchronize_rcu();
92069207
nft_trans_destroy(trans);
92079208
err_flowtable_trans:
92089209
nft_hooks_destroy(&flowtable->hook_list);

net/netfilter/nfnetlink_osf.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,9 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,
302302
{
303303
struct nf_osf_user_finger *f;
304304
struct nf_osf_finger *kf = NULL, *sf;
305+
unsigned int tot_opt_len = 0;
305306
int err = 0;
307+
int i;
306308

307309
if (!capable(CAP_NET_ADMIN))
308310
return -EPERM;
@@ -318,6 +320,17 @@ static int nfnl_osf_add_callback(struct sk_buff *skb,
318320
if (f->opt_num > ARRAY_SIZE(f->opt))
319321
return -EINVAL;
320322

323+
for (i = 0; i < f->opt_num; i++) {
324+
if (!f->opt[i].length || f->opt[i].length > MAX_IPOPTLEN)
325+
return -EINVAL;
326+
if (f->opt[i].kind == OSFOPT_MSS && f->opt[i].length < 4)
327+
return -EINVAL;
328+
329+
tot_opt_len += f->opt[i].length;
330+
if (tot_opt_len > MAX_IPOPTLEN)
331+
return -EINVAL;
332+
}
333+
321334
if (!memchr(f->genre, 0, MAXGENRELEN) ||
322335
!memchr(f->subtype, 0, MAXGENRELEN) ||
323336
!memchr(f->version, 0, MAXGENRELEN))

0 commit comments

Comments
 (0)