NetBSD Problem Report #60082

From www@netbsd.org  Sun Mar 15 03:30:39 2026
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256
	 client-signature RSA-PSS (2048 bits) client-digest SHA256)
	(Client CN "mail.netbsd.org", Issuer "R12" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id EAD3D1A9243
	for <gnats-bugs@gnats.NetBSD.org>; Sun, 15 Mar 2026 03:30:38 +0000 (UTC)
Message-Id: <20260315033038.092F21A9244@mollari.NetBSD.org>
Date: Sun, 15 Mar 2026 03:30:37 +0000 (UTC)
From: imuwoto@gmail.com
Reply-To: imuwoto@gmail.com
To: gnats-bugs@NetBSD.org
Subject: swap encryption corrupt data
X-Send-Pr-Version: www-1.0
X-From4GNATS: "imuwoto@gmail.com via gnats" <gnats-admin@NetBSD.org>

>Number:         60082
>Notify-List:    riastradh@NetBSD.org
>Category:       kern
>Synopsis:       swap encryption corrupt data
>Confidential:   no
>Severity:       serious
>Priority:       high
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 15 03:35:00 +0000 2026
>Last-Modified:  Sat Jun 27 15:00:08 +0000 2026
>Originator:     YAMAMOTO Takashi
>Release:        -current
>Organization:
>Environment:
amd64
>Description:
when paging out, uvm_swap_io encrypts the page contents
and then issues write requests to swapdev. if the write fails
for some reason, the pageout will be cancelled. but it leaves
the data in the pages encrypted.
note: we are in the pagedaemon context and some kind of errors
are "common".  eg. VOP_BMAP has special cases for the pagedaemon
to return ENOMEM.

>How-To-Repeat:
use swap.
>Fix:

>Release-Note:

>Audit-Trail:

From: Takashi YAMAMOTO <yamt9999@gmail.com>
To: gnats-bugs@netbsd.org
Cc: kern-bug-people@netbsd.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org
Subject: Re: kern/60082: swap encryption corrupt data
Date: Tue, 24 Mar 2026 21:44:18 +0900

 i'm testing this:
 https://github.com/yamt/netbsd-src/commit/61c72a69444bd76a202a562c458999643a1aa4fd

From: "YAMAMOTO Takashi" <yamt@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60082 CVS commit: src/sys/uvm
Date: Fri, 27 Mar 2026 07:14:46 +0000

 Module Name:	src
 Committed By:	yamt
 Date:		Fri Mar 27 07:14:46 UTC 2026

 Modified Files:
 	src/sys/uvm: uvm_pager.c uvm_swap.c uvm_swap.h

 Log Message:
 fix swap encryption data corruption issue

 when paging out, uvm_swap_io encrypts the page contents in-place
 and then issues write requests to swapdev. if the write fails
 for some reason, the pageout will be cancelled. but it leaves
 the data in the pages encrypted. ie. data corruption. note that
 this doesn't necessarily involve broken swap devices. as we are
 in the pagedaemon context, some kind of transient errors are
 rather normal. for example, ffs VOP_BMAP has special cases for
 the pagedaemon to return ENOMEM.

 this commit fixes the issue by simply reverting the encryption
 on error.

 PR/60082
 https://gnats.netbsd.org/60082


 To generate a diff of this commit:
 cvs rdiff -u -r1.134 -r1.135 src/sys/uvm/uvm_pager.c
 cvs rdiff -u -r1.221 -r1.222 src/sys/uvm/uvm_swap.c
 cvs rdiff -u -r1.29 -r1.30 src/sys/uvm/uvm_swap.h

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

From: "Taylor R Campbell" <riastradh@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/60082 CVS commit: src/sys/uvm
Date: Sat, 27 Jun 2026 14:56:29 +0000

 Module Name:	src
 Committed By:	riastradh
 Date:		Sat Jun 27 14:56:29 UTC 2026

 Modified Files:
 	src/sys/uvm: uvm_swap.c

 Log Message:
 uvm(9): Fix comments on swap encryption and tidy various whitespace.

 No functional change intended: comments and whitespace only.

 Cleanup after various fixes for:

 PR kern/60082: swap encryption corrupt data
 PR kern/60083: swap encryption break /dev/drum
 PR kern/60084: swap encryption: per-page tracking seems overengineered


 To generate a diff of this commit:
 cvs rdiff -u -r1.233 -r1.234 src/sys/uvm/uvm_swap.c

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

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.51 2026/08/10 02:28:17 riastradh Exp $
$NetBSD: gnats_config.sh,v 1.10 2026/05/13 22:00:09 riastradh Exp $
Copyright © 1994-2026 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.