From patchwork Wed Mar 4 17:06:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Domenico Andreoli X-Patchwork-Id: 11420505 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 712E014BC for ; Wed, 4 Mar 2020 17:06:54 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 3A88524673 for ; Wed, 4 Mar 2020 17:06:54 +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="UzWuKWhw" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3A88524673 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 7949A6B0003; Wed, 4 Mar 2020 12:06:53 -0500 (EST) Delivered-To: linux-mm-outgoing@kvack.org Received: by kanga.kvack.org (Postfix, from userid 40) id 746526B0005; Wed, 4 Mar 2020 12:06:53 -0500 (EST) X-Original-To: int-list-linux-mm@kvack.org X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 65A956B0007; Wed, 4 Mar 2020 12:06:53 -0500 (EST) X-Original-To: linux-mm@kvack.org X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0152.hostedemail.com [216.40.44.152]) by kanga.kvack.org (Postfix) with ESMTP id 4E00C6B0003 for ; Wed, 4 Mar 2020 12:06:53 -0500 (EST) Received: from smtpin15.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id 03F4340C7 for ; Wed, 4 Mar 2020 17:06:53 +0000 (UTC) X-FDA: 76558309464.15.peace39_5920eddc84614 X-Spam-Summary: 2,0,0,366a8ec15a135fff,d41d8cd98f00b204,cavokz@gmail.com,,RULES_HIT:41:355:379:800:960:973:988:989:1260:1277:1312:1313:1314:1345:1437:1516:1518:1519:1534:1541:1593:1594:1595:1596:1711:1730:1747:1777:1792:2393:2559:2562:2896:3138:3139:3140:3141:3142:3352:3865:3866:3867:3868:3871:3872:3874:5007:6261:6653:7514:7576:7875:10004:10400:11026:11658:11914:12043:12291:12296:12297:12438:12517:12519:12679:12683:13069:13221:13229:13311:13357:13439:13895:14093:14096:14097:14181:14394:14721:21080:21444:21450:21451:21611:21627:21990:30012:30054:30070,0,RBL:209.85.128.67:@gmail.com:.lbl8.mailshell.net-66.100.201.100 62.18.0.100,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fp,MSBL:0,DNSBL:neutral,Custom_rules:0:0:0,LFtime:24,LUA_SUMMARY:none X-HE-Tag: peace39_5920eddc84614 X-Filterd-Recvd-Size: 4478 Received: from mail-wm1-f67.google.com (mail-wm1-f67.google.com [209.85.128.67]) by imf01.hostedemail.com (Postfix) with ESMTP for ; Wed, 4 Mar 2020 17:06:52 +0000 (UTC) Received: by mail-wm1-f67.google.com with SMTP id x3so14531wmj.1 for ; Wed, 04 Mar 2020 09:06:52 -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:mime-version :content-disposition:user-agent; bh=eAvOIF6AGY3vlZ1kzI6VwMQbeJQz/suMmkKBmXk6J8Y=; b=UzWuKWhwSTJKSKcktovi82mOWChrc/f0KtLo4X5rUYd9T9r93VZEsjULHytd8lrxv5 YIjTecmQzPuwr7GMOVXPUDzk7lTvc126GlJ12boC1Sz8lUEzTYLgcL4e4+ZzBgZnaXgV yJnsaPX9X5VH511KEtLXIvytDFOzksJdNlA9OVlQIJHT1qYZpqldWsMilzD7CoLwojYe dUPg13pM6AO6vwLFYzO4RMgsvkXMOQwQ7VjuWB5iu3uobCoFQICIbneHO+1KAYyyzoAT rs+eqJyYPk72BAxEhnWCrgwDElzuYrpfn0wpJMW+tKXYEHArAEXOCq/oElUgKrHDfO1x 49+w== 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 :mime-version:content-disposition:user-agent; bh=eAvOIF6AGY3vlZ1kzI6VwMQbeJQz/suMmkKBmXk6J8Y=; b=XQjJ0sNGqfe08q1R5DJsT5HtyVLPhoZ3aWI+PHXphlVfFt0oDOFF6CgEROP9LTn55C F4DMLTMV7B/jHtyys/qDvbN5Q1PNQixjfZlQgcOJ4yw/ZKKkGJ9718cmAlFWXqA3O5zz PXShaMl+F+TwM0g8Fm8Kl3AAzNPsZAyykx2x2SNZCkeXAf6nUsVpVTw1o6KLy7+cCI5L eoMgRQRAm+9+W9DCwfoyJlsZAieYZpDGVhxUAbeNr6ryKMqXFWqDVo0ryJ8tqJ7Ml4vD YwxqAWYcyaCOcncTV/iWHtSlQSlEGa54DRm6WzO+BQzsJEXXhdcg0YONzNF+Aop1VGjM 6FEw== X-Gm-Message-State: ANhLgQ0kfxPxxR87c8XBrbBfP4DRZm4cuaUtHUgwnNI0S7WwgodOCNXH esRx5qg10vREnh+8Igd/N1o= X-Google-Smtp-Source: ADFU+vs1u9SfcjF5RGIglTQpijbTZfS8yfBBuwrm2uVF6l/ojNbTblWiBQyIEcYPkcSSRfs4nBBHBQ== X-Received: by 2002:a1c:c906:: with SMTP id f6mr4622479wmb.16.1583341611386; Wed, 04 Mar 2020 09:06:51 -0800 (PST) Received: from dumbo ([83.137.6.114]) by smtp.gmail.com with ESMTPSA id o8sm4841231wmh.15.2020.03.04.09.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Mar 2020 09:06:50 -0800 (PST) Date: Wed, 4 Mar 2020 18:06:46 +0100 From: Domenico Andreoli To: "Darrick J. Wong" Cc: "Rafael J. Wysocki" , 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 Subject: [PATCH v2] hibernate: Allow uswsusp to write to swap Message-ID: <20200304170646.GA31552@dumbo> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.10.1 (2018-07-13) 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: 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 Reported-by: kernel test robot Reviewed-by: Darrick J. Wong --- 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))