Source-Changes-HG archive

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

[src/trunk]: src/sys Pacify a syzbot complaint about bit shifting.



details:   https://anonhg.NetBSD.org/src/rev/558599fc8ca4
branches:  trunk
changeset: 1008469:558599fc8ca4
user:      ad <ad%NetBSD.org@localhost>
date:      Mon Mar 23 18:33:43 2020 +0000

description:
Pacify a syzbot complaint about bit shifting.

Reported-by: syzbot+dd5df915b2cd2f3f3da5%syzkaller.appspotmail.com@localhost

diffstat:

 sys/kern/vfs_cache.c |  18 +++++++++---------
 sys/sys/namei.src    |   6 +++---
 2 files changed, 12 insertions(+), 12 deletions(-)

diffs (101 lines):

diff -r d7c9efad840e -r 558599fc8ca4 sys/kern/vfs_cache.c
--- a/sys/kern/vfs_cache.c      Mon Mar 23 16:38:29 2020 +0000
+++ b/sys/kern/vfs_cache.c      Mon Mar 23 18:33:43 2020 +0000
@@ -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 @@
 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 @@
  * 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 @@
  */
 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 @@
        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 @@
 {
        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 @@
 {
        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);
 
diff -r d7c9efad840e -r 558599fc8ca4 sys/sys/namei.src
--- a/sys/sys/namei.src Mon Mar 23 16:38:29 2020 +0000
+++ b/sys/sys/namei.src Mon Mar 23 18:33:43 2020 +0000
@@ -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 @@
 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 */
 };



Home | Main Index | Thread Index | Old Index