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

vfs: make the string hashes salt the hash

We always mixed in the parent pointer into the dentry name hash, but we
did it late at lookup time. It turns out that we can simplify that
lookup-time action by salting the hash with the parent pointer early
instead of late.

A few other users of our string hashes also wanted to mix in their own
pointers into the hash, and those are updated to use the same mechanism.

Hash users that don't have any particular initial salt can just use the
NULL pointer as a no-salt.

Cc: Vegard Nossum <vegard.nossum@oracle.com>
Cc: George Spelvin <linux@sciencehorizons.net>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

+99 -89
+5 -3
drivers/staging/lustre/lustre/llite/statahead.c
··· 174 174 * Insert it into sai_entries tail when init. 175 175 */ 176 176 static struct ll_sa_entry * 177 - ll_sa_entry_alloc(struct ll_statahead_info *sai, __u64 index, 177 + ll_sa_entry_alloc(struct dentry *parent, 178 + struct ll_statahead_info *sai, __u64 index, 178 179 const char *name, int len) 179 180 { 180 181 struct ll_inode_info *lli; ··· 222 221 dname = (char *)entry + sizeof(struct ll_sa_entry); 223 222 memcpy(dname, name, len); 224 223 dname[len] = 0; 225 - entry->se_qstr.hash = full_name_hash(name, len); 224 + 225 + entry->se_qstr.hash = full_name_hash(parent, name, len); 226 226 entry->se_qstr.len = len; 227 227 entry->se_qstr.name = dname; 228 228 ··· 904 902 int rc; 905 903 int rc1; 906 904 907 - entry = ll_sa_entry_alloc(sai, sai->sai_index, entry_name, 905 + entry = ll_sa_entry_alloc(parent, sai, sai->sai_index, entry_name, 908 906 entry_name_len); 909 907 if (IS_ERR(entry)) 910 908 return;
+1 -1
fs/adfs/dir.c
··· 207 207 */ 208 208 qstr->len = i = name_len; 209 209 name = qstr->name; 210 - hash = init_name_hash(); 210 + hash = init_name_hash(parent); 211 211 while (i--) { 212 212 char c; 213 213
+4 -4
fs/affs/namei.c
··· 61 61 * Note: the dentry argument is the parent dentry. 62 62 */ 63 63 static inline int 64 - __affs_hash_dentry(struct qstr *qstr, toupper_t toupper, bool notruncate) 64 + __affs_hash_dentry(const struct dentry *dentry, struct qstr *qstr, toupper_t toupper, bool notruncate) 65 65 { 66 66 const u8 *name = qstr->name; 67 67 unsigned long hash; ··· 72 72 if (retval) 73 73 return retval; 74 74 75 - hash = init_name_hash(); 75 + hash = init_name_hash(dentry); 76 76 len = min(qstr->len, AFFSNAMEMAX); 77 77 for (; len > 0; name++, len--) 78 78 hash = partial_name_hash(toupper(*name), hash); ··· 84 84 static int 85 85 affs_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 86 86 { 87 - return __affs_hash_dentry(qstr, affs_toupper, 87 + return __affs_hash_dentry(dentry, qstr, affs_toupper, 88 88 affs_nofilenametruncate(dentry)); 89 89 90 90 } ··· 92 92 static int 93 93 affs_intl_hash_dentry(const struct dentry *dentry, struct qstr *qstr) 94 94 { 95 - return __affs_hash_dentry(qstr, affs_intl_toupper, 95 + return __affs_hash_dentry(dentry, qstr, affs_intl_toupper, 96 96 affs_nofilenametruncate(dentry)); 97 97 98 98 }
+1 -1
fs/autofs4/waitq.c
··· 397 397 } 398 398 } 399 399 qstr.name = name; 400 - qstr.hash = full_name_hash(name, qstr.len); 400 + qstr.hash = full_name_hash(dentry, name, qstr.len); 401 401 402 402 if (mutex_lock_interruptible(&sbi->wq_mutex)) { 403 403 kfree(qstr.name);
+2 -2
fs/ceph/inode.c
··· 1164 1164 1165 1165 dname.name = rinfo->dname; 1166 1166 dname.len = rinfo->dname_len; 1167 - dname.hash = full_name_hash(dname.name, dname.len); 1167 + dname.hash = full_name_hash(parent, dname.name, dname.len); 1168 1168 vino.ino = le64_to_cpu(rinfo->targeti.in->ino); 1169 1169 vino.snap = le64_to_cpu(rinfo->targeti.in->snapid); 1170 1170 retry_lookup: ··· 1508 1508 1509 1509 dname.name = rde->name; 1510 1510 dname.len = rde->name_len; 1511 - dname.hash = full_name_hash(dname.name, dname.len); 1511 + dname.hash = full_name_hash(parent, dname.name, dname.len); 1512 1512 1513 1513 vino.ino = le64_to_cpu(rde->inode.in->ino); 1514 1514 vino.snap = le64_to_cpu(rde->inode.in->snapid);
+1 -1
fs/ceph/mds_client.c
··· 3204 3204 WARN_ON(1); 3205 3205 goto release; /* hrm... */ 3206 3206 } 3207 - dname.hash = full_name_hash(dname.name, dname.len); 3207 + dname.hash = full_name_hash(parent, dname.name, dname.len); 3208 3208 dentry = d_lookup(parent, &dname); 3209 3209 dput(parent); 3210 3210 if (!dentry)
+1 -1
fs/cifs/dir.c
··· 856 856 wchar_t c; 857 857 int i, charlen; 858 858 859 - hash = init_name_hash(); 859 + hash = init_name_hash(dentry); 860 860 for (i = 0; i < q->len; i += charlen) { 861 861 charlen = codepage->char2uni(&q->name[i], q->len - i, &c); 862 862 /* error out if we can't convert the character */
+9 -12
fs/dcache.c
··· 104 104 105 105 static struct hlist_bl_head *dentry_hashtable __read_mostly; 106 106 107 - static inline struct hlist_bl_head *d_hash(const struct dentry *parent, 108 - unsigned int hash) 107 + static inline struct hlist_bl_head *d_hash(unsigned int hash) 109 108 { 110 - hash += (unsigned long) parent / L1_CACHE_BYTES; 111 109 return dentry_hashtable + hash_32(hash, d_hash_shift); 112 110 } 113 111 ··· 486 488 if (unlikely(IS_ROOT(dentry))) 487 489 b = &dentry->d_sb->s_anon; 488 490 else 489 - b = d_hash(dentry->d_parent, dentry->d_name.hash); 491 + b = d_hash(dentry->d_name.hash); 490 492 491 493 hlist_bl_lock(b); 492 494 __hlist_bl_del(&dentry->d_hash); ··· 1668 1670 struct qstr q; 1669 1671 1670 1672 q.name = name; 1671 - q.hash_len = hashlen_string(name); 1673 + q.hash_len = hashlen_string(parent, name); 1672 1674 return d_alloc(parent, &q); 1673 1675 } 1674 1676 EXPORT_SYMBOL(d_alloc_name); ··· 2092 2094 { 2093 2095 u64 hashlen = name->hash_len; 2094 2096 const unsigned char *str = name->name; 2095 - struct hlist_bl_head *b = d_hash(parent, hashlen_hash(hashlen)); 2097 + struct hlist_bl_head *b = d_hash(hashlen_hash(hashlen)); 2096 2098 struct hlist_bl_node *node; 2097 2099 struct dentry *dentry; 2098 2100 ··· 2209 2211 unsigned int len = name->len; 2210 2212 unsigned int hash = name->hash; 2211 2213 const unsigned char *str = name->name; 2212 - struct hlist_bl_head *b = d_hash(parent, hash); 2214 + struct hlist_bl_head *b = d_hash(hash); 2213 2215 struct hlist_bl_node *node; 2214 2216 struct dentry *found = NULL; 2215 2217 struct dentry *dentry; ··· 2289 2291 * calculate the standard hash first, as the d_op->d_hash() 2290 2292 * routine may choose to leave the hash value unchanged. 2291 2293 */ 2292 - name->hash = full_name_hash(name->name, name->len); 2294 + name->hash = full_name_hash(dir, name->name, name->len); 2293 2295 if (dir->d_flags & DCACHE_OP_HASH) { 2294 2296 int err = dir->d_op->d_hash(dir, name); 2295 2297 if (unlikely(err < 0)) ··· 2362 2364 2363 2365 static void _d_rehash(struct dentry * entry) 2364 2366 { 2365 - __d_rehash(entry, d_hash(entry->d_parent, entry->d_name.hash)); 2367 + __d_rehash(entry, d_hash(entry->d_name.hash)); 2366 2368 } 2367 2369 2368 2370 /** ··· 2819 2821 * for the same hash queue because of how unlikely it is. 2820 2822 */ 2821 2823 __d_drop(dentry); 2822 - __d_rehash(dentry, d_hash(target->d_parent, target->d_name.hash)); 2824 + __d_rehash(dentry, d_hash(target->d_name.hash)); 2823 2825 2824 2826 /* 2825 2827 * Unhash the target (d_delete() is not usable here). If exchanging ··· 2827 2829 */ 2828 2830 __d_drop(target); 2829 2831 if (exchange) { 2830 - __d_rehash(target, 2831 - d_hash(dentry->d_parent, dentry->d_name.hash)); 2832 + __d_rehash(target, d_hash(dentry->d_name.hash)); 2832 2833 } 2833 2834 2834 2835 /* Switch the names.. */
+2 -2
fs/efivarfs/super.c
··· 65 65 66 66 static int efivarfs_d_hash(const struct dentry *dentry, struct qstr *qstr) 67 67 { 68 - unsigned long hash = init_name_hash(); 68 + unsigned long hash = init_name_hash(dentry); 69 69 const unsigned char *s = qstr->name; 70 70 unsigned int len = qstr->len; 71 71 ··· 98 98 q.name = name; 99 99 q.len = strlen(name); 100 100 101 - err = efivarfs_d_hash(NULL, &q); 101 + err = efivarfs_d_hash(parent, &q); 102 102 if (err) 103 103 return ERR_PTR(err); 104 104
+1 -1
fs/fat/namei_msdos.c
··· 154 154 155 155 error = msdos_format_name(qstr->name, qstr->len, msdos_name, options); 156 156 if (!error) 157 - qstr->hash = full_name_hash(msdos_name, MSDOS_NAME); 157 + qstr->hash = full_name_hash(dentry, msdos_name, MSDOS_NAME); 158 158 return 0; 159 159 } 160 160
+2 -2
fs/fat/namei_vfat.c
··· 107 107 */ 108 108 static int vfat_hash(const struct dentry *dentry, struct qstr *qstr) 109 109 { 110 - qstr->hash = full_name_hash(qstr->name, vfat_striptail_len(qstr)); 110 + qstr->hash = full_name_hash(dentry, qstr->name, vfat_striptail_len(qstr)); 111 111 return 0; 112 112 } 113 113 ··· 127 127 name = qstr->name; 128 128 len = vfat_striptail_len(qstr); 129 129 130 - hash = init_name_hash(); 130 + hash = init_name_hash(dentry); 131 131 while (len--) 132 132 hash = partial_name_hash(nls_tolower(t, *name++), hash); 133 133 qstr->hash = end_name_hash(hash);
-2
fs/fuse/dev.c
··· 1525 1525 goto err; 1526 1526 fuse_copy_finish(cs); 1527 1527 buf[outarg.namelen] = 0; 1528 - name.hash = full_name_hash(name.name, name.len); 1529 1528 1530 1529 down_read(&fc->killsb); 1531 1530 err = -ENOENT; ··· 1575 1576 goto err; 1576 1577 fuse_copy_finish(cs); 1577 1578 buf[outarg.namelen] = 0; 1578 - name.hash = full_name_hash(name.name, name.len); 1579 1579 1580 1580 down_read(&fc->killsb); 1581 1581 err = -ENOENT;
+2 -1
fs/fuse/dir.c
··· 953 953 if (!dir) 954 954 goto unlock; 955 955 956 + name->hash = full_name_hash(dir, name->name, name->len); 956 957 entry = d_lookup(dir, name); 957 958 dput(dir); 958 959 if (!entry) ··· 1203 1202 1204 1203 fc = get_fuse_conn(dir); 1205 1204 1206 - name.hash = full_name_hash(name.name, name.len); 1205 + name.hash = full_name_hash(parent, name.name, name.len); 1207 1206 dentry = d_lookup(parent, &name); 1208 1207 if (!dentry) { 1209 1208 retry:
+1 -1
fs/hfs/string.c
··· 59 59 if (len > HFS_NAMELEN) 60 60 len = HFS_NAMELEN; 61 61 62 - hash = init_name_hash(); 62 + hash = init_name_hash(dentry); 63 63 for (; len; len--) 64 64 hash = partial_name_hash(caseorder[*name++], hash); 65 65 this->hash = end_name_hash(hash);
+1 -1
fs/hfsplus/unicode.c
··· 346 346 347 347 casefold = test_bit(HFSPLUS_SB_CASEFOLD, &HFSPLUS_SB(sb)->flags); 348 348 decompose = !test_bit(HFSPLUS_SB_NODECOMPOSE, &HFSPLUS_SB(sb)->flags); 349 - hash = init_name_hash(); 349 + hash = init_name_hash(dentry); 350 350 astr = str->name; 351 351 len = str->len; 352 352 while (len > 0) {
+1 -1
fs/hpfs/dentry.c
··· 26 26 /*return -ENOENT;*/ 27 27 x: 28 28 29 - hash = init_name_hash(); 29 + hash = init_name_hash(dentry); 30 30 for (i = 0; i < l; i++) 31 31 hash = partial_name_hash(hpfs_upcase(hpfs_sb(dentry->d_sb)->sb_cp_table,qstr->name[i]), hash); 32 32 qstr->hash = end_name_hash(hash);
+7 -7
fs/isofs/inode.c
··· 174 174 * Compute the hash for the isofs name corresponding to the dentry. 175 175 */ 176 176 static int 177 - isofs_hashi_common(struct qstr *qstr, int ms) 177 + isofs_hashi_common(const struct dentry *dentry, struct qstr *qstr, int ms) 178 178 { 179 179 const char *name; 180 180 int len; ··· 188 188 len--; 189 189 } 190 190 191 - hash = init_name_hash(); 191 + hash = init_name_hash(dentry); 192 192 while (len--) { 193 193 c = tolower(*name++); 194 194 hash = partial_name_hash(c, hash); ··· 231 231 static int 232 232 isofs_hashi(const struct dentry *dentry, struct qstr *qstr) 233 233 { 234 - return isofs_hashi_common(qstr, 0); 234 + return isofs_hashi_common(dentry, qstr, 0); 235 235 } 236 236 237 237 static int ··· 246 246 * Compute the hash for the isofs name corresponding to the dentry. 247 247 */ 248 248 static int 249 - isofs_hash_common(struct qstr *qstr, int ms) 249 + isofs_hash_common(const struct dentry *dentry, struct qstr *qstr, int ms) 250 250 { 251 251 const char *name; 252 252 int len; ··· 258 258 len--; 259 259 } 260 260 261 - qstr->hash = full_name_hash(name, len); 261 + qstr->hash = full_name_hash(dentry, name, len); 262 262 263 263 return 0; 264 264 } ··· 266 266 static int 267 267 isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr) 268 268 { 269 - return isofs_hash_common(qstr, 1); 269 + return isofs_hash_common(dentry, qstr, 1); 270 270 } 271 271 272 272 static int 273 273 isofs_hashi_ms(const struct dentry *dentry, struct qstr *qstr) 274 274 { 275 - return isofs_hashi_common(qstr, 1); 275 + return isofs_hashi_common(dentry, qstr, 1); 276 276 } 277 277 278 278 static int
+6 -2
fs/jffs2/dir.c
··· 81 81 struct jffs2_full_dirent *fd = NULL, *fd_list; 82 82 uint32_t ino = 0; 83 83 struct inode *inode = NULL; 84 + unsigned int nhash; 84 85 85 86 jffs2_dbg(1, "jffs2_lookup()\n"); 86 87 ··· 90 89 91 90 dir_f = JFFS2_INODE_INFO(dir_i); 92 91 92 + /* The 'nhash' on the fd_list is not the same as the dentry hash */ 93 + nhash = full_name_hash(NULL, target->d_name.name, target->d_name.len); 94 + 93 95 mutex_lock(&dir_f->sem); 94 96 95 97 /* NB: The 2.2 backport will need to explicitly check for '.' and '..' here */ 96 - for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= target->d_name.hash; fd_list = fd_list->next) { 97 - if (fd_list->nhash == target->d_name.hash && 98 + for (fd_list = dir_f->dents; fd_list && fd_list->nhash <= nhash; fd_list = fd_list->next) { 99 + if (fd_list->nhash == nhash && 98 100 (!fd || fd_list->version > fd->version) && 99 101 strlen(fd_list->name) == target->d_name.len && 100 102 !strncmp(fd_list->name, target->d_name.name, target->d_name.len)) {
+1 -1
fs/jffs2/readinode.c
··· 674 674 } 675 675 } 676 676 677 - fd->nhash = full_name_hash(fd->name, rd->nsize); 677 + fd->nhash = full_name_hash(NULL, fd->name, rd->nsize); 678 678 fd->next = NULL; 679 679 fd->name[rd->nsize] = '\0'; 680 680
+1 -1
fs/jffs2/scan.c
··· 1100 1100 fd->next = NULL; 1101 1101 fd->version = je32_to_cpu(rd->version); 1102 1102 fd->ino = je32_to_cpu(rd->ino); 1103 - fd->nhash = full_name_hash(fd->name, checkedlen); 1103 + fd->nhash = full_name_hash(NULL, fd->name, checkedlen); 1104 1104 fd->type = rd->type; 1105 1105 jffs2_add_fd_to_list(c, fd, &ic->scan_dents); 1106 1106
+1 -1
fs/jffs2/summary.c
··· 476 476 fd->next = NULL; 477 477 fd->version = je32_to_cpu(spd->version); 478 478 fd->ino = je32_to_cpu(spd->ino); 479 - fd->nhash = full_name_hash(fd->name, checkedlen); 479 + fd->nhash = full_name_hash(NULL, fd->name, checkedlen); 480 480 fd->type = spd->type; 481 481 482 482 jffs2_add_fd_to_list(c, fd, &ic->scan_dents);
+2 -2
fs/jffs2/write.c
··· 245 245 246 246 fd->version = je32_to_cpu(rd->version); 247 247 fd->ino = je32_to_cpu(rd->ino); 248 - fd->nhash = full_name_hash(name, namelen); 248 + fd->nhash = full_name_hash(NULL, name, namelen); 249 249 fd->type = rd->type; 250 250 memcpy(fd->name, name, namelen); 251 251 fd->name[namelen]=0; ··· 598 598 jffs2_add_fd_to_list(c, fd, &dir_f->dents); 599 599 mutex_unlock(&dir_f->sem); 600 600 } else { 601 - uint32_t nhash = full_name_hash(name, namelen); 601 + uint32_t nhash = full_name_hash(NULL, name, namelen); 602 602 603 603 fd = dir_f->dents; 604 604 /* We don't actually want to reserve any space, but we do
+1 -1
fs/jfs/namei.c
··· 1564 1564 unsigned long hash; 1565 1565 int i; 1566 1566 1567 - hash = init_name_hash(); 1567 + hash = init_name_hash(dir); 1568 1568 for (i=0; i < this->len; i++) 1569 1569 hash = partial_name_hash(tolower(this->name[i]), hash); 1570 1570 this->hash = end_name_hash(hash);
+2 -2
fs/kernfs/dir.c
··· 336 336 */ 337 337 static unsigned int kernfs_name_hash(const char *name, const void *ns) 338 338 { 339 - unsigned long hash = init_name_hash(); 339 + unsigned long hash = init_name_hash(ns); 340 340 unsigned int len = strlen(name); 341 341 while (len--) 342 342 hash = partial_name_hash(*name++, hash); 343 - hash = (end_name_hash(hash) ^ hash_ptr((void *)ns, 31)); 343 + hash = end_name_hash(hash); 344 344 hash &= 0x7fffffffU; 345 345 /* Reserve hash numbers 0, 1 and INT_MAX for magic directory entries */ 346 346 if (hash < 2)
+25 -17
fs/namei.c
··· 1890 1890 * payload bytes, to match the way that hash_name() iterates until it 1891 1891 * finds the delimiter after the name. 1892 1892 */ 1893 - unsigned int full_name_hash(const char *name, unsigned int len) 1893 + unsigned int full_name_hash(const void *salt, const char *name, unsigned int len) 1894 1894 { 1895 - unsigned long a, x = 0, y = 0; 1895 + unsigned long a, x = 0, y = (unsigned long)salt; 1896 1896 1897 1897 for (;;) { 1898 1898 if (!len) ··· 1911 1911 EXPORT_SYMBOL(full_name_hash); 1912 1912 1913 1913 /* Return the "hash_len" (hash and length) of a null-terminated string */ 1914 - u64 hashlen_string(const char *name) 1914 + u64 hashlen_string(const void *salt, const char *name) 1915 1915 { 1916 - unsigned long a = 0, x = 0, y = 0, adata, mask, len; 1916 + unsigned long a = 0, x = 0, y = (unsigned long)salt; 1917 + unsigned long adata, mask, len; 1917 1918 const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS; 1918 1919 1919 - len = -sizeof(unsigned long); 1920 + len = 0; 1921 + goto inside; 1922 + 1920 1923 do { 1921 1924 HASH_MIX(x, y, a); 1922 1925 len += sizeof(unsigned long); 1926 + inside: 1923 1927 a = load_unaligned_zeropad(name+len); 1924 1928 } while (!has_zero(a, &adata, &constants)); 1925 1929 ··· 1939 1935 * Calculate the length and hash of the path component, and 1940 1936 * return the "hash_len" as the result. 1941 1937 */ 1942 - static inline u64 hash_name(const char *name) 1938 + static inline u64 hash_name(const void *salt, const char *name) 1943 1939 { 1944 - unsigned long a = 0, b, x = 0, y = 0, adata, bdata, mask, len; 1940 + unsigned long a = 0, b, x = 0, y = (unsigned long)salt; 1941 + unsigned long adata, bdata, mask, len; 1945 1942 const struct word_at_a_time constants = WORD_AT_A_TIME_CONSTANTS; 1946 1943 1947 - len = -sizeof(unsigned long); 1944 + len = 0; 1945 + goto inside; 1946 + 1948 1947 do { 1949 1948 HASH_MIX(x, y, a); 1950 1949 len += sizeof(unsigned long); 1950 + inside: 1951 1951 a = load_unaligned_zeropad(name+len); 1952 1952 b = a ^ REPEAT_BYTE('/'); 1953 1953 } while (!(has_zero(a, &adata, &constants) | has_zero(b, &bdata, &constants))); ··· 1967 1959 #else /* !CONFIG_DCACHE_WORD_ACCESS: Slow, byte-at-a-time version */ 1968 1960 1969 1961 /* Return the hash of a string of known length */ 1970 - unsigned int full_name_hash(const char *name, unsigned int len) 1962 + unsigned int full_name_hash(const void *salt, const char *name, unsigned int len) 1971 1963 { 1972 - unsigned long hash = init_name_hash(); 1964 + unsigned long hash = init_name_hash(salt); 1973 1965 while (len--) 1974 1966 hash = partial_name_hash((unsigned char)*name++, hash); 1975 1967 return end_name_hash(hash); ··· 1977 1969 EXPORT_SYMBOL(full_name_hash); 1978 1970 1979 1971 /* Return the "hash_len" (hash and length) of a null-terminated string */ 1980 - u64 hashlen_string(const char *name) 1972 + u64 hashlen_string(const void *salt, const char *name) 1981 1973 { 1982 - unsigned long hash = init_name_hash(); 1974 + unsigned long hash = init_name_hash(salt); 1983 1975 unsigned long len = 0, c; 1984 1976 1985 1977 c = (unsigned char)*name; ··· 1996 1988 * We know there's a real path component here of at least 1997 1989 * one character. 1998 1990 */ 1999 - static inline u64 hash_name(const char *name) 1991 + static inline u64 hash_name(const void *salt, const char *name) 2000 1992 { 2001 - unsigned long hash = init_name_hash(); 1993 + unsigned long hash = init_name_hash(salt); 2002 1994 unsigned long len = 0, c; 2003 1995 2004 1996 c = (unsigned char)*name; ··· 2038 2030 if (err) 2039 2031 return err; 2040 2032 2041 - hash_len = hash_name(name); 2033 + hash_len = hash_name(nd->path.dentry, name); 2042 2034 2043 2035 type = LAST_NORM; 2044 2036 if (name[0] == '.') switch (hashlen_len(hash_len)) { ··· 2444 2436 2445 2437 this.name = name; 2446 2438 this.len = len; 2447 - this.hash = full_name_hash(name, len); 2439 + this.hash = full_name_hash(base, name, len); 2448 2440 if (!len) 2449 2441 return ERR_PTR(-EACCES); 2450 2442 ··· 2497 2489 2498 2490 this.name = name; 2499 2491 this.len = len; 2500 - this.hash = full_name_hash(name, len); 2492 + this.hash = full_name_hash(base, name, len); 2501 2493 if (!len) 2502 2494 return ERR_PTR(-EACCES); 2503 2495
+1 -1
fs/ncpfs/dir.c
··· 139 139 int i; 140 140 141 141 t = NCP_IO_TABLE(sb); 142 - hash = init_name_hash(); 142 + hash = init_name_hash(dentry); 143 143 for (i=0; i<this->len ; i++) 144 144 hash = partial_name_hash(ncp_tolower(t, this->name[i]), 145 145 hash);
+2 -2
fs/nfs/dir.c
··· 232 232 * in a page cache page which kmemleak does not scan. 233 233 */ 234 234 kmemleak_not_leak(string->name); 235 - string->hash = full_name_hash(name, len); 235 + string->hash = full_name_hash(NULL, name, len); 236 236 return 0; 237 237 } 238 238 ··· 497 497 if (filename.len == 2 && filename.name[1] == '.') 498 498 return; 499 499 } 500 - filename.hash = full_name_hash(filename.name, filename.len); 500 + filename.hash = full_name_hash(parent, filename.name, filename.len); 501 501 502 502 dentry = d_lookup(parent, &filename); 503 503 again:
+1 -1
fs/ntfs/namei.c
··· 253 253 err = (signed)nls_name.len; 254 254 goto err_out; 255 255 } 256 - nls_name.hash = full_name_hash(nls_name.name, nls_name.len); 256 + nls_name.hash = full_name_hash(dent, nls_name.name, nls_name.len); 257 257 258 258 dent = d_add_ci(dent, dent_inode, &nls_name); 259 259 kfree(nls_name.name);
+1 -1
fs/ocfs2/dlm/dlmcommon.h
··· 47 47 #define DLM_HASH_BUCKETS (DLM_HASH_PAGES * DLM_BUCKETS_PER_PAGE) 48 48 49 49 /* Intended to make it easier for us to switch out hash functions */ 50 - #define dlm_lockid_hash(_n, _l) full_name_hash(_n, _l) 50 + #define dlm_lockid_hash(_n, _l) full_name_hash(NULL, _n, _l) 51 51 52 52 enum dlm_mle_type { 53 53 DLM_MLE_BLOCK = 0,
+1 -1
fs/proc/proc_sysctl.c
··· 623 623 624 624 qname.name = table->procname; 625 625 qname.len = strlen(table->procname); 626 - qname.hash = full_name_hash(qname.name, qname.len); 626 + qname.hash = full_name_hash(dir, qname.name, qname.len); 627 627 628 628 child = d_lookup(dir, &qname); 629 629 if (!child) {
+1 -1
fs/sysv/namei.c
··· 33 33 function. */ 34 34 if (qstr->len > SYSV_NAMELEN) { 35 35 qstr->len = SYSV_NAMELEN; 36 - qstr->hash = full_name_hash(qstr->name, qstr->len); 36 + qstr->hash = full_name_hash(dentry, qstr->name, qstr->len); 37 37 } 38 38 return 0; 39 39 }
+3 -3
include/linux/stringhash.h
··· 34 34 */ 35 35 36 36 /* Hash courtesy of the R5 hash in reiserfs modulo sign bits */ 37 - #define init_name_hash() 0 37 + #define init_name_hash(salt) (unsigned long)(salt) 38 38 39 39 /* partial hash update function. Assume roughly 4 bits per character */ 40 40 static inline unsigned long ··· 60 60 * 61 61 * If not set, this falls back to a wrapper around the preceding. 62 62 */ 63 - extern unsigned int __pure full_name_hash(const char *, unsigned int); 63 + extern unsigned int __pure full_name_hash(const void *salt, const char *, unsigned int); 64 64 65 65 /* 66 66 * A hash_len is a u64 with the hash of a string in the low ··· 71 71 #define hashlen_create(hash, len) ((u64)(len)<<32 | (u32)(hash)) 72 72 73 73 /* Return the "hash_len" (hash and length) of a null-terminated string */ 74 - extern u64 __pure hashlen_string(const char *name); 74 + extern u64 __pure hashlen_string(const void *salt, const char *name); 75 75 76 76 #endif /* __LINUX_STRINGHASH_H */
+2 -2
include/linux/sunrpc/svcauth.h
··· 172 172 */ 173 173 static inline unsigned long hash_str(char const *name, int bits) 174 174 { 175 - return hashlen_hash(hashlen_string(name)) >> (32 - bits); 175 + return hashlen_hash(hashlen_string(NULL, name)) >> (32 - bits); 176 176 } 177 177 178 178 static inline unsigned long hash_mem(char const *buf, int length, int bits) 179 179 { 180 - return full_name_hash(buf, length) >> (32 - bits); 180 + return full_name_hash(NULL, buf, length) >> (32 - bits); 181 181 } 182 182 183 183 #endif /* __KERNEL__ */
+2 -2
lib/test_hash.c
··· 155 155 buf[j] = '\0'; 156 156 157 157 for (i = 0; i <= j; i++) { 158 - u64 hashlen = hashlen_string(buf+i); 159 - u32 h0 = full_name_hash(buf+i, j-i); 158 + u64 hashlen = hashlen_string(buf+i, buf+i); 159 + u32 h0 = full_name_hash(buf+i, buf+i, j-i); 160 160 161 161 /* Check that hashlen_string gets the length right */ 162 162 if (hashlen_len(hashlen) != j-i) {
+1 -1
net/core/dev.c
··· 196 196 197 197 static inline struct hlist_head *dev_name_hash(struct net *net, const char *name) 198 198 { 199 - unsigned int hash = full_name_hash(name, strnlen(name, IFNAMSIZ)); 199 + unsigned int hash = full_name_hash(net, name, strnlen(name, IFNAMSIZ)); 200 200 201 201 return &net->dev_name_head[hash_32(hash, NETDEV_HASHBITS)]; 202 202 }
+2 -2
security/smack/smack_access.c
··· 413 413 unsigned int hash; 414 414 struct hlist_head *head; 415 415 416 - hash = full_name_hash(skp->smk_known, strlen(skp->smk_known)); 416 + hash = full_name_hash(NULL, skp->smk_known, strlen(skp->smk_known)); 417 417 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; 418 418 419 419 hlist_add_head_rcu(&skp->smk_hashed, head); ··· 433 433 struct hlist_head *head; 434 434 struct smack_known *skp; 435 435 436 - hash = full_name_hash(string, strlen(string)); 436 + hash = full_name_hash(NULL, string, strlen(string)); 437 437 head = &smack_known_hash[hash & (SMACK_HASH_SLOTS - 1)]; 438 438 439 439 hlist_for_each_entry_rcu(skp, head, smk_hashed)
+1 -1
security/tomoyo/memory.c
··· 154 154 if (!name) 155 155 return NULL; 156 156 len = strlen(name) + 1; 157 - hash = full_name_hash((const unsigned char *) name, len - 1); 157 + hash = full_name_hash(NULL, (const unsigned char *) name, len - 1); 158 158 head = &tomoyo_name_list[hash_long(hash, TOMOYO_HASH_BITS)]; 159 159 if (mutex_lock_interruptible(&tomoyo_policy_lock)) 160 160 return NULL;
+1 -1
security/tomoyo/util.c
··· 666 666 ptr->const_len = tomoyo_const_part_length(name); 667 667 ptr->is_dir = len && (name[len - 1] == '/'); 668 668 ptr->is_patterned = (ptr->const_len < len); 669 - ptr->hash = full_name_hash(name, len); 669 + ptr->hash = full_name_hash(NULL, name, len); 670 670 } 671 671 672 672 /**