Module Name:    src
Committed By:   ad
Date:           Mon Mar 23 18:33:43 UTC 2020

Modified Files:
        src/sys/kern: vfs_cache.c
        src/sys/sys: namei.src

Log Message:
Pacify a syzbot complaint about bit shifting.

Reported-by: syzbot+dd5df915b2cd2f3f3...@syzkaller.appspotmail.com


To generate a diff of this commit:
cvs rdiff -u -r1.128 -r1.129 src/sys/kern/vfs_cache.c
cvs rdiff -u -r1.49 -r1.50 src/sys/sys/namei.src

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/vfs_cache.c
diff -u src/sys/kern/vfs_cache.c:1.128 src/sys/kern/vfs_cache.c:1.129
--- src/sys/kern/vfs_cache.c:1.128	Sun Mar 22 14:38:37 2020
+++ src/sys/kern/vfs_cache.c	Mon Mar 23 18:33:43 2020
@@ -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.
@@ -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
@@ -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;
@@ -334,10 +334,10 @@ cache_compare_key(void *context, const v
  * 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);
 
@@ -418,7 +418,7 @@ cache_remove(struct namecache *ncp, cons
  */
 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;
@@ -520,7 +520,7 @@ cache_lookup(struct vnode *dvp, const ch
 	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;
@@ -650,7 +650,7 @@ cache_lookup_linked(struct vnode *dvp, c
 {
 	vnode_impl_t *dvi = VNODE_TO_VIMPL(dvp);
 	struct namecache *ncp;
-	int64_t key;
+	uint64_t key;
 	int error;
 
 	/* Establish default results. */
@@ -1169,7 +1169,7 @@ cache_purge_name(struct vnode *dvp, cons
 {
 	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);
 

Index: src/sys/sys/namei.src
diff -u src/sys/sys/namei.src:1.49 src/sys/sys/namei.src:1.50
--- src/sys/sys/namei.src:1.49	Sun Mar 22 14:38:37 2020
+++ src/sys/sys/namei.src	Mon Mar 23 18:33:43 2020
@@ -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
@@ -216,13 +216,13 @@ NAMEIFL	PARAMASK	0x02ee300	/* mask of pa
 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 */
 };

Reply via email to