|
| 1 | +From 92b389a828ec7e185e7777e491a057473f3214b6 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Rong Tao <rongtao@cestc.cn> |
| 3 | +Date: Sat, 4 Oct 2025 22:23:29 +0800 |
| 4 | +Subject: [PATCH] bpf: Finish constification of 1st parameter of bpf_d_path() |
| 5 | + |
| 6 | +The commit 1b8abbb12128 ("bpf...d_path(): constify path argument") |
| 7 | +constified the first parameter of the bpf_d_path(), but failed to |
| 8 | +update it in all places. Finish constification. |
| 9 | + |
| 10 | +Otherwise the selftest fail to build: |
| 11 | +.../selftests/bpf/bpf_experimental.h:222:12: error: conflicting types for 'bpf_path_d_path' |
| 12 | + 222 | extern int bpf_path_d_path(const struct path *path, char *buf, size_t buf__sz) __ksym; |
| 13 | + | ^ |
| 14 | +.../selftests/bpf/tools/include/vmlinux.h:153922:12: note: previous declaration is here |
| 15 | + 153922 | extern int bpf_path_d_path(struct path *path, char *buf, size_t buf__sz) __weak __ksym; |
| 16 | + |
| 17 | +Fixes: 1b8abbb12128 ("bpf...d_path(): constify path argument") |
| 18 | +Signed-off-by: Rong Tao <rongtao@cestc.cn> |
| 19 | +Signed-off-by: Alexei Starovoitov <ast@kernel.org> |
| 20 | +--- |
| 21 | + include/uapi/linux/bpf.h | 2 +- |
| 22 | + scripts/bpf_doc.py | 1 + |
| 23 | + tools/include/uapi/linux/bpf.h | 2 +- |
| 24 | + tools/testing/selftests/bpf/progs/verifier_vfs_accept.c | 2 +- |
| 25 | + 4 files changed, 4 insertions(+), 3 deletions(-) |
| 26 | + |
| 27 | +diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h |
| 28 | +index ae83d8649ef1..6829936d33f5 100644 |
| 29 | +--- a/include/uapi/linux/bpf.h |
| 30 | ++++ b/include/uapi/linux/bpf.h |
| 31 | +@@ -4891,7 +4891,7 @@ union bpf_attr { |
| 32 | + * |
| 33 | + * **-ENOENT** if the bpf_local_storage cannot be found. |
| 34 | + * |
| 35 | +- * long bpf_d_path(struct path *path, char *buf, u32 sz) |
| 36 | ++ * long bpf_d_path(const struct path *path, char *buf, u32 sz) |
| 37 | + * Description |
| 38 | + * Return full path for given **struct path** object, which |
| 39 | + * needs to be the kernel BTF *path* object. The path is |
| 40 | +diff --git a/scripts/bpf_doc.py b/scripts/bpf_doc.py |
| 41 | +index c77dc40f7689..15d113a1bc1d 100755 |
| 42 | +--- a/scripts/bpf_doc.py |
| 43 | ++++ b/scripts/bpf_doc.py |
| 44 | +@@ -788,6 +788,7 @@ class PrinterHelpersHeader(Printer): |
| 45 | + 'struct task_struct', |
| 46 | + 'struct cgroup', |
| 47 | + 'struct path', |
| 48 | ++ 'const struct path', |
| 49 | + 'struct btf_ptr', |
| 50 | + 'struct inode', |
| 51 | + 'struct socket', |
| 52 | +diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h |
| 53 | +index ae83d8649ef1..6829936d33f5 100644 |
| 54 | +--- a/tools/include/uapi/linux/bpf.h |
| 55 | ++++ b/tools/include/uapi/linux/bpf.h |
| 56 | +@@ -4891,7 +4891,7 @@ union bpf_attr { |
| 57 | + * |
| 58 | + * **-ENOENT** if the bpf_local_storage cannot be found. |
| 59 | + * |
| 60 | +- * long bpf_d_path(struct path *path, char *buf, u32 sz) |
| 61 | ++ * long bpf_d_path(const struct path *path, char *buf, u32 sz) |
| 62 | + * Description |
| 63 | + * Return full path for given **struct path** object, which |
| 64 | + * needs to be the kernel BTF *path* object. The path is |
| 65 | +diff --git a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c |
| 66 | +index 3e2d76ee8050..55398c04290a 100644 |
| 67 | +--- a/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c |
| 68 | ++++ b/tools/testing/selftests/bpf/progs/verifier_vfs_accept.c |
| 69 | +@@ -70,7 +70,7 @@ __success |
| 70 | + int BPF_PROG(path_d_path_from_file_argument, struct file *file) |
| 71 | + { |
| 72 | + int ret; |
| 73 | +- struct path *path; |
| 74 | ++ const struct path *path; |
| 75 | + |
| 76 | + /* The f_path member is a path which is embedded directly within a |
| 77 | + * file. Therefore, a pointer to such embedded members are still |
| 78 | +-- |
| 79 | +2.47.3 |
| 80 | + |
0 commit comments