Browse Source

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf

Daniel Borkmann says:

====================
pull-request: bpf 2018-09-16

The following pull-request contains BPF updates for your *net* tree.

The main changes are:

1) Fix end boundary calculation in BTF for the type section, from Martin.

2) Fix and revert subtraction of pointers that was accidentally allowed
   for unprivileged programs, from Alexei.

3) Fix bpf_msg_pull_data() helper by using __GFP_COMP in order to avoid
   a warning in linearizing sg pages into a single one for large allocs,
   from Tushar.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
David S. Miller 7 years ago
parent
commit
0376d5dce0
3 changed files with 4 additions and 3 deletions
  1. 1 1
      kernel/bpf/btf.c
  2. 1 1
      kernel/bpf/verifier.c
  3. 2 1
      net/core/filter.c

+ 1 - 1
kernel/bpf/btf.c

@@ -1844,7 +1844,7 @@ static int btf_check_all_metas(struct btf_verifier_env *env)
 
 
 	hdr = &btf->hdr;
 	hdr = &btf->hdr;
 	cur = btf->nohdr_data + hdr->type_off;
 	cur = btf->nohdr_data + hdr->type_off;
-	end = btf->nohdr_data + hdr->type_len;
+	end = cur + hdr->type_len;
 
 
 	env->log_type_id = 1;
 	env->log_type_id = 1;
 	while (cur < end) {
 	while (cur < end) {

+ 1 - 1
kernel/bpf/verifier.c

@@ -3163,7 +3163,7 @@ static int adjust_reg_min_max_vals(struct bpf_verifier_env *env,
 				 * an arbitrary scalar. Disallow all math except
 				 * an arbitrary scalar. Disallow all math except
 				 * pointer subtraction
 				 * pointer subtraction
 				 */
 				 */
-				if (opcode == BPF_SUB){
+				if (opcode == BPF_SUB && env->allow_ptr_leaks) {
 					mark_reg_unknown(env, regs, insn->dst_reg);
 					mark_reg_unknown(env, regs, insn->dst_reg);
 					return 0;
 					return 0;
 				}
 				}

+ 2 - 1
net/core/filter.c

@@ -2344,7 +2344,8 @@ BPF_CALL_4(bpf_msg_pull_data,
 	if (unlikely(bytes_sg_total > copy))
 	if (unlikely(bytes_sg_total > copy))
 		return -EINVAL;
 		return -EINVAL;
 
 
-	page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC, get_order(copy));
+	page = alloc_pages(__GFP_NOWARN | GFP_ATOMIC | __GFP_COMP,
+			   get_order(copy));
 	if (unlikely(!page))
 	if (unlikely(!page))
 		return -ENOMEM;
 		return -ENOMEM;
 	p = page_address(page);
 	p = page_address(page);