From nobody Wed Jan 05 20:07:35 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 13F1B1935162 for ; Wed, 5 Jan 2022 20:07:36 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4JTgWW5sj1z4jx4 for ; Wed, 5 Jan 2022 20:07:35 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id A748F122F1 for ; Wed, 5 Jan 2022 20:07:35 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 205K7ZRr048836 for ; Wed, 5 Jan 2022 20:07:35 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 205K7Z2a048835 for bugs@FreeBSD.org; Wed, 5 Jan 2022 20:07:35 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 260793] 'swapon -a' can crash the system Date: Wed, 05 Jan 2022 20:07:35 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: 12.3-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: markj@FreeBSD.org X-Bugzilla-Status: Open X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_status Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1641413255; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=0Jtwtc/UodGykV1CKazuYss6W1+hrLWSy3qq/o/Ntcg=; b=aU5EI6qGSoF/A5dE+KZdAUg7iNUZ9wWoNuEJjObPc1yOA6cJDDzmP99nbiN+FyL+mvR8vx +BAOJzK07zFGJoOjvqoP/PRUHy5v0WRw3EQ2U8zQUMXGixKX4dyNnu5YrO7Gfd7jDjMtFp vITsdARJR0wqhWvMsLBN9pSnfzafOvDAiCfZ0z9G1n1vDv/9Sxg41rF4+xjPEd7XIIMNi8 y9DbB4fvfGYsOnEaMxDWanxEXdT7ldUdQOawO57eDLj0OwejPNnbWOIOI7HTBuHaFMuTpI rOnUerWd2XndFGmcVeB/jdYt1sBKutKK30Kfbhw/vcek6LJNsg9UqAgHsoGPQw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1641413255; a=rsa-sha256; cv=none; b=pB7A+aZJsPSI9320UuBl0byggdEv+CqJTmBHOBmhwRdBSgmQ+iYXdbBEfPU50FPfJ99yqo jcWYz6c6zHOSo8tR4HZTyLkPz41HI9AKGSbBCwAU7StT2cAPA24MlzB+qwCsGmKtkTkolG HX/R8/ALEoJmXzSAD6nTL+bbNy/rKXems6H1ENEB8tOaBoON51eoSbwVB3faT4E7nsnNyg G2EOclap9Cw3fk26BldtNC4uHmvvHAzsAXLQ8uRmnrkGHDdpcCp9lAl90/7uE2Ao+vSne6 7d3PG7gD4borsmnqBI4ONK6nvU4ySsoeihK+z196T+5hwY9W/34byO/XATNAzA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D260793 Mark Johnston changed: What |Removed |Added ---------------------------------------------------------------------------- Status|New |Open --- Comment #3 from Mark Johnston --- (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.=