Module Name:    src
Committed By:   riastradh
Date:           Thu Jun  3 01:00:24 UTC 2021

Modified Files:
        src/sys/kern: kern_ksyms.c

Log Message:
ksyms(4): Don't skip symbol tables that are soon to be freed, take 2.

They will not actually be freed until /dev/ksyms is closed, so
continued access to them remains kosher.

The previous change was busted because of an off-by-one error in a
previous previous change's iteration over the symtabs; that error has
since been corrected.


To generate a diff of this commit:
cvs rdiff -u -r1.95 -r1.96 src/sys/kern/kern_ksyms.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/kern_ksyms.c
diff -u src/sys/kern/kern_ksyms.c:1.95 src/sys/kern/kern_ksyms.c:1.96
--- src/sys/kern/kern_ksyms.c:1.95	Thu Jun  3 01:00:15 2021
+++ src/sys/kern/kern_ksyms.c	Thu Jun  3 01:00:24 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_ksyms.c,v 1.95 2021/06/03 01:00:15 riastradh Exp $	*/
+/*	$NetBSD: kern_ksyms.c,v 1.96 2021/06/03 01:00:24 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.95 2021/06/03 01:00:15 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_ksyms.c,v 1.96 2021/06/03 01:00:24 riastradh Exp $");
 
 #if defined(_KERNEL) && defined(_KERNEL_OPT)
 #include "opt_copy_symtab.h"
@@ -1089,8 +1089,6 @@ ksymsread(dev_t dev, struct uio *uio, in
 	for (st = TAILQ_FIRST(&ksyms_symtabs);
 	     ;
 	     st = TAILQ_NEXT(st, sd_queue)) {
-		if (__predict_false(st->sd_gone))
-			continue;
 		if (uio->uio_resid == 0)
 			return 0;
 		if (uio->uio_offset <= st->sd_symsize + filepos) {
@@ -1108,13 +1106,11 @@ ksymsread(dev_t dev, struct uio *uio, in
 	/*
 	 * Copy out the string table
 	 */
-	KASSERT(filepos <= sizeof(struct ksyms_hdr) +
+	KASSERT(filepos == sizeof(struct ksyms_hdr) +
 	    ksyms_hdr.kh_shdr[SYMTAB].sh_size);
 	for (st = TAILQ_FIRST(&ksyms_symtabs);
 	     ;
 	     st = TAILQ_NEXT(st, sd_queue)) {
-		if (__predict_false(st->sd_gone))
-			continue;
 		if (uio->uio_resid == 0)
 			return 0;
 		if (uio->uio_offset <= st->sd_strsize + filepos) {

Reply via email to