* [linux-next:master 1231/1936] fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2025-04-08 9:15 kernel test robot
2025-04-08 9:24 ` Christian Brauner
0 siblings, 1 reply; 3+ messages in thread
From: kernel test robot @ 2025-04-08 9:15 UTC (permalink / raw)
To: NeilBrown; +Cc: oe-kbuild-all, Christian Brauner
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 7702d0130dc002bab2c3571ddb6ff68f82d99aea
commit: 973256a7be6ed574f242995c15a8aa80cc0cc566 [1231/1936] VFS: rename lookup_one_len family to lookup_noperm and remove permission check
config: arc-randconfig-r121-20250408 (https://download.01.org/0day-ci/archive/20250408/202504081746.zMqyeksR-lkp@intel.com/config)
compiler: arc-linux-gcc (GCC) 12.4.0
reproduce: (https://download.01.org/0day-ci/archive/20250408/202504081746.zMqyeksR-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/202504081746.zMqyeksR-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
>> fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const * @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected char const *
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
>> fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char const *name @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected unsigned char const *name
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
vim +258 fs/kernfs/mount.c
199
200 /**
201 * kernfs_node_dentry - get a dentry for the given kernfs_node
202 * @kn: kernfs_node for which a dentry is needed
203 * @sb: the kernfs super_block
204 *
205 * Return: the dentry pointer
206 */
207 struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
208 struct super_block *sb)
209 {
210 struct dentry *dentry;
211 struct kernfs_node *knparent;
212 struct kernfs_root *root;
213
214 BUG_ON(sb->s_op != &kernfs_sops);
215
216 dentry = dget(sb->s_root);
217
218 /* Check if this is the root kernfs_node */
219 if (!rcu_access_pointer(kn->__parent))
220 return dentry;
221
222 root = kernfs_root(kn);
223 /*
224 * As long as kn is valid, its parent can not vanish. This is cgroup's
225 * kn so it can't have its parent replaced. Therefore it is safe to use
226 * the ancestor node outside of the RCU or locked section.
227 */
228 if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_INVARIANT_PARENT)))
229 return ERR_PTR(-EINVAL);
230 scoped_guard(rcu) {
231 knparent = find_next_ancestor(kn, NULL);
232 }
233 if (WARN_ON(!knparent)) {
234 dput(dentry);
235 return ERR_PTR(-EINVAL);
236 }
237
238 do {
239 struct dentry *dtmp;
240 struct kernfs_node *kntmp;
241 const char *name;
242
243 if (kn == knparent)
244 return dentry;
245
246 scoped_guard(rwsem_read, &root->kernfs_rwsem) {
247 kntmp = find_next_ancestor(kn, knparent);
248 if (WARN_ON(!kntmp)) {
249 dput(dentry);
250 return ERR_PTR(-EINVAL);
251 }
252 name = kstrdup(kernfs_rcu_name(kntmp), GFP_KERNEL);
253 }
254 if (!name) {
255 dput(dentry);
256 return ERR_PTR(-ENOMEM);
257 }
> 258 dtmp = lookup_noperm_positive_unlocked(&QSTR(kntmp->name), dentry);
259 dput(dentry);
260 kfree(name);
261 if (IS_ERR(dtmp))
262 return dtmp;
263 knparent = kntmp;
264 dentry = dtmp;
265 } while (true);
266 }
267
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [linux-next:master 1231/1936] fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces)
2025-04-08 9:15 [linux-next:master 1231/1936] fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
@ 2025-04-08 9:24 ` Christian Brauner
0 siblings, 0 replies; 3+ messages in thread
From: Christian Brauner @ 2025-04-08 9:24 UTC (permalink / raw)
To: kernel test robot; +Cc: NeilBrown, oe-kbuild-all
On Tue, Apr 08, 2025 at 05:15:34PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
> head: 7702d0130dc002bab2c3571ddb6ff68f82d99aea
> commit: 973256a7be6ed574f242995c15a8aa80cc0cc566 [1231/1936] VFS: rename lookup_one_len family to lookup_noperm and remove permission check
> config: arc-randconfig-r121-20250408 (https://download.01.org/0day-ci/archive/20250408/202504081746.zMqyeksR-lkp@intel.com/config)
> compiler: arc-linux-gcc (GCC) 12.4.0
> reproduce: (https://download.01.org/0day-ci/archive/20250408/202504081746.zMqyeksR-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/202504081746.zMqyeksR-lkp@intel.com/
>
> sparse warnings: (new ones prefixed by >>)
> >> fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const * @@ got char const [noderef] __rcu *name @@
> fs/kernfs/mount.c:258:57: sparse: expected char const *
> fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
> >> fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char const *name @@ got char const [noderef] __rcu *name @@
> fs/kernfs/mount.c:258:57: sparse: expected unsigned char const *name
> fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
>
> vim +258 fs/kernfs/mount.c
>
> 199
> 200 /**
> 201 * kernfs_node_dentry - get a dentry for the given kernfs_node
> 202 * @kn: kernfs_node for which a dentry is needed
> 203 * @sb: the kernfs super_block
> 204 *
> 205 * Return: the dentry pointer
> 206 */
> 207 struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
> 208 struct super_block *sb)
> 209 {
> 210 struct dentry *dentry;
> 211 struct kernfs_node *knparent;
> 212 struct kernfs_root *root;
> 213
> 214 BUG_ON(sb->s_op != &kernfs_sops);
> 215
> 216 dentry = dget(sb->s_root);
> 217
> 218 /* Check if this is the root kernfs_node */
> 219 if (!rcu_access_pointer(kn->__parent))
> 220 return dentry;
> 221
> 222 root = kernfs_root(kn);
> 223 /*
> 224 * As long as kn is valid, its parent can not vanish. This is cgroup's
> 225 * kn so it can't have its parent replaced. Therefore it is safe to use
> 226 * the ancestor node outside of the RCU or locked section.
> 227 */
> 228 if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_INVARIANT_PARENT)))
> 229 return ERR_PTR(-EINVAL);
> 230 scoped_guard(rcu) {
> 231 knparent = find_next_ancestor(kn, NULL);
> 232 }
> 233 if (WARN_ON(!knparent)) {
> 234 dput(dentry);
> 235 return ERR_PTR(-EINVAL);
> 236 }
> 237
> 238 do {
> 239 struct dentry *dtmp;
> 240 struct kernfs_node *kntmp;
> 241 const char *name;
> 242
> 243 if (kn == knparent)
> 244 return dentry;
> 245
> 246 scoped_guard(rwsem_read, &root->kernfs_rwsem) {
> 247 kntmp = find_next_ancestor(kn, knparent);
> 248 if (WARN_ON(!kntmp)) {
> 249 dput(dentry);
> 250 return ERR_PTR(-EINVAL);
> 251 }
> 252 name = kstrdup(kernfs_rcu_name(kntmp), GFP_KERNEL);
> 253 }
> 254 if (!name) {
> 255 dput(dentry);
> 256 return ERR_PTR(-ENOMEM);
> 257 }
> > 258 dtmp = lookup_noperm_positive_unlocked(&QSTR(kntmp->name), dentry);
This should be:
diff --git a/fs/kernfs/mount.c b/fs/kernfs/mount.c
index 7c908e1c2730..a82fbce25c28 100644
--- a/fs/kernfs/mount.c
+++ b/fs/kernfs/mount.c
@@ -255,7 +255,7 @@ struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
dput(dentry);
return ERR_PTR(-ENOMEM);
}
- dtmp = lookup_noperm_positive_unlocked(&QSTR(kntmp->name), dentry);
+ dtmp = lookup_noperm_positive_unlocked(&QSTR(name), dentry);
dput(dentry);
kfree(name);
if (IS_ERR(dtmp))
I've fixed that.
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [linux-next:master 1231/1936] fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces)
@ 2025-04-08 19:26 kernel test robot
0 siblings, 0 replies; 3+ messages in thread
From: kernel test robot @ 2025-04-08 19:26 UTC (permalink / raw)
To: NeilBrown; +Cc: oe-kbuild-all, Christian Brauner
tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master
head: 7702d0130dc002bab2c3571ddb6ff68f82d99aea
commit: 973256a7be6ed574f242995c15a8aa80cc0cc566 [1231/1936] VFS: rename lookup_one_len family to lookup_noperm and remove permission check
config: x86_64-randconfig-122-20250408 (https://download.01.org/0day-ci/archive/20250409/202504090310.xjNpww93-lkp@intel.com/config)
compiler: clang version 20.1.2 (https://github.com/llvm/llvm-project 58df0ef89dd64126512e4ee27b4ac3fd8ddf6247)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250409/202504090310.xjNpww93-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/202504090310.xjNpww93-lkp@intel.com/
sparse warnings: (new ones prefixed by >>)
fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const * @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected char const *
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const * @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected char const *
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
>> fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected char const *const p @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected char const *const p
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in initializer (different address spaces) @@ expected unsigned char const *name @@ got char const [noderef] __rcu *name @@
fs/kernfs/mount.c:258:57: sparse: expected unsigned char const *name
fs/kernfs/mount.c:258:57: sparse: got char const [noderef] __rcu *name
vim +258 fs/kernfs/mount.c
199
200 /**
201 * kernfs_node_dentry - get a dentry for the given kernfs_node
202 * @kn: kernfs_node for which a dentry is needed
203 * @sb: the kernfs super_block
204 *
205 * Return: the dentry pointer
206 */
207 struct dentry *kernfs_node_dentry(struct kernfs_node *kn,
208 struct super_block *sb)
209 {
210 struct dentry *dentry;
211 struct kernfs_node *knparent;
212 struct kernfs_root *root;
213
214 BUG_ON(sb->s_op != &kernfs_sops);
215
216 dentry = dget(sb->s_root);
217
218 /* Check if this is the root kernfs_node */
219 if (!rcu_access_pointer(kn->__parent))
220 return dentry;
221
222 root = kernfs_root(kn);
223 /*
224 * As long as kn is valid, its parent can not vanish. This is cgroup's
225 * kn so it can't have its parent replaced. Therefore it is safe to use
226 * the ancestor node outside of the RCU or locked section.
227 */
228 if (WARN_ON_ONCE(!(root->flags & KERNFS_ROOT_INVARIANT_PARENT)))
229 return ERR_PTR(-EINVAL);
230 scoped_guard(rcu) {
231 knparent = find_next_ancestor(kn, NULL);
232 }
233 if (WARN_ON(!knparent)) {
234 dput(dentry);
235 return ERR_PTR(-EINVAL);
236 }
237
238 do {
239 struct dentry *dtmp;
240 struct kernfs_node *kntmp;
241 const char *name;
242
243 if (kn == knparent)
244 return dentry;
245
246 scoped_guard(rwsem_read, &root->kernfs_rwsem) {
247 kntmp = find_next_ancestor(kn, knparent);
248 if (WARN_ON(!kntmp)) {
249 dput(dentry);
250 return ERR_PTR(-EINVAL);
251 }
252 name = kstrdup(kernfs_rcu_name(kntmp), GFP_KERNEL);
253 }
254 if (!name) {
255 dput(dentry);
256 return ERR_PTR(-ENOMEM);
257 }
> 258 dtmp = lookup_noperm_positive_unlocked(&QSTR(kntmp->name), dentry);
259 dput(dentry);
260 kfree(name);
261 if (IS_ERR(dtmp))
262 return dtmp;
263 knparent = kntmp;
264 dentry = dtmp;
265 } while (true);
266 }
267
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-04-08 19:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-08 9:15 [linux-next:master 1231/1936] fs/kernfs/mount.c:258:57: sparse: sparse: incorrect type in argument 1 (different address spaces) kernel test robot
2025-04-08 9:24 ` Christian Brauner
-- strict thread matches above, loose matches on Subject: below --
2025-04-08 19:26 kernel test robot
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.