Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'pull-qstr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs

Pull d_name audit update from Al Viro:
"Simplifying ->d_name audits, easy part.

Turn dentry->d_name into an anon union of const struct qsrt (d_name
itself) and a writable alias (__d_name).

With constification of some struct qstr * arguments of functions that
get &dentry->d_name passed to them, that ends up with all
modifications provably done only in fs/dcache.c (and a fairly small
part of it).

Any new places doing modifications will be easy to find - grep for
__d_name will suffice"

* tag 'pull-qstr' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs:
make it easier to catch those who try to modify ->d_name
generic_ci_validate_strict_name(): constify name argument
afs_dir_search: constify qstr argument
afs_edit_dir_{add,remove}(): constify qstr argument
exfat_find(): constify qstr argument
security_dentry_init_security(): constify qstr argument

+34 -29
+2 -2
fs/afs/dir_edit.c
··· 239 239 * The caller must hold the inode locked. 240 240 */ 241 241 void afs_edit_dir_add(struct afs_vnode *vnode, 242 - struct qstr *name, struct afs_fid *new_fid, 242 + const struct qstr *name, struct afs_fid *new_fid, 243 243 enum afs_edit_dir_reason why) 244 244 { 245 245 union afs_xdr_dir_block *meta, *block; ··· 391 391 * The caller must hold the inode locked. 392 392 */ 393 393 void afs_edit_dir_remove(struct afs_vnode *vnode, 394 - struct qstr *name, enum afs_edit_dir_reason why) 394 + const struct qstr *name, enum afs_edit_dir_reason why) 395 395 { 396 396 union afs_xdr_dir_block *meta, *block, *pblock; 397 397 union afs_xdr_dirent *de, *pde;
+1 -1
fs/afs/dir_search.c
··· 188 188 /* 189 189 * Search the appropriate hash chain in the contents of an AFS directory. 190 190 */ 191 - int afs_dir_search(struct afs_vnode *dvnode, struct qstr *name, 191 + int afs_dir_search(struct afs_vnode *dvnode, const struct qstr *name, 192 192 struct afs_fid *_fid, afs_dataversion_t *_dir_version) 193 193 { 194 194 struct afs_dir_iter iter = { .dvnode = dvnode, };
+3 -3
fs/afs/internal.h
··· 1099 1099 /* 1100 1100 * dir_edit.c 1101 1101 */ 1102 - extern void afs_edit_dir_add(struct afs_vnode *, struct qstr *, struct afs_fid *, 1102 + extern void afs_edit_dir_add(struct afs_vnode *, const struct qstr *, struct afs_fid *, 1103 1103 enum afs_edit_dir_reason); 1104 - extern void afs_edit_dir_remove(struct afs_vnode *, struct qstr *, enum afs_edit_dir_reason); 1104 + extern void afs_edit_dir_remove(struct afs_vnode *, const struct qstr *, enum afs_edit_dir_reason); 1105 1105 void afs_edit_dir_update(struct afs_vnode *vnode, const struct qstr *name, 1106 1106 struct afs_vnode *new_dvnode, enum afs_edit_dir_reason why); 1107 1107 void afs_mkdir_init_dir(struct afs_vnode *dvnode, struct afs_vnode *parent_vnode); ··· 1114 1114 union afs_xdr_dir_block *afs_dir_find_block(struct afs_dir_iter *iter, size_t block); 1115 1115 int afs_dir_search_bucket(struct afs_dir_iter *iter, const struct qstr *name, 1116 1116 struct afs_fid *_fid); 1117 - int afs_dir_search(struct afs_vnode *dvnode, struct qstr *name, 1117 + int afs_dir_search(struct afs_vnode *dvnode, const struct qstr *name, 1118 1118 struct afs_fid *_fid, afs_dataversion_t *_dir_version); 1119 1119 1120 1120 /*
+13 -13
fs/dcache.c
··· 1717 1717 dname = dentry->d_shortname.string; 1718 1718 } 1719 1719 1720 - dentry->d_name.len = name->len; 1721 - dentry->d_name.hash = name->hash; 1720 + dentry->__d_name.len = name->len; 1721 + dentry->__d_name.hash = name->hash; 1722 1722 memcpy(dname, name->name, name->len); 1723 1723 dname[name->len] = 0; 1724 1724 1725 1725 /* Make sure we always see the terminating NUL character */ 1726 - smp_store_release(&dentry->d_name.name, dname); /* ^^^ */ 1726 + smp_store_release(&dentry->__d_name.name, dname); /* ^^^ */ 1727 1727 1728 1728 dentry->d_flags = 0; 1729 1729 lockref_init(&dentry->d_lockref); ··· 2743 2743 /* 2744 2744 * Both external: swap the pointers 2745 2745 */ 2746 - swap(target->d_name.name, dentry->d_name.name); 2746 + swap(target->__d_name.name, dentry->__d_name.name); 2747 2747 } else { 2748 2748 /* 2749 2749 * dentry:internal, target:external. Steal target's 2750 2750 * storage and make target internal. 2751 2751 */ 2752 - dentry->d_name.name = target->d_name.name; 2752 + dentry->__d_name.name = target->__d_name.name; 2753 2753 target->d_shortname = dentry->d_shortname; 2754 - target->d_name.name = target->d_shortname.string; 2754 + target->__d_name.name = target->d_shortname.string; 2755 2755 } 2756 2756 } else { 2757 2757 if (unlikely(dname_external(dentry))) { ··· 2759 2759 * dentry:external, target:internal. Give dentry's 2760 2760 * storage to target and make dentry internal 2761 2761 */ 2762 - target->d_name.name = dentry->d_name.name; 2762 + target->__d_name.name = dentry->__d_name.name; 2763 2763 dentry->d_shortname = target->d_shortname; 2764 - dentry->d_name.name = dentry->d_shortname.string; 2764 + dentry->__d_name.name = dentry->d_shortname.string; 2765 2765 } else { 2766 2766 /* 2767 2767 * Both are internal. ··· 2771 2771 target->d_shortname.words[i]); 2772 2772 } 2773 2773 } 2774 - swap(dentry->d_name.hash_len, target->d_name.hash_len); 2774 + swap(dentry->__d_name.hash_len, target->__d_name.hash_len); 2775 2775 } 2776 2776 2777 2777 static void copy_name(struct dentry *dentry, struct dentry *target) ··· 2781 2781 old_name = external_name(dentry); 2782 2782 if (unlikely(dname_external(target))) { 2783 2783 atomic_inc(&external_name(target)->count); 2784 - dentry->d_name = target->d_name; 2784 + dentry->__d_name = target->__d_name; 2785 2785 } else { 2786 2786 dentry->d_shortname = target->d_shortname; 2787 - dentry->d_name.name = dentry->d_shortname.string; 2788 - dentry->d_name.hash_len = target->d_name.hash_len; 2787 + dentry->__d_name.name = dentry->d_shortname.string; 2788 + dentry->__d_name.hash_len = target->__d_name.hash_len; 2789 2789 } 2790 2790 if (old_name && likely(atomic_dec_and_test(&old_name->count))) 2791 2791 kfree_rcu(old_name, head); ··· 3134 3134 !d_unlinked(dentry)); 3135 3135 spin_lock(&dentry->d_parent->d_lock); 3136 3136 spin_lock_nested(&dentry->d_lock, DENTRY_D_LOCK_NESTED); 3137 - dentry->d_name.len = sprintf(dentry->d_shortname.string, "#%llu", 3137 + dentry->__d_name.len = sprintf(dentry->d_shortname.string, "#%llu", 3138 3138 (unsigned long long)inode->i_ino); 3139 3139 spin_unlock(&dentry->d_lock); 3140 3140 spin_unlock(&dentry->d_parent->d_lock);
+1 -1
fs/exfat/namei.c
··· 587 587 } 588 588 589 589 /* lookup a file */ 590 - static int exfat_find(struct inode *dir, struct qstr *qname, 590 + static int exfat_find(struct inode *dir, const struct qstr *qname, 591 591 struct exfat_dir_entry *info) 592 592 { 593 593 int ret, dentry, count;
+4 -1
include/linux/dcache.h
··· 95 95 seqcount_spinlock_t d_seq; /* per dentry seqlock */ 96 96 struct hlist_bl_node d_hash; /* lookup hash list */ 97 97 struct dentry *d_parent; /* parent directory */ 98 - struct qstr d_name; 98 + union { 99 + struct qstr __d_name; /* for use ONLY in fs/dcache.c */ 100 + const struct qstr d_name; 101 + }; 99 102 struct inode *d_inode; /* Where the name belongs to - NULL is 100 103 * negative */ 101 104 union shortname_store d_shortname;
+4 -2
include/linux/fs.h
··· 3716 3716 * happens when a directory is casefolded and the filesystem is strict 3717 3717 * about its encoding. 3718 3718 */ 3719 - static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) 3719 + static inline bool generic_ci_validate_strict_name(struct inode *dir, 3720 + const struct qstr *name) 3720 3721 { 3721 3722 if (!IS_CASEFOLDED(dir) || !sb_has_strict_encoding(dir->i_sb)) 3722 3723 return true; ··· 3732 3731 return !utf8_validate(dir->i_sb->s_encoding, name); 3733 3732 } 3734 3733 #else 3735 - static inline bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) 3734 + static inline bool generic_ci_validate_strict_name(struct inode *dir, 3735 + const struct qstr *name) 3736 3736 { 3737 3737 return true; 3738 3738 }
+1 -1
include/linux/lsm_hook_defs.h
··· 85 85 int mode, const struct qstr *name, const char **xattr_name, 86 86 struct lsm_context *cp) 87 87 LSM_HOOK(int, 0, dentry_create_files_as, struct dentry *dentry, int mode, 88 - struct qstr *name, const struct cred *old, struct cred *new) 88 + const struct qstr *name, const struct cred *old, struct cred *new) 89 89 90 90 #ifdef CONFIG_SECURITY_PATH 91 91 LSM_HOOK(int, 0, path_unlink, const struct path *dir, struct dentry *dentry)
+2 -2
include/linux/security.h
··· 391 391 const char **xattr_name, 392 392 struct lsm_context *lsmcxt); 393 393 int security_dentry_create_files_as(struct dentry *dentry, int mode, 394 - struct qstr *name, 394 + const struct qstr *name, 395 395 const struct cred *old, 396 396 struct cred *new); 397 397 int security_path_notify(const struct path *path, u64 mask, ··· 872 872 } 873 873 874 874 static inline int security_dentry_create_files_as(struct dentry *dentry, 875 - int mode, struct qstr *name, 875 + int mode, const struct qstr *name, 876 876 const struct cred *old, 877 877 struct cred *new) 878 878 {
+1 -1
security/security.c
··· 1814 1814 * Return: Returns 0 on success, error on failure. 1815 1815 */ 1816 1816 int security_dentry_create_files_as(struct dentry *dentry, int mode, 1817 - struct qstr *name, 1817 + const struct qstr *name, 1818 1818 const struct cred *old, struct cred *new) 1819 1819 { 1820 1820 return call_int_hook(dentry_create_files_as, dentry, mode,
+1 -1
security/selinux/hooks.c
··· 2905 2905 } 2906 2906 2907 2907 static int selinux_dentry_create_files_as(struct dentry *dentry, int mode, 2908 - struct qstr *name, 2908 + const struct qstr *name, 2909 2909 const struct cred *old, 2910 2910 struct cred *new) 2911 2911 {
+1 -1
security/smack/smack_lsm.c
··· 4908 4908 } 4909 4909 4910 4910 static int smack_dentry_create_files_as(struct dentry *dentry, int mode, 4911 - struct qstr *name, 4911 + const struct qstr *name, 4912 4912 const struct cred *old, 4913 4913 struct cred *new) 4914 4914 {