Module Name: src
Committed By: uwe
Date: Sat Dec 12 18:35:59 UTC 2020
Modified Files:
src/sys/kern: vfs_cache.c
Log Message:
vfs_cache - do not write outside allocated memory.
In cache_cpu_init allocate struct nchcpu, not struct nchstats_percpu.
cache_update_stats expects the former (that contains two percpu
structs). Stat updates where smashing whatever was in the next pool
allocation.
Reported by martin@ as crashes in ptyfs on Krups.
To generate a diff of this commit:
cvs rdiff -u -r1.147 -r1.148 src/sys/kern/vfs_cache.c
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.147 src/sys/kern/vfs_cache.c:1.148
--- src/sys/kern/vfs_cache.c:1.147 Thu Jun 4 03:08:33 2020
+++ src/sys/kern/vfs_cache.c Sat Dec 12 18:35:59 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: vfs_cache.c,v 1.147 2020/06/04 03:08:33 riastradh Exp $ */
+/* $NetBSD: vfs_cache.c,v 1.148 2020/12/12 18:35:59 uwe 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.147 2020/06/04 03:08:33 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vfs_cache.c,v 1.148 2020/12/12 18:35:59 uwe Exp $");
#define __NAMECACHE_PRIVATE
#ifdef _KERNEL_OPT
@@ -1106,8 +1106,7 @@ cache_cpu_init(struct cpu_info *ci)
void *p;
size_t sz;
- sz = roundup2(sizeof(struct nchstats_percpu), coherency_unit) +
- coherency_unit;
+ sz = roundup2(sizeof(struct nchcpu), coherency_unit) + coherency_unit;
p = kmem_zalloc(sz, KM_SLEEP);
ci->ci_data.cpu_nch = (void *)roundup2((uintptr_t)p, coherency_unit);
}