NetBSD-Bugs archive

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

Re: kern/58972: madvise(MADV_WILLNEED) on EFI genfb framebuffer crashes kernel



The following reply was made to PR kern/58972; it has been noted by GNATS.

From: RVP <rvp%SDF.ORG@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc: 
Subject: Re: kern/58972: madvise(MADV_WILLNEED) on EFI genfb framebuffer
 crashes kernel
Date: Wed, 8 Jan 2025 06:23:16 +0000 (UTC)

 On Tue, 7 Jan 2025, rvp%SDF.ORG@localhost wrote:
 
 > Doing madvise() however, crashes the kernel (as _any_ user--no root reqd.)
 > in uvm_readahead().
 >
 
 The exact log is:
 
 ```
 [   131.111980] prevented execution of 0x0 (SMEP)
 [   131.111980] fatal page fault in supervisor mode
 [   131.111980] trap type 6 code 0x10 rip 0 cs 0x8 rflags 0x10246 cr2 0 ilevel 0 rsp 0xffffd1026969dea8
 [   131.111980] curlwp 0xffffa2762ee7b400 pid 346.346 lowest kstack 0xffffd102696992c0
 [   131.111980] panic: trap
 [   131.111980] cpu1: Begin traceback...
 [   131.111980] vpanic() at netbsd:vpanic+0x171
 [   131.111980] panic() at netbsd:panic+0x3c
 [   131.111980] trap() at netbsd:trap+0xb44
 [   131.111980] --- trap (number 6) ---
 [   131.111980] ?() at 0
 [   131.111980] uvm_readahead() at netbsd:uvm_readahead+0x3d
 [   131.111980] uvm_map_willneed() at netbsd:uvm_map_willneed+0xdb
 [   131.111980] syscall() at netbsd:syscall+0x112
 [   131.111980] --- syscall (number 75) ---
 [   131.111980] netbsd:syscall+0x112:
 [   131.111980] cpu1: End traceback...
 [   131.111980] dumping to dev 168,10 (offset=76055, size=2038493):
 ```
 
 > Mebbe madvise() should do nothing on framebuffer devices (like on Linux)?
 >
 
 ... and, this seems to fix it:
 
 
 ```
 diff -urN a/src/sys/uvm/uvm_readahead.c b/src/sys/uvm/uvm_readahead.c
 --- a/src/sys/uvm/uvm_readahead.c	2023-09-23 18:21:12.000000000 +0000
 +++ b/src/sys/uvm/uvm_readahead.c	2025-01-07 23:26:06.084960295 +0000
 @@ -350,6 +350,9 @@
   uvm_readahead(struct uvm_object *uobj, off_t off, off_t size)
   {
 
 +	if (uobj->pgops->pgo_get == NULL)
 +		return EOPNOTSUPP;
 +
   	/*
   	 * don't allow too much read-ahead.
   	 */
 ```
 
 -RVP
 


Home | Main Index | Thread Index | Old Index