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=-2.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, USER_AGENT_SANE_1 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 568E9C3F2D3 for ; Sat, 29 Feb 2020 20:02:06 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E7B6A246B0 for ; Sat, 29 Feb 2020 20:02:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BGTE4xeW" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E7B6A246B0 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linux.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 3CC1A6B0005; Sat, 29 Feb 2020 15:02:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 37CD46B0006; Sat, 29 Feb 2020 15:02:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2921D6B0007; Sat, 29 Feb 2020 15:02:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0120.hostedemail.com [216.40.44.120]) by kanga.kvack.org (Postfix) with ESMTP id 0DA636B0005 for ; Sat, 29 Feb 2020 15:02:05 -0500 (EST) Received: from smtpin07.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id C8AA44DA1 for ; Sat, 29 Feb 2020 20:02:04 +0000 (UTC) X-FDA: 76544235768.07.vest14_4c4cdb25ae74e X-HE-Tag: vest14_4c4cdb25ae74e X-Filterd-Recvd-Size: 5845 Received: from mail-wm1-f65.google.com (mail-wm1-f65.google.com [209.85.128.65]) by imf26.hostedemail.com (Postfix) with ESMTP for ; Sat, 29 Feb 2020 20:02:04 +0000 (UTC) Received: by mail-wm1-f65.google.com with SMTP id 9so855013wmo.1 for ; Sat, 29 Feb 2020 12:02:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=5HtXVHt8g2TngqQLkSV4rjhDAGaSXSD43YSdcP2E8DE=; b=BGTE4xeWqaSXlX2J+uJwVmYWsT03oEBO4Jd0ECUO1GpmPi9OCLcmTmKD4QibJhbgFo YyFF1lzdQBXKUg7Csmt/Zz7ieUDaC9xWAcxpIjUprhcxZDWUu4zvmgfOFzC2Y7nKqF+l lCWmqu8kcfy5EpoXBQ6vfQ3XR9GHoVirpAYSz+HPf8Q4XLmtXqWAiMeXUYgiRGUtX622 peP3KVH825faU69qYaZvEkNHnM1JRHHbpFTjqNCZ8kF2RAIJx3Y4xTHp3oldTIQv7KOQ QqLixyBT5/ELrj/0lDQ6QyXp0z6tEug98Eg/AcRkruReSiH0lcfbakIwGiShvtZAEth+ t0eQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to:user-agent; bh=5HtXVHt8g2TngqQLkSV4rjhDAGaSXSD43YSdcP2E8DE=; b=mnuEgw23WMkifO+q/ykqAJYf58Zwuw8fM75TF0Br4esIenWMLH2EwzlsLS3mWwcvPr BXWsN//mCfQ5uKO11dQHYmBm4IbfNOoC7rHmcAGq14YNw95fFlpelpk6uFL2/CbMiEkh sJmjHxQQ83wF0ytB5bURhjhyztfeg2KsgqqF5KjU9+FFngS+lQnenP82r0Bfgh+nh7ai QtnoAi+Aba6ko6HVtBOjTT/bnf194jYX6s9LTRy7tSQqrL2GtpKvoWIPSFQqE1Zl4gvA 9RMqr3z7OB/jTSvXVvAhqPWs//A8jfZyTRRUy5iRE/jhwx+sNpsV0kYaFHELV7BqgH5D zxDg== X-Gm-Message-State: APjAAAU+g1svII2ZqM38iMQz6TAEgwmXYEXhyL6u817b/1Nxa/MEJkVP +L1yRcJyIDJjr61ys6GROOE= X-Google-Smtp-Source: APXvYqxbFIq7i7LKjT21XwH6j2UsGVWt6/c8aIGMmDQZIOQQCTABOEMv0TFHJvBePC50BRN6G7NuKQ== X-Received: by 2002:a7b:cc82:: with SMTP id p2mr10605147wma.159.1583006523007; Sat, 29 Feb 2020 12:02:03 -0800 (PST) Received: from dumbo (ip4da2e549.direct-adsl.nl. [77.162.229.73]) by smtp.gmail.com with ESMTPSA id b18sm18637473wru.50.2020.02.29.12.02.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 29 Feb 2020 12:02:02 -0800 (PST) Date: Sat, 29 Feb 2020 21:02:00 +0100 From: Domenico Andreoli To: "Darrick J. Wong" Cc: linux-pm@vger.kernel.org, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, mkleinsoft@gmail.com, hch@lst.de, akpm@linux-foundation.org, rjw@rjwysocki.net, len.brown@intel.com, pavel@ucw.cz Subject: Re: [PATCH] hibernate: unlock swap bdev for writing when uswsusp is active Message-ID: <20200229200200.GA10970@dumbo> References: <20200229170825.GX8045@magnolia> <20200229180716.GA31323@dumbo> <20200229183820.GA8037@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200229183820.GA8037@magnolia> User-Agent: Mutt/1.10.1 (2018-07-13) X-Bogosity: Ham, tests=bogofilter, spamicity=0.002017, 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 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. > ...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. Maybe user-space hibernation should be a separate option. > > --D -- rsa4096: 3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13 ed25519: FFB4 0CC3 7F2E 091D F7DA 356E CC79 2832 ED38 CB05