Index: sys/conf/files =================================================================== --- sys/conf/files +++ sys/conf/files @@ -647,8 +647,8 @@ ipsec_support | zfs crypto/skein/skein.c optional crypto | zfs crypto/skein/skein_block.c optional crypto | zfs -crypto/siphash/siphash.c optional inet | inet6 -crypto/siphash/siphash_test.c optional inet | inet6 +crypto/siphash/siphash.c standard +crypto/siphash/siphash_test.c standard ddb/db_access.c optional ddb ddb/db_break.c optional ddb ddb/db_capture.c optional ddb Index: sys/fs/devfs/devfs_devs.c =================================================================== --- sys/fs/devfs/devfs_devs.c +++ sys/fs/devfs/devfs_devs.c @@ -52,6 +52,8 @@ #include +#include + /* * The one true (but secret) list of active devices in the system. * Locked by dev_lock()/devmtx @@ -75,6 +77,8 @@ SYSCTL_UINT(_vfs_devfs, OID_AUTO, rule_depth, CTLFLAG_RW, &devfs_rule_depth, 0, "Max depth of ruleset include"); +static uint8_t hash_key[16] = {'S', 'I', 'P', 'H', 'A', 'S', 'H', 'D', 'E', 'V', 'F', 'S', 'K', 'E', 'Y', 0x00}; + /* * Helper sysctl for devname(3). We're given a dev_t and return the * name, if any, registered by the device driver. @@ -153,15 +157,24 @@ int devfs_dev_exists(const char *name) { + SIPHASH_CTX ctx; + uint64_t hash; struct cdev_priv *cdp; + SipHash24_Init(&ctx); + SipHash_SetKey(&ctx, hash_key); + SipHash_Update(&ctx, name, sizeof(name)); + SipHash_Final((u_int8_t *)&hash, &ctx); + mtx_assert(&devmtx, MA_OWNED); TAILQ_FOREACH(cdp, &cdevp_list, cdp_list) { if ((cdp->cdp_flags & CDP_ACTIVE) == 0) continue; - if (strcmp(cdp->cdp_c.si_name, name) == 0) - return (1); + if (cdp->cdp_hash == hash) { + if (strcmp(cdp->cdp_c.si_name, name) == 0) + return (1); + } } if (devfs_dir_find(name) != 0) return (1); @@ -696,6 +709,7 @@ void devfs_create(struct cdev *dev) { + SIPHASH_CTX ctx; struct cdev_priv *cdp; mtx_assert(&devmtx, MA_OWNED); @@ -704,6 +718,11 @@ cdp->cdp_inode = alloc_unrl(devfs_inos); dev_refl(dev); + SipHash24_Init(&ctx); + SipHash_SetKey(&ctx, hash_key); + SipHash_Update(&ctx, dev->si_name, sizeof(dev->si_name)); + SipHash_Final((u_int8_t *)&cdp->cdp_hash, &ctx); + TAILQ_INSERT_TAIL(&cdevp_list, cdp, cdp_list); devfs_generation++; } Index: sys/fs/devfs/devfs_int.h =================================================================== --- sys/fs/devfs/devfs_int.h +++ sys/fs/devfs/devfs_int.h @@ -69,6 +69,7 @@ void (*cdp_dtr_cb)(void *); void *cdp_dtr_cb_arg; + uint64_t cdp_hash; LIST_HEAD(, cdev_privdata) cdp_fdpriv; };