Date: Wed, 05 Jan 2022 20:07:35 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260793] 'swapon -a' can crash the system Message-ID: <bug-260793-227-60RiS9ASj8@https.bugs.freebsd.org/bugzilla/> In-Reply-To: <bug-260793-227@https.bugs.freebsd.org/bugzilla/> References: <bug-260793-227@https.bugs.freebsd.org/bugzilla/>
next in thread | previous in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260793 Mark Johnston <markj@FreeBSD.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |Open --- Comment #3 from Mark Johnston <markj@FreeBSD.org> --- (In reply to Peter Much from comment #2) I think swapoff should handle this scenario. swapon -a already silently ignores EBUSY from swapon(), which occurs when the file is already a swap device, so it shouldn't also discard blocks in a file that is already a swap device. Normally the kernel wouldn't allow this, but we have: https://github.com/freebsd/freebsd-src/blob/main/sys/vm/swap_pager.c#L3006 Perhaps swapon's swapon_trim() can check to see if a file at the path is already in use as a swap device. I don't think we have a good way to do th= at though. For devfs files we can compare the device number with the ones available from the vm.swap_info sysctl, but this won't work for regular fil= es, I think. Perhaps we can extend the swapon() syscall to let the kernel perform the trimming. Or add an IS_THIS_A_SWAP_DEVICE ioctl that swapon can check befo= re trying to erase the file blocks. --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-260793-227-60RiS9ASj8>