Skip to content

Commit 26c9342

Browse files
committed
Merge tag 'pull-filename' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs
Pull vfs 'struct filename' updates from Al Viro: "[Mostly] sanitize struct filename handling" * tag 'pull-filename' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (68 commits) sysfs(2): fs_index() argument is _not_ a pathname alpha: switch osf_mount() to strndup_user() ksmbd: use CLASS(filename_kernel) mqueue: switch to CLASS(filename) user_statfs(): switch to CLASS(filename) statx: switch to CLASS(filename_maybe_null) quotactl_block(): switch to CLASS(filename) chroot(2): switch to CLASS(filename) move_mount(2): switch to CLASS(filename_maybe_null) namei.c: switch user pathname imports to CLASS(filename{,_flags}) namei.c: convert getname_kernel() callers to CLASS(filename_kernel) do_f{chmod,chown,access}at(): use CLASS(filename_uflags) do_readlinkat(): switch to CLASS(filename_flags) do_sys_truncate(): switch to CLASS(filename) do_utimes_path(): switch to CLASS(filename_uflags) chdir(2): unspaghettify a bit... do_fchownat(): unspaghettify a bit... fspick(2): use CLASS(filename_flags) name_to_handle_at(): use CLASS(filename_uflags) vfs_open_tree(): use CLASS(filename_uflags) ...
2 parents 8a5203c + 0787a93 commit 26c9342

File tree

37 files changed

+563
-827
lines changed

37 files changed

+563
-827
lines changed

Documentation/filesystems/porting.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,3 +1340,14 @@ The ->setlease() file_operation must now be explicitly set in order to provide
13401340
support for leases. When set to NULL, the kernel will now return -EINVAL to
13411341
attempts to set a lease. Filesystems that wish to use the kernel-internal lease
13421342
implementation should set it to generic_setlease().
1343+
1344+
---
1345+
1346+
**mandatory**
1347+
1348+
fs/namei.c primitives that consume filesystem references (do_renameat2(),
1349+
do_linkat(), do_symlinkat(), do_mkdirat(), do_mknodat(), do_unlinkat()
1350+
and do_rmdir()) are gone; they are replaced with non-consuming analogues
1351+
(filename_renameat2(), etc.)
1352+
Callers are adjusted - responsibility for dropping the filenames belongs
1353+
to them now.

arch/alpha/kernel/osf_sys.c

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -454,42 +454,30 @@ static int
454454
osf_ufs_mount(const char __user *dirname,
455455
struct ufs_args __user *args, int flags)
456456
{
457-
int retval;
458-
struct cdfs_args tmp;
459-
struct filename *devname;
457+
struct ufs_args tmp;
458+
char *devname __free(kfree) = NULL;
460459

461-
retval = -EFAULT;
462460
if (copy_from_user(&tmp, args, sizeof(tmp)))
463-
goto out;
464-
devname = getname(tmp.devname);
465-
retval = PTR_ERR(devname);
461+
return -EFAULT;
462+
devname = strndup_user(tmp.devname, PATH_MAX);
466463
if (IS_ERR(devname))
467-
goto out;
468-
retval = do_mount(devname->name, dirname, "ext2", flags, NULL);
469-
putname(devname);
470-
out:
471-
return retval;
464+
return PTR_ERR(devname);
465+
return do_mount(devname, dirname, "ext2", flags, NULL);
472466
}
473467

474468
static int
475469
osf_cdfs_mount(const char __user *dirname,
476470
struct cdfs_args __user *args, int flags)
477471
{
478-
int retval;
479472
struct cdfs_args tmp;
480-
struct filename *devname;
473+
char *devname __free(kfree) = NULL;
481474

482-
retval = -EFAULT;
483475
if (copy_from_user(&tmp, args, sizeof(tmp)))
484-
goto out;
485-
devname = getname(tmp.devname);
486-
retval = PTR_ERR(devname);
476+
return -EFAULT;
477+
devname = strndup_user(tmp.devname, PATH_MAX);
487478
if (IS_ERR(devname))
488-
goto out;
489-
retval = do_mount(devname->name, dirname, "iso9660", flags, NULL);
490-
putname(devname);
491-
out:
492-
return retval;
479+
return PTR_ERR(devname);
480+
return do_mount(devname, dirname, "iso9660", flags, NULL);
493481
}
494482

495483
static int

fs/coredump.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,11 +895,12 @@ static bool coredump_file(struct core_name *cn, struct coredump_params *cprm,
895895
* privs and don't want to unlink another user's coredump.
896896
*/
897897
if (!coredump_force_suid_safe(cprm)) {
898+
CLASS(filename_kernel, name)(cn->corename);
898899
/*
899900
* If it doesn't exist, that's fine. If there's some
900901
* other problem, we'll catch it at the filp_open().
901902
*/
902-
do_unlinkat(AT_FDCWD, getname_kernel(cn->corename));
903+
filename_unlinkat(AT_FDCWD, name);
903904
}
904905

905906
/*

fs/dcache.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3297,10 +3297,6 @@ static void __init dcache_init(void)
32973297
runtime_const_init(ptr, dentry_hashtable);
32983298
}
32993299

3300-
/* SLAB cache for __getname() consumers */
3301-
struct kmem_cache *names_cachep __ro_after_init;
3302-
EXPORT_SYMBOL(names_cachep);
3303-
33043300
void __init vfs_caches_init_early(void)
33053301
{
33063302
int i;
@@ -3314,9 +3310,7 @@ void __init vfs_caches_init_early(void)
33143310

33153311
void __init vfs_caches_init(void)
33163312
{
3317-
names_cachep = kmem_cache_create_usercopy("names_cache", PATH_MAX, 0,
3318-
SLAB_HWCACHE_ALIGN|SLAB_PANIC, 0, PATH_MAX, NULL);
3319-
3313+
filename_init();
33203314
dcache_init();
33213315
inode_init();
33223316
files_init();

0 commit comments

Comments
 (0)