mirror of
				https://github.com/torvalds/linux.git
				synced 2025-10-31 16:48:26 +02:00 
			
		
		
		
	bpf: Move bpf_loop and bpf_for_each_map_elem under CAP_BPF
They would require func_info which needs prog BTF anyway. Loading BTF and setting the prog btf_fd while loading the prog indirectly requires CAP_BPF, so just to reduce confusion, move both these helpers taking callback under bpf_capable() protection as well, since they cannot be used without CAP_BPF. Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com> Link: https://lore.kernel.org/r/20220823013117.24916-1-memxor@gmail.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
This commit is contained in:
		
							parent
							
								
									f52c894734
								
							
						
					
					
						commit
						5679ff2f13
					
				
					 1 changed files with 4 additions and 4 deletions
				
			
		|  | @ -1613,10 +1613,6 @@ bpf_base_func_proto(enum bpf_func_id func_id) | ||||||
| 		return &bpf_ringbuf_submit_dynptr_proto; | 		return &bpf_ringbuf_submit_dynptr_proto; | ||||||
| 	case BPF_FUNC_ringbuf_discard_dynptr: | 	case BPF_FUNC_ringbuf_discard_dynptr: | ||||||
| 		return &bpf_ringbuf_discard_dynptr_proto; | 		return &bpf_ringbuf_discard_dynptr_proto; | ||||||
| 	case BPF_FUNC_for_each_map_elem: |  | ||||||
| 		return &bpf_for_each_map_elem_proto; |  | ||||||
| 	case BPF_FUNC_loop: |  | ||||||
| 		return &bpf_loop_proto; |  | ||||||
| 	case BPF_FUNC_strncmp: | 	case BPF_FUNC_strncmp: | ||||||
| 		return &bpf_strncmp_proto; | 		return &bpf_strncmp_proto; | ||||||
| 	case BPF_FUNC_strtol: | 	case BPF_FUNC_strtol: | ||||||
|  | @ -1659,6 +1655,10 @@ bpf_base_func_proto(enum bpf_func_id func_id) | ||||||
| 		return &bpf_timer_cancel_proto; | 		return &bpf_timer_cancel_proto; | ||||||
| 	case BPF_FUNC_kptr_xchg: | 	case BPF_FUNC_kptr_xchg: | ||||||
| 		return &bpf_kptr_xchg_proto; | 		return &bpf_kptr_xchg_proto; | ||||||
|  | 	case BPF_FUNC_for_each_map_elem: | ||||||
|  | 		return &bpf_for_each_map_elem_proto; | ||||||
|  | 	case BPF_FUNC_loop: | ||||||
|  | 		return &bpf_loop_proto; | ||||||
| 	default: | 	default: | ||||||
| 		break; | 		break; | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue
	
	 Kumar Kartikeya Dwivedi
						Kumar Kartikeya Dwivedi