Re: broken hash use in fs/cifs/dfs_cache.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Al Viro <viro@xxxxxxxxxxxxxxxxxx> writes:
> Either the key comparison or the hash function is wrong here.  *IF* something
> external guarantees the full match, we don't need strcasecmp() - strcmp()
> would work.  Otherwise, the hash function needs to be changed.

I think here we need to make the hash case-insensitive.

Perhaps calling jhash() with lower-cased bytes like so (pseudo-code):

static inline unsigned int cache_entry_hash(const void *data, int size)
{
	unsigned int h = 0;
        u32 c;
        u8 *s = data;

        while (s < data+size) {
        	int len = decode_char(s, &c);
        	if (!len)
        		break;
		c = tolower(c);
                s += len;
                h = jhash(&c, sizeof(c), h);
        }

	return h % CACHE_HTABLE_SIZE;
}

Cheers,
-- 
Aurélien Aptel / SUSE Labs Samba Team
GPG: 1839 CB5F 9F5B FB9B AA97  8C99 03C8 A49B 521B D5D3
SUSE Software Solutions Germany GmbH, Maxfeldstr. 5, 90409 Nürnberg, DE
GF: Felix Imendörffer, Mary Higgins, Sri Rasiah HRB 247165 (AG München)





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux