From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF11BC3F2D4 for ; Sun, 1 Mar 2020 21:35:49 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8185E246A1 for ; Sun, 1 Mar 2020 21:35:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 8185E246A1 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id DF35E6B0005; Sun, 1 Mar 2020 16:35:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id DA3866B0006; Sun, 1 Mar 2020 16:35:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CB9376B0007; Sun, 1 Mar 2020 16:35:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0240.hostedemail.com [216.40.44.240]) by kanga.kvack.org (Postfix) with ESMTP id B40986B0005 for ; Sun, 1 Mar 2020 16:35:48 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 6FC2B28DB1 for ; Sun, 1 Mar 2020 21:35:48 +0000 (UTC) X-FDA: 76548100776.06.door07_4fc2061a6a403 X-HE-Tag: door07_4fc2061a6a403 X-Filterd-Recvd-Size: 5128 Received: from mail-oi1-f196.google.com (mail-oi1-f196.google.com [209.85.167.196]) by imf32.hostedemail.com (Postfix) with ESMTP for ; Sun, 1 Mar 2020 21:35:47 +0000 (UTC) Received: by mail-oi1-f196.google.com with SMTP id 2so8429766oiz.5 for ; Sun, 01 Mar 2020 13:35:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=oyE5Vq1uGiCQC0izukDlQ84tv/Yn0CZvAVoYGB9H9JA=; b=kNC0QFGnc+mkSrn36jAWUoX2M7EG0jgjNTN3W+R30L9q42OHjDWjirV1M6EbSbZUW4 I8+n/r7Qp0uFjjbi2Mn0tmwqx2qjHKwhqSOAEKcMsp6gETFDku+8wvz9gB1GyGWIk0Ty FUO7mCAHfnS4ntq45lkZQr6vkN9iYcoxaV57dZez1YnPZ7WT4PPFsD7lZYBuyZxIlJYC 8zKgnsfnSeHald5libcr2JTPp3TmpRtoQSEIcWFYWuN/yldoJY3ETENvksmIvMIlb3jM dezGS9vzr4OBOnKiqJgyKAc9nBfN+gw5aV+hPl8H2kIWTz1G7nNHdjNiVJmo5EVqH8QV QHdw== X-Gm-Message-State: APjAAAWnlCSW/W59yZ2Vd3svA0JbqIlJp95uT35RnFkK2l4PGIB5y0lp LUWaFZmUcolJnGzILwkAlGLkgxLvz0CpWLsk3X0= X-Google-Smtp-Source: APXvYqwc36SK4tls9i2nd0gdJfBh8IhAkEVLekPBpOVDM5r7DGtogpYivNmpwoiVXWcwTZcRq+oniU0slts/j2CITUc= X-Received: by 2002:aca:4d82:: with SMTP id a124mr10088079oib.103.1583098547283; Sun, 01 Mar 2020 13:35:47 -0800 (PST) MIME-Version: 1.0 References: <20200229170825.GX8045@magnolia> <20200229180716.GA31323@dumbo> <20200229183820.GA8037@magnolia> <20200229200200.GA10970@dumbo> In-Reply-To: <20200229200200.GA10970@dumbo> From: "Rafael J. Wysocki" Date: Sun, 1 Mar 2020 22:35:36 +0100 Message-ID: Subject: Re: [PATCH] hibernate: unlock swap bdev for writing when uswsusp is active To: Domenico Andreoli Cc: "Darrick J. Wong" , Linux PM , Linux Memory Management List , linux-fsdevel@vger.kernel.org, mkleinsoft@gmail.com, Christoph Hellwig , Andrew Morton , "Rafael J. Wysocki" , Len Brown , Pavel Machek Content-Type: text/plain; charset="UTF-8" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sat, Feb 29, 2020 at 9:02 PM Domenico Andreoli wrote: > > On Sat, Feb 29, 2020 at 10:38:20AM -0800, Darrick J. Wong wrote: > > On Sat, Feb 29, 2020 at 07:07:16PM +0100, Domenico Andreoli wrote: > > > On Sat, Feb 29, 2020 at 09:08:25AM -0800, Darrick J. Wong wrote: > > > > From: Darrick J. Wong > > > > > > > > It turns out that there /is/ one use case for programs being able to > > > > write to swap devices, and that is the userspace hibernation code. The > > > > uswsusp ioctls allow userspace to lease parts of swap devices, so turn > > > > S_SWAPFILE off when invoking suspend. > > > > > > > > Fixes: 1638045c3677 ("mm: set S_SWAPFILE on blockdev swap devices") > > > > Reported-by: Domenico Andreoli > > > > Reported-by: Marian Klein > > > > > > I also tested it yesterday but was not satisfied, unfortunately I did > > > not come with my comment in time. > > > > > > Yes, I confirm that the uswsusp works again but also checked that > > > swap_relockall() is not triggered at all and therefore after the first > > > hibernation cycle the S_SWAPFILE bit remains cleared and the whole > > > swap_relockall() is useless. > > > > > > I'm not sure this patch should be merged in the current form. > > > > NNGGHHGGHGH /me is rapidly losing his sanity and will soon just revert > > the whole security feature because I'm getting fed up with people > > yelling at me *while I'm on vacation* trying to *restore* my sanity. I > > really don't want to be QAing userspace-directed hibernation right now. > > Maybe we could proceed with the first patch to amend the regression and > postpone the improved fix to a later patch? Don't loose sanity for this. I would concur here. > > ...right, the patch is broken because we have to relock the swapfiles in > > whatever code executes after we jump back to the restored kernel, not in > > the one that's doing the restoring. Does this help? > > I made a few unsuccessful attempts in kernel/power/hibernate.c and > eventually I'm switching to qemu to speed up the test cycle. > > > OTOH, maybe we should just leave the swapfiles unlocked after resume. > > Userspace has clearly demonstrated the one usecase for writing to the > > swapfile, which means anyone could have jumped in while uswsusp was > > running and written whatever crap they wanted to the parts of the swap > > file that weren't leased for the hibernate image. > > Essentially, if the hibernation is supported the swapfile is not totally > safe. But that's only the case with the userspace variant, isn't it? > Maybe user-space hibernation should be a separate option. That actually is not a bad idea at all in my view. Thanks!