Skip to content

Commit

Permalink
Pacify a syzbot complaint about bit shifting.
Browse files Browse the repository at this point in the history
Reported-by: syzbot+dd5df915b2cd2f3f3da5@syzkaller.appspotmail.com
  • Loading branch information
doranand committed Mar 23, 2020
1 parent ccf2a9f commit 395a577
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
18 changes: 9 additions & 9 deletions sys/kern/vfs_cache.c
@@ -1,4 +1,4 @@
/* $NetBSD: vfs_cache.c,v 1.128 2020/03/22 14:38:37 ad Exp $ */
/* $NetBSD: vfs_cache.c,v 1.129 2020/03/23 18:33:43 ad Exp $ */

/*-
* Copyright (c) 2008, 2019, 2020 The NetBSD Foundation, Inc.
Expand Down Expand Up @@ -172,7 +172,7 @@
*/

#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.128 2020/03/22 14:38:37 ad Exp $");
__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.129 2020/03/23 18:33:43 ad Exp $");

#define __NAMECACHE_PRIVATE
#ifdef _KERNEL_OPT
Expand Down Expand Up @@ -318,7 +318,7 @@ static int
cache_compare_key(void *context, const void *n, const void *k)
{
const struct namecache *ncp = n;
const int64_t key = *(const int64_t *)k;
const uint64_t key = *(const uint64_t *)k;

if (ncp->nc_key < key) {
return -1;
Expand All @@ -334,10 +334,10 @@ cache_compare_key(void *context, const void *n, const void *k)
* the key value to try and improve uniqueness, and so that length doesn't
* need to be compared separately for string comparisons.
*/
static inline int64_t
static inline uint64_t
cache_key(const char *name, size_t nlen)
{
int64_t key;
uint64_t key;

KASSERT(nlen <= USHRT_MAX);

Expand Down Expand Up @@ -418,7 +418,7 @@ cache_remove(struct namecache *ncp, const bool dir2node)
*/
static struct namecache * __noinline
cache_lookup_entry(struct vnode *dvp, const char *name, size_t namelen,
int64_t key)
uint64_t key)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct rb_node *node = dvi->vi_nc_tree.rbt_root;
Expand Down Expand Up @@ -520,7 +520,7 @@ cache_lookup(struct vnode *dvp, const char *name, size_t namelen,
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
struct vnode *vp;
int64_t key;
uint64_t key;
int error;
bool hit;
krw_t op;
Expand Down Expand Up @@ -650,7 +650,7 @@ cache_lookup_linked(struct vnode *dvp, const char *name, size_t namelen,
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
int64_t key;
uint64_t key;
int error;

/* Establish default results. */
Expand Down Expand Up @@ -1169,7 +1169,7 @@ cache_purge_name(struct vnode *dvp, const char *name, size_t namelen)
{
vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
struct namecache *ncp;
int64_t key;
uint64_t key;

SDT_PROBE(vfs, namecache, purge, name, name, namelen, 0, 0, 0);

Expand Down
6 changes: 3 additions & 3 deletions sys/sys/namei.src
@@ -1,4 +1,4 @@
/* $NetBSD: namei.src,v 1.49 2020/03/22 14:38:37 ad Exp $ */
/* $NetBSD: namei.src,v 1.50 2020/03/23 18:33:43 ad Exp $ */

/*
* Copyright (c) 1985, 1989, 1991, 1993
Expand Down Expand Up @@ -216,13 +216,13 @@ NAMEIFL PARAMASK 0x02ee300 /* mask of parameter descriptors */
struct nchnode;
struct namecache {
struct rb_node nc_tree; /* d red-black tree, must be first */
int64_t nc_key; /* - hash key */
uint64_t nc_key; /* - hash key */
TAILQ_ENTRY(namecache) nc_list; /* v vp's list of cache entries */
TAILQ_ENTRY(namecache) nc_lru; /* l pseudo-lru chain */
struct vnode *nc_dvp; /* - vnode of parent of name */
struct vnode *nc_vp; /* - vnode the name refers to */
int nc_lrulist; /* l which LRU list its on */
short nc_nlen; /* - length of the name */
u_short nc_nlen; /* - length of the name */
char nc_whiteout; /* - true if a whiteout */
char nc_name[41]; /* - segment name */
};
Expand Down

0 comments on commit 395a577

Please sign in to comment.