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=-5.4 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,UNPARSEABLE_RELAY,USER_AGENT_SANE_1 autolearn=ham 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 96601C3F2CD for ; Mon, 23 Mar 2020 15:21:18 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 52084206F8 for ; Mon, 23 Mar 2020 15:21:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=oracle.com header.i=@oracle.com header.b="dt/NnxV7" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 52084206F8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id D548E6B0005; Mon, 23 Mar 2020 11:21:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2A296B0006; Mon, 23 Mar 2020 11:21:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id C68586B0007; Mon, 23 Mar 2020 11:21:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0131.hostedemail.com [216.40.44.131]) by kanga.kvack.org (Postfix) with ESMTP id AF21B6B0005 for ; Mon, 23 Mar 2020 11:21:17 -0400 (EDT) Received: from smtpin12.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 3DEAB2C81 for ; Mon, 23 Mar 2020 15:21:17 +0000 (UTC) X-FDA: 76626990594.12.flesh21_7f79d4ac89322 X-HE-Tag: flesh21_7f79d4ac89322 X-Filterd-Recvd-Size: 6299 Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) by imf45.hostedemail.com (Postfix) with ESMTP for ; Mon, 23 Mar 2020 15:21:15 +0000 (UTC) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02NF9KZR118132; Mon, 23 Mar 2020 15:21:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : references : mime-version : content-type : in-reply-to; s=corp-2020-01-29; bh=zE4D52tgEN49T+Cl6dWeOECY4EVZp7WCUSOL0e06lSM=; b=dt/NnxV7tWjWUmuOtTRP6v1x67UniZ7/R2U2mZOJI1jB/wRBn7IP/ZhZYDi3puAA8bgJ uovkD6vduPlv6jWW3powKJRzXBHrqJr6Qedn91aH0JSX+XAl7RSwBuByfQKRZhDvoFS9 msTiCb4lWigf4DmHxWFt/jzf9l1ImVONYkAP/FC8hjlGQKpXCiWJ5GuJXGzZL6Sf0QzT gWiAm9qb/eYnI2WR2qWd1XHATUIk539WdJYMvQEpgXG7Bft7ICnKmquza0V8jYpLmyEu 106eMvJAYHVkGAt0owONRcBfwotfqH7MgezSRNMlO8Xa52G76NZK1vzJZXLHOzg0vzwv Pw== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by aserp2120.oracle.com with ESMTP id 2ywavky771-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2020 15:21:11 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 02NFJpr3068524; Mon, 23 Mar 2020 15:21:11 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2yxw7fn7ge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 23 Mar 2020 15:21:11 +0000 Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 02NFL7V9015843; Mon, 23 Mar 2020 15:21:07 GMT Received: from localhost (/67.169.218.210) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 23 Mar 2020 08:21:06 -0700 Date: Mon, 23 Mar 2020 08:21:05 -0700 From: "Darrick J. Wong" To: Domenico Andreoli Cc: "Rafael J. Wysocki" , "Rafael J. Wysocki" , Linux PM , Linux Memory Management List , linux-fsdevel@vger.kernel.org, mkleinsoft@gmail.com, Christoph Hellwig , Andrew Morton , Len Brown , Pavel Machek Subject: Re: [PATCH v2] hibernate: Allow uswsusp to write to swap Message-ID: <20200323152105.GB29351@magnolia> References: <20200304170646.GA31552@dumbo> <5202091.FuziMeULnI@kreacher> <20200322112314.GA22738@dumbo> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200322112314.GA22738@dumbo> User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9569 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 mlxlogscore=999 spamscore=0 adultscore=0 phishscore=0 suspectscore=0 malwarescore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003230086 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9569 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 adultscore=0 malwarescore=0 priorityscore=1501 mlxscore=0 bulkscore=0 clxscore=1015 impostorscore=0 phishscore=0 suspectscore=0 mlxlogscore=999 spamscore=0 lowpriorityscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2003020000 definitions=main-2003230086 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 Sun, Mar 22, 2020 at 12:23:14PM +0100, Domenico Andreoli wrote: > On Sun, Mar 22, 2020 at 08:14:21AM +0100, Rafael J. Wysocki wrote: > > On Wednesday, March 4, 2020 6:06:46 PM CET Domenico Andreoli wrote: > > > From: Domenico Andreoli > > > > > > 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. > > > > > > Quick fix: disable the S_SWAPFILE check if hibernation is configured. > > > > > > Fixes: dc617f29dbe5 ("vfs: don't allow writes to swap files") > > > Reported-by: Domenico Andreoli > > > Reported-by: Marian Klein > > > Signed-off-by: Domenico Andreoli > > > > > > v2: > > > - use hibernation_available() instead of IS_ENABLED(CONFIG_HIBERNATE) > > > - make Fixes: point to the right commit > > > > This looks OK to me. > > > > Has it been taken care of already, or am I expected to apply it? > > I don't know who is supposed to take it, I did not receive any notification. Hmmm. I thought it had been picked up by akpm (see "[alternative-merged] vfs-partially-revert-dont-allow-writes-to-swap-files.patch removed from -mm tree" from 5 March), but it's not in mmotm now, so I'll put this in my vfs tree for 5.7. Also, since apparently my previous RVB apparently never made it to the internet, Reviewed-by: Darrick J. Wong --D > > > > > --- > > > fs/block_dev.c | 4 +++- > > > 1 file changed, 3 insertions(+), 1 deletion(-) > > > > > > Index: b/fs/block_dev.c > > > =================================================================== > > > --- a/fs/block_dev.c > > > +++ b/fs/block_dev.c > > > @@ -34,6 +34,7 @@ > > > #include > > > #include > > > #include > > > +#include > > > #include "internal.h" > > > > > > struct bdev_inode { > > > @@ -2001,7 +2002,8 @@ ssize_t blkdev_write_iter(struct kiocb * > > > if (bdev_read_only(I_BDEV(bd_inode))) > > > return -EPERM; > > > > > > - if (IS_SWAPFILE(bd_inode)) > > > + /* uswsusp needs write permission to the swap */ > > > + if (IS_SWAPFILE(bd_inode) && !hibernation_available()) > > > return -ETXTBSY; > > > > > > if (!iov_iter_count(from)) > > > > > > > > > > > > > -- > rsa4096: 3B10 0CA1 8674 ACBA B4FE FCD2 CE5B CF17 9960 DE13 > ed25519: FFB4 0CC3 7F2E 091D F7DA 356E CC79 2832 ED38 CB05