All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc
  2025-05-29  3:32 ` [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc Rong Tao
@ 2025-06-02  6:20 ` Dan Carpenter
  0 siblings, 0 replies; 8+ messages in thread
From: kernel test robot @ 2025-05-29 20:30 UTC (permalink / raw)
  To: oe-kbuild; +Cc: lkp, Dan Carpenter

BCC: lkp@intel.com
CC: oe-kbuild-all@lists.linux.dev
In-Reply-To: <tencent_97F8B56B340F51DB604B482FEBF012460505@qq.com>
References: <tencent_97F8B56B340F51DB604B482FEBF012460505@qq.com>
TO: Rong Tao <rtoax@foxmail.com>
TO: ast@kernel.org
TO: daniel@iogearbox.net
CC: rtoax@foxmail.com
CC: rongtao@cestc.cn
CC: Andrii Nakryiko <andrii@kernel.org>
CC: Martin KaFai Lau <martin.lau@linux.dev>
CC: Eduard Zingerman <eddyz87@gmail.com>
CC: Song Liu <song@kernel.org>
CC: Yonghong Song <yonghong.song@linux.dev>
CC: John Fastabend <john.fastabend@gmail.com>
CC: KP Singh <kpsingh@kernel.org>
CC: Stanislav Fomichev <sdf@fomichev.me>
CC: Hao Luo <haoluo@google.com>
CC: Jiri Olsa <jolsa@kernel.org>
CC: Mykola Lysenko <mykolal@fb.com>
CC: Shuah Khan <skhan@linuxfoundation.org>
CC: Juntong Deng <juntong.deng@outlook.com>
CC: Amery Hung <amery.hung@bytedance.com>
CC: Dave Marchevsky <davemarchevsky@fb.com>
CC: Hou Tao <houtao1@huawei.com>
CC: "(open list:BPF \(Safe Dynamic Programs and Tools\))" <bpf@vger.kernel.org> (open list:BPF (Safe Dynamic Programs and Tools))
CC: linux-kernel@vger.kernel.org
CC: linux-kselftest@vger.kernel.org

Hi Rong,

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/Rong-Tao/selftests-bpf-Add-selftests-for-bpf_task_cwd_from_pid/20250529-113933
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link:    https://lore.kernel.org/r/tencent_97F8B56B340F51DB604B482FEBF012460505%40qq.com
patch subject: [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc
:::::: branch date: 17 hours ago
:::::: commit date: 17 hours ago
config: x86_64-randconfig-161-20250529 (https://download.01.org/0day-ci/archive/20250530/202505300432.nZC50gOu-lkp@intel.com/config)
compiler: gcc-12 (Debian 12.2.0-14) 12.2.0

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>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202505300432.nZC50gOu-lkp@intel.com/

smatch warnings:
kernel/bpf/helpers.c:2687 bpf_task_cwd_from_pid() warn: inconsistent returns 'rcu_read'.

vim +/rcu_read +2687 kernel/bpf/helpers.c

675c3596ff32c0 Juntong Deng 2024-10-14  2649  
b24383bde5a454 Rong Tao     2025-05-29  2650  /**
b24383bde5a454 Rong Tao     2025-05-29  2651   * bpf_task_cwd_from_pid - Get a task's absolute pathname of the current
b24383bde5a454 Rong Tao     2025-05-29  2652   * working directory from its pid.
b24383bde5a454 Rong Tao     2025-05-29  2653   * @pid: The pid of the task being looked up.
b24383bde5a454 Rong Tao     2025-05-29  2654   * @buf: The array pointed to by buf.
b24383bde5a454 Rong Tao     2025-05-29  2655   * @buf_len: buf length.
b24383bde5a454 Rong Tao     2025-05-29  2656   */
b24383bde5a454 Rong Tao     2025-05-29  2657  __bpf_kfunc int bpf_task_cwd_from_pid(s32 pid, char *buf, u32 buf_len)
b24383bde5a454 Rong Tao     2025-05-29  2658  {
b24383bde5a454 Rong Tao     2025-05-29  2659  	struct path pwd;
b24383bde5a454 Rong Tao     2025-05-29  2660  	char kpath[256], *path;
b24383bde5a454 Rong Tao     2025-05-29  2661  	struct task_struct *task;
b24383bde5a454 Rong Tao     2025-05-29  2662  
b24383bde5a454 Rong Tao     2025-05-29  2663  	if (!buf || buf_len == 0)
b24383bde5a454 Rong Tao     2025-05-29  2664  		return -EINVAL;
b24383bde5a454 Rong Tao     2025-05-29  2665  
b24383bde5a454 Rong Tao     2025-05-29  2666  	rcu_read_lock();
b24383bde5a454 Rong Tao     2025-05-29  2667  	task = pid_task(find_vpid(pid), PIDTYPE_PID);
b24383bde5a454 Rong Tao     2025-05-29  2668  	if (!task) {
b24383bde5a454 Rong Tao     2025-05-29  2669  		rcu_read_unlock();
b24383bde5a454 Rong Tao     2025-05-29  2670  		return -ESRCH;
b24383bde5a454 Rong Tao     2025-05-29  2671  	}
b24383bde5a454 Rong Tao     2025-05-29  2672  	task_lock(task);
b24383bde5a454 Rong Tao     2025-05-29  2673  	if (!task->fs) {
b24383bde5a454 Rong Tao     2025-05-29  2674  		task_unlock(task);
b24383bde5a454 Rong Tao     2025-05-29  2675  		return -ENOENT;
b24383bde5a454 Rong Tao     2025-05-29  2676  	}
b24383bde5a454 Rong Tao     2025-05-29  2677  	get_fs_pwd(task->fs, &pwd);
b24383bde5a454 Rong Tao     2025-05-29  2678  	task_unlock(task);
b24383bde5a454 Rong Tao     2025-05-29  2679  	rcu_read_unlock();
b24383bde5a454 Rong Tao     2025-05-29  2680  
b24383bde5a454 Rong Tao     2025-05-29  2681  	path = d_path(&pwd, kpath, sizeof(kpath));
b24383bde5a454 Rong Tao     2025-05-29  2682  	path_put(&pwd);
b24383bde5a454 Rong Tao     2025-05-29  2683  	if (IS_ERR(path))
b24383bde5a454 Rong Tao     2025-05-29  2684  		return PTR_ERR(path);
b24383bde5a454 Rong Tao     2025-05-29  2685  
b24383bde5a454 Rong Tao     2025-05-29  2686  	strncpy(buf, path, buf_len);
b24383bde5a454 Rong Tao     2025-05-29 @2687  	return 0;
b24383bde5a454 Rong Tao     2025-05-29  2688  }
b24383bde5a454 Rong Tao     2025-05-29  2689  

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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-06-02  6:20 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1748488784.git.rtoax@foxmail.com>
2025-05-29  3:32 ` [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc Rong Tao
2025-05-29  5:44   ` Alexei Starovoitov
2025-05-30  1:28     ` Rong Tao
2025-05-30  1:55       ` Yonghong Song
2025-05-30  6:34         ` Rong Tao
2025-05-29  3:32 ` [PATCH bpf-next 2/2] selftests/bpf: Add selftests for bpf_task_cwd_from_pid() Rong Tao
2025-05-29 20:30 [PATCH bpf-next 1/2] bpf: Add bpf_task_cwd_from_pid() kfunc kernel test robot
2025-06-02  6:20 ` Dan Carpenter

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.