All of lore.kernel.org
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: thinker.li@gmail.com
Cc: oe-kbuild-all@lists.linux.dev
Subject: Re: [RFC bpf-next v3 4/5] bpf: Add a new dynptr type for CGRUP_SOCKOPT.
Date: Wed, 16 Aug 2023 22:19:01 +0800	[thread overview]
Message-ID: <202308162201.NR58Gd8V-lkp@intel.com> (raw)
In-Reply-To: <20230815174712.660956-5-thinker.li@gmail.com>

Hi,

[This is a private test report for your RFC patch.]
kernel test robot noticed the following build warnings:

[auto build test WARNING on bpf-next/master]

url:    https://github.com/intel-lab-lkp/linux/commits/thinker-li-gmail-com/bpf-enable-sleepable-BPF-programs-attached-to-cgroup-get-set-sockopt/20230816-014936
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/20230815174712.660956-5-thinker.li%40gmail.com
patch subject: [RFC bpf-next v3 4/5] bpf: Add a new dynptr type for CGRUP_SOCKOPT.
config: x86_64-buildonly-randconfig-r001-20230816 (https://download.01.org/0day-ci/archive/20230816/202308162201.NR58Gd8V-lkp@intel.com/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce: (https://download.01.org/0day-ci/archive/20230816/202308162201.NR58Gd8V-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202308162201.NR58Gd8V-lkp@intel.com/

All warnings (new ones prefixed by >>):

   kernel/bpf/helpers.c:1892:19: warning: no previous declaration for 'bpf_obj_new_impl' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_obj_new_impl(u64 local_type_id__k, void *meta__ign)
                      ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:1922:18: warning: no previous declaration for 'bpf_obj_drop_impl' [-Wmissing-declarations]
    __bpf_kfunc void bpf_obj_drop_impl(void *p__alloc, void *meta__ign)
                     ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:1930:19: warning: no previous declaration for 'bpf_refcount_acquire_impl' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_refcount_acquire_impl(void *p__refcounted_kptr, void *meta__ign)
                      ^~~~~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:1975:17: warning: no previous declaration for 'bpf_list_push_front_impl' [-Wmissing-declarations]
    __bpf_kfunc int bpf_list_push_front_impl(struct bpf_list_head *head,
                    ^~~~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:1985:17: warning: no previous declaration for 'bpf_list_push_back_impl' [-Wmissing-declarations]
    __bpf_kfunc int bpf_list_push_back_impl(struct bpf_list_head *head,
                    ^~~~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2018:35: warning: no previous declaration for 'bpf_list_pop_front' [-Wmissing-declarations]
    __bpf_kfunc struct bpf_list_node *bpf_list_pop_front(struct bpf_list_head *head)
                                      ^~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2023:35: warning: no previous declaration for 'bpf_list_pop_back' [-Wmissing-declarations]
    __bpf_kfunc struct bpf_list_node *bpf_list_pop_back(struct bpf_list_head *head)
                                      ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2028:33: warning: no previous declaration for 'bpf_rbtree_remove' [-Wmissing-declarations]
    __bpf_kfunc struct bpf_rb_node *bpf_rbtree_remove(struct bpf_rb_root *root,
                                    ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2084:17: warning: no previous declaration for 'bpf_rbtree_add_impl' [-Wmissing-declarations]
    __bpf_kfunc int bpf_rbtree_add_impl(struct bpf_rb_root *root, struct bpf_rb_node *node,
                    ^~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2094:33: warning: no previous declaration for 'bpf_rbtree_first' [-Wmissing-declarations]
    __bpf_kfunc struct bpf_rb_node *bpf_rbtree_first(struct bpf_rb_root *root)
                                    ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2107:33: warning: no previous declaration for 'bpf_task_acquire' [-Wmissing-declarations]
    __bpf_kfunc struct task_struct *bpf_task_acquire(struct task_struct *p)
                                    ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2118:18: warning: no previous declaration for 'bpf_task_release' [-Wmissing-declarations]
    __bpf_kfunc void bpf_task_release(struct task_struct *p)
                     ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2207:33: warning: no previous declaration for 'bpf_task_from_pid' [-Wmissing-declarations]
    __bpf_kfunc struct task_struct *bpf_task_from_pid(s32 pid)
                                    ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2248:19: warning: no previous declaration for 'bpf_dynptr_slice' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_dynptr_slice(const struct bpf_dynptr_kern *ptr, u32 offset,
                      ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2333:19: warning: no previous declaration for 'bpf_dynptr_slice_rdwr' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_dynptr_slice_rdwr(const struct bpf_dynptr_kern *ptr, u32 offset,
                      ^~~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2364:17: warning: no previous declaration for 'bpf_dynptr_adjust' [-Wmissing-declarations]
    __bpf_kfunc int bpf_dynptr_adjust(struct bpf_dynptr_kern *ptr, u32 start, u32 end)
                    ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2382:18: warning: no previous declaration for 'bpf_dynptr_is_null' [-Wmissing-declarations]
    __bpf_kfunc bool bpf_dynptr_is_null(struct bpf_dynptr_kern *ptr)
                     ^~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2387:18: warning: no previous declaration for 'bpf_dynptr_is_rdonly' [-Wmissing-declarations]
    __bpf_kfunc bool bpf_dynptr_is_rdonly(struct bpf_dynptr_kern *ptr)
                     ^~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2395:19: warning: no previous declaration for 'bpf_dynptr_size' [-Wmissing-declarations]
    __bpf_kfunc __u32 bpf_dynptr_size(const struct bpf_dynptr_kern *ptr)
                      ^~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2403:17: warning: no previous declaration for 'bpf_dynptr_clone' [-Wmissing-declarations]
    __bpf_kfunc int bpf_dynptr_clone(struct bpf_dynptr_kern *ptr,
                    ^~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2416:19: warning: no previous declaration for 'bpf_cast_to_kern_ctx' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_cast_to_kern_ctx(void *obj)
                      ^~~~~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2421:19: warning: no previous declaration for 'bpf_rdonly_cast' [-Wmissing-declarations]
    __bpf_kfunc void *bpf_rdonly_cast(void *obj__ign, u32 btf_id__k)
                      ^~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2426:18: warning: no previous declaration for 'bpf_rcu_read_lock' [-Wmissing-declarations]
    __bpf_kfunc void bpf_rcu_read_lock(void)
                     ^~~~~~~~~~~~~~~~~
   kernel/bpf/helpers.c:2431:18: warning: no previous declaration for 'bpf_rcu_read_unlock' [-Wmissing-declarations]
    __bpf_kfunc void bpf_rcu_read_unlock(void)
                     ^~~~~~~~~~~~~~~~~~~
>> kernel/bpf/helpers.c:2441:17: warning: no previous declaration for 'bpf_sockopt_dynptr_alloc' [-Wmissing-declarations]
    __bpf_kfunc int bpf_sockopt_dynptr_alloc(struct bpf_sockopt *sopt, int size,
                    ^~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/helpers.c:2469:17: warning: no previous declaration for 'bpf_sockopt_dynptr_install' [-Wmissing-declarations]
    __bpf_kfunc int bpf_sockopt_dynptr_install(struct bpf_sockopt *sopt,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/helpers.c:2506:17: warning: no previous declaration for 'bpf_sockopt_dynptr_release' [-Wmissing-declarations]
    __bpf_kfunc int bpf_sockopt_dynptr_release(struct bpf_sockopt *sopt,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/helpers.c:2545:17: warning: no previous declaration for 'bpf_sockopt_dynptr_from' [-Wmissing-declarations]
    __bpf_kfunc int bpf_sockopt_dynptr_from(struct bpf_sockopt *sopt,
                    ^~~~~~~~~~~~~~~~~~~~~~~
>> kernel/bpf/helpers.c:2590:17: warning: no previous declaration for 'bpf_sockopt_dynptr_copy_to' [-Wmissing-declarations]
    __bpf_kfunc int bpf_sockopt_dynptr_copy_to(struct bpf_sockopt *sopt,
                    ^~~~~~~~~~~~~~~~~~~~~~~~~~


vim +/bpf_sockopt_dynptr_alloc +2441 kernel/bpf/helpers.c

  2435	
  2436	/* Create a buffer of the given size for a {set,get}sockopt BPF filter.
  2437	 *
  2438	 * This kfunc is only avaliabe for sleeplabe contexts. The dynptr should be
  2439	 * released by bpf_sockopt_dynptr_install() or bpf_sockopt_release().
  2440	 */
> 2441	__bpf_kfunc int bpf_sockopt_dynptr_alloc(struct bpf_sockopt *sopt, int size,
  2442						 struct bpf_dynptr_kern *ptr__uninit)
  2443	{
  2444		void *optval;
  2445		int err;
  2446	
  2447		bpf_dynptr_set_null(ptr__uninit);
  2448	
  2449		err = bpf_dynptr_check_size(size);
  2450		if (err)
  2451			return err;
  2452	
  2453		optval = kzalloc(size, GFP_KERNEL);
  2454		if (!optval)
  2455			return -ENOMEM;
  2456	
  2457		bpf_dynptr_init(ptr__uninit, optval,
  2458				BPF_DYNPTR_TYPE_CGROUP_SOCKOPT, 0, size);
  2459	
  2460		return size;
  2461	}
  2462	
  2463	/* Install the buffer of the dynptr into the sockopt context.
  2464	 *
  2465	 * This kfunc is only avaliabe for sleeplabe contexts. The dynptr should be
  2466	 * allocated by bpf_sockopt_dynptr_alloc().  The dynptr is invalid after
  2467	 * returning from this function successfully.
  2468	 */
> 2469	__bpf_kfunc int bpf_sockopt_dynptr_install(struct bpf_sockopt *sopt,
  2470						   struct bpf_dynptr_kern *ptr)
  2471	{
  2472		struct bpf_sockopt_kern *sopt_kern = (struct bpf_sockopt_kern *)sopt;
  2473	
  2474		if (!(sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_REPLACE) ||
  2475		    bpf_dynptr_get_type(ptr) != BPF_DYNPTR_TYPE_CGROUP_SOCKOPT ||
  2476		    !ptr->data)
  2477			return -EINVAL;
  2478	
  2479		if (sopt_kern->optval == ptr->data &&
  2480		    !(sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_USER)) {
  2481			/* This dynptr is initialized by bpf_sockopt_dynptr_from()
  2482			 * and the optval is not overwritten by
  2483			 * bpf_sockopt_dynptr_install() yet.
  2484			 */
  2485			bpf_dynptr_set_null(ptr);
  2486			sopt_kern->flags &= ~BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR;
  2487			return 0;
  2488		}
  2489	
  2490		if (sopt_kern->optval &&
  2491		    !(sopt_kern->flags & (BPF_SOCKOPT_FLAG_OPTVAL_USER |
  2492					  BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR)))
  2493			kfree(sopt_kern->optval);
  2494	
  2495		sopt_kern->optval = ptr->data;
  2496		sopt_kern->optval_end = ptr->data + __bpf_dynptr_size(ptr);
  2497		sopt_kern->optlen = __bpf_dynptr_size(ptr);
  2498		sopt_kern->flags &= ~(BPF_SOCKOPT_FLAG_OPTVAL_USER |
  2499				      BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR);
  2500	
  2501		bpf_dynptr_set_null(ptr);
  2502	
  2503		return 0;
  2504	}
  2505	
> 2506	__bpf_kfunc int bpf_sockopt_dynptr_release(struct bpf_sockopt *sopt,
  2507						   struct bpf_dynptr_kern *ptr)
  2508	{
  2509		struct bpf_sockopt_kern *sopt_kern = (struct bpf_sockopt_kern *)sopt;
  2510	
  2511		if (bpf_dynptr_get_type(ptr) != BPF_DYNPTR_TYPE_CGROUP_SOCKOPT ||
  2512		    !ptr->data)
  2513			return -EINVAL;
  2514	
  2515		if (sopt_kern->optval == ptr->data &&
  2516		    !(sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_USER))
  2517			/* This dynptr is initialized by bpf_sockopt_dynptr_from()
  2518			 * and the optval is not overwritten by
  2519			 * bpf_sockopt_dynptr_install() yet.
  2520			 */
  2521			sopt_kern->flags &= ~BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR;
  2522		else
  2523			kfree(ptr->data);
  2524		bpf_dynptr_set_null(ptr);
  2525	
  2526		return 0;
  2527	}
  2528	
  2529	/* Initialize a sockopt dynptr from a user or installed optval pointer.
  2530	 *
  2531	 * sopt->optval can be a user pointer or a kernel pointer. A kernel pointer
  2532	 * can be a buffer allocated by the caller of the BPF program or a buffer
  2533	 * installed by other BPF programs through bpf_sockopt_dynptr_install().
  2534	 *
  2535	 * Atmost one dynptr shall be created by this function at any moment, or
  2536	 * it will return -EINVAL. You can create another dypptr by this function
  2537	 * after release the previous one by bpf_sockopt_dynptr_release().
  2538	 *
  2539	 * A dynptr that is initialized when optval is a user pointer is an
  2540	 * exception. In this case, the dynptr will point to a kernel buffer with
  2541	 * the same content as the user buffer. To simplify the code, users should
  2542	 * always make sure having only one dynptr initialized by this function at
  2543	 * any moment.
  2544	 */
> 2545	__bpf_kfunc int bpf_sockopt_dynptr_from(struct bpf_sockopt *sopt,
  2546						struct bpf_dynptr_kern *ptr__uninit,
  2547						unsigned int size)
  2548	{
  2549		struct bpf_sockopt_kern *sopt_kern = (struct bpf_sockopt_kern *)sopt;
  2550		int err;
  2551	
  2552		bpf_dynptr_set_null(ptr__uninit);
  2553	
  2554		if (size > (sopt_kern->optval_end - sopt_kern->optval))
  2555			return -EINVAL;
  2556	
  2557		if (size == 0)
  2558			size = min(sopt_kern->optlen,
  2559				   (int)(sopt_kern->optval_end - sopt_kern->optval));
  2560	
  2561		if (sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR)
  2562			return -EINVAL;
  2563	
  2564		if (sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_USER) {
  2565			err = bpf_sockopt_dynptr_alloc(sopt, sopt_kern->optlen,
  2566						       ptr__uninit);
  2567			if (err >= 0)
  2568				err = copy_from_user(ptr__uninit->data,
  2569						     sopt_kern->optval,
  2570						     size);
  2571			return err;
  2572		}
  2573	
  2574		bpf_dynptr_init(ptr__uninit, sopt_kern->optval,
  2575				BPF_DYNPTR_TYPE_CGROUP_SOCKOPT, 0,
  2576				size);
  2577		sopt_kern->flags |= BPF_SOCKOPT_FLAG_OPTVAL_DYNPTR;
  2578	
  2579		return size;
  2580	}
  2581	
  2582	/**
  2583	 * int bpf_sockopt_dynptr_copy_to(struct bpf_sockopt *sopt,
  2584	 *				  struct bpf_dynptr_kern *ptr)
  2585	 *     Description
  2586	 *             Copy data from *ptr* to *sopt->optval*.
  2587	 *     Return
  2588	 *             >= 0 on success, or a negative error in case of failure.
  2589	 */
> 2590	__bpf_kfunc int bpf_sockopt_dynptr_copy_to(struct bpf_sockopt *sopt,
  2591						   struct bpf_dynptr_kern *ptr)
  2592	{
  2593		__u32 size = bpf_dynptr_size(ptr);
  2594	
  2595		struct bpf_sockopt_kern *sopt_kern = (struct bpf_sockopt_kern *)sopt;
  2596		int ret;
  2597	
  2598		if (size > (sopt_kern->optval_end - sopt_kern->optval))
  2599			return -EINVAL;
  2600	
  2601		if (sopt_kern->flags & BPF_SOCKOPT_FLAG_OPTVAL_USER) {
  2602			ret = copy_to_user(sopt_kern->optval, ptr->data,
  2603					   size);
  2604			if (unlikely(ret))
  2605				return -EFAULT;
  2606		} else {
  2607			/* Use memmove() in case of optval & ptr overlap. */
  2608			memmove(sopt_kern->optval, ptr->data, size);
  2609			ret = size;
  2610		}
  2611	
  2612		return ret;
  2613	}
  2614	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

  reply	other threads:[~2023-08-16 14:20 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-15 17:47 [RFC bpf-next v3 0/5] Sleepable BPF programs on cgroup {get,set}sockopt thinker.li
2023-08-15 17:47 ` [RFC bpf-next v3 1/5] bpf: enable sleepable BPF programs attached to cgroup/{get,set}sockopt thinker.li
2023-08-15 20:58   ` Stanislav Fomichev
2023-08-15 21:04     ` Kui-Feng Lee
2023-08-16  0:42   ` kernel test robot
2023-08-15 17:47 ` [RFC bpf-next v3 2/5] libbpf: add sleepable sections for {get,set}sockopt() thinker.li
2023-08-15 17:47 ` [RFC bpf-next v3 3/5] bpf: Prevent BPF programs from access the buffer pointed by user_optval thinker.li
2023-08-17  0:55   ` Martin KaFai Lau
2023-08-17 18:10     ` Kui-Feng Lee
2023-08-17  1:17   ` Alexei Starovoitov
2023-08-17 18:12     ` Kui-Feng Lee
2023-08-15 17:47 ` [RFC bpf-next v3 4/5] bpf: Add a new dynptr type for CGRUP_SOCKOPT thinker.li
2023-08-16 14:19   ` kernel test robot [this message]
2023-08-17  1:25   ` Alexei Starovoitov
2023-08-17 19:00     ` Kui-Feng Lee
2023-08-17 19:43       ` Alexei Starovoitov
2023-08-18  0:14         ` Kui-Feng Lee
2023-08-17 20:41     ` Martin KaFai Lau
2023-08-17 21:37       ` Yonghong Song
2023-08-17 22:56         ` Martin KaFai Lau
2023-08-17 21:46       ` Alexei Starovoitov
2023-08-17 22:45         ` Martin KaFai Lau
2023-08-15 17:47 ` [RFC bpf-next v3 5/5] selftests/bpf: Add test cases for sleepable BPF programs of the CGROUP_SOCKOPT type thinker.li
2023-08-15 20:57   ` Stanislav Fomichev
2023-08-15 23:37     ` Kui-Feng Lee
2023-08-16  0:03       ` Kui-Feng Lee
2023-08-17  1:13         ` Martin KaFai Lau
2023-08-17 18:36           ` Kui-Feng Lee

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=202308162201.NR58Gd8V-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=oe-kbuild-all@lists.linux.dev \
    --cc=thinker.li@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.