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.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT autolearn=unavailable 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 5BF7DC48BD6 for ; Wed, 26 Jun 2019 03:52:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3D3CF20659 for ; Wed, 26 Jun 2019 03:52:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726987AbfFZDwc (ORCPT ); Tue, 25 Jun 2019 23:52:32 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:44166 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726757AbfFZDwc (ORCPT ); Tue, 25 Jun 2019 23:52:32 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hfyyN-0008Mv-UN; Wed, 26 Jun 2019 03:51:52 +0000 Date: Wed, 26 Jun 2019 04:51:51 +0100 From: Al Viro To: "Darrick J. Wong" Cc: matthew.garrett@nebula.com, yuchao0@huawei.com, tytso@mit.edu, ard.biesheuvel@linaro.org, josef@toxicpanda.com, hch@infradead.org, clm@fb.com, adilger.kernel@dilger.ca, jack@suse.com, dsterba@suse.com, jaegeuk@kernel.org, jk@ozlabs.org, reiserfs-devel@vger.kernel.org, linux-efi@vger.kernel.org, devel@lists.orangefs.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org Subject: Re: [PATCH 5/5] vfs: don't allow writes to swap files Message-ID: <20190626035151.GA10613@ZenIV.linux.org.uk> References: <156151637248.2283603.8458727861336380714.stgit@magnolia> <156151641177.2283603.7806026378321236401.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <156151641177.2283603.7806026378321236401.stgit@magnolia> User-Agent: Mutt/1.11.3 (2019-02-01) Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org On Tue, Jun 25, 2019 at 07:33:31PM -0700, Darrick J. Wong wrote: > --- a/fs/attr.c > +++ b/fs/attr.c > @@ -236,6 +236,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de > if (IS_IMMUTABLE(inode)) > return -EPERM; > > + if (IS_SWAPFILE(inode)) > + return -ETXTBSY; > + > if ((ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) && > IS_APPEND(inode)) > return -EPERM; Er... So why exactly is e.g. chmod(2) forbidden for swapfiles? Or touch(1), for that matter... > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 596ac98051c5..1ca4ee8c2d60 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -3165,6 +3165,19 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > if (error) > goto bad_swap; > > + /* > + * Flush any pending IO and dirty mappings before we start using this > + * swap file. > + */ > + if (S_ISREG(inode->i_mode)) { > + inode->i_flags |= S_SWAPFILE; > + error = inode_drain_writes(inode); > + if (error) { > + inode->i_flags &= ~S_SWAPFILE; > + goto bad_swap; > + } > + } Why are swap partitions any less worthy of protection? 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.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_MUTT 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 583FDC4646B for ; Wed, 26 Jun 2019 04:20:49 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 308CE2086D; Wed, 26 Jun 2019 04:20:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sourceforge.net header.i=@sourceforge.net header.b="DYVAJ9TW"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=sf.net header.i=@sf.net header.b="fZKzgAQh" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 308CE2086D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linux-f2fs-devel-bounces@lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.90_1) (envelope-from ) id 1hfzQD-0000kc-Ed; Wed, 26 Jun 2019 04:20:37 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) (envelope-from ) id 1hfzQC-0000kS-MO for linux-f2fs-devel@lists.sourceforge.net; Wed, 26 Jun 2019 04:20:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Sender:In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=kIclzzvbwh3gy97S4kcHDKI8qcoqoEowJ4LfFBdWgr0=; b=DYVAJ9TWHatk/5Snm+zBNW4RJ cX4qQAgU/e8hxFa4cjk8xfpXzEiX6fFQtwpuQdXNBfybsIhX7k0kzrJ++6OXi1Wo0OSwPhAY21gcn ijJJdFYK0WqXYll0+IqWM9//Wz6T8Y17Y8tcb5SVqdyEkSp2VN8Cnapw9CsU+0TPYfZ7Q=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Sender:In-Reply-To:Content-Type:MIME-Version:References:Message-ID: Subject:Cc:To:From:Date:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kIclzzvbwh3gy97S4kcHDKI8qcoqoEowJ4LfFBdWgr0=; b=fZKzgAQh4cUXMb7URwG+a5j1W4 kAyAgzzB7n9ykby8YhlOI2O7ObNhi3rqmy6elPKYWWs8GD+sLithRNCIXfhBbJD7d9JokIvKpbgEP qtZcVGw2cJq5IocoxZAqhn/1KOsDq9VFF4Ypx5ewP35E8b/zBMyUD8lrlnjZY9fkN59w=; Received: from zeniv.linux.org.uk ([195.92.253.2]) by sfi-mx-4.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.90_1) id 1hfzQM-00DvIf-QU for linux-f2fs-devel@lists.sourceforge.net; Wed, 26 Jun 2019 04:20:48 +0000 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hfyyN-0008Mv-UN; Wed, 26 Jun 2019 03:51:52 +0000 Date: Wed, 26 Jun 2019 04:51:51 +0100 From: Al Viro To: "Darrick J. Wong" Message-ID: <20190626035151.GA10613@ZenIV.linux.org.uk> References: <156151637248.2283603.8458727861336380714.stgit@magnolia> <156151641177.2283603.7806026378321236401.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <156151641177.2283603.7806026378321236401.stgit@magnolia> User-Agent: Mutt/1.11.3 (2019-02-01) X-Headers-End: 1hfzQM-00DvIf-QU Subject: Re: [f2fs-dev] [PATCH 5/5] vfs: don't allow writes to swap files X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-efi@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org, clm@fb.com, adilger.kernel@dilger.ca, matthew.garrett@nebula.com, linux-nilfs@vger.kernel.org, hch@infradead.org, linux-ext4@vger.kernel.org, devel@lists.orangefs.org, josef@toxicpanda.com, reiserfs-devel@vger.kernel.org, dsterba@suse.com, jaegeuk@kernel.org, tytso@mit.edu, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, jk@ozlabs.org, jack@suse.com, linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Tue, Jun 25, 2019 at 07:33:31PM -0700, Darrick J. Wong wrote: > --- a/fs/attr.c > +++ b/fs/attr.c > @@ -236,6 +236,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de > if (IS_IMMUTABLE(inode)) > return -EPERM; > > + if (IS_SWAPFILE(inode)) > + return -ETXTBSY; > + > if ((ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) && > IS_APPEND(inode)) > return -EPERM; Er... So why exactly is e.g. chmod(2) forbidden for swapfiles? Or touch(1), for that matter... > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 596ac98051c5..1ca4ee8c2d60 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -3165,6 +3165,19 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > if (error) > goto bad_swap; > > + /* > + * Flush any pending IO and dirty mappings before we start using this > + * swap file. > + */ > + if (S_ISREG(inode->i_mode)) { > + inode->i_flags |= S_SWAPFILE; > + error = inode_drain_writes(inode); > + if (error) { > + inode->i_flags &= ~S_SWAPFILE; > + goto bad_swap; > + } > + } Why are swap partitions any less worthy of protection? _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel 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.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_MUTT 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 292F1C4646B for ; Wed, 26 Jun 2019 03:53:51 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id E4BEB2082F for ; Wed, 26 Jun 2019 03:53:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="sUDNM/vU" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E4BEB2082F Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=pqI3KFpJSCSh8LH6JqGzfY2D3enkFFtxweldIAkHLIo=; b=sUDNM/vU8++F7B yrGorgm3fo/UveXzL8YQqWEUtKDh4Zw4HPuFk/6zSBlETOplJKUtj5zHbZXcK+qFb9TbKy1cM14n3 b5AmhJ5mZMPK2fYx8pJ9JNzqxzD0g/ITvFkxLx0wZiLh3eo0qrRZF4P5wlU1MaxJ1Xo37IAp/sqyf 2s7Z5bZpG0LGfwOy3oNxtYOUsXX2napOM/soJLyxcasNNRSndwWT2z3ZCIqVy22GdIC3rPO2tUWOW qyXfGgNRjdGzv8fPX0DEgk0xoHEp1Uv0xF6tPxN6U21vyp/fLhXdBtwal/t40qUF6N9mRGLru7f0f z3ZvJmBH2mpwzgJZ+H7g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1hfz02-0000fQ-4m; Wed, 26 Jun 2019 03:53:34 +0000 Received: from zeniv.linux.org.uk ([195.92.253.2]) by bombadil.infradead.org with esmtps (Exim 4.92 #3 (Red Hat Linux)) id 1hfyzq-0000b2-6K for linux-mtd@lists.infradead.org; Wed, 26 Jun 2019 03:53:24 +0000 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92 #3 (Red Hat Linux)) id 1hfyyN-0008Mv-UN; Wed, 26 Jun 2019 03:51:52 +0000 Date: Wed, 26 Jun 2019 04:51:51 +0100 From: Al Viro To: "Darrick J. Wong" Subject: Re: [PATCH 5/5] vfs: don't allow writes to swap files Message-ID: <20190626035151.GA10613@ZenIV.linux.org.uk> References: <156151637248.2283603.8458727861336380714.stgit@magnolia> <156151641177.2283603.7806026378321236401.stgit@magnolia> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <156151641177.2283603.7806026378321236401.stgit@magnolia> User-Agent: Mutt/1.11.3 (2019-02-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190625_205322_415538_CACD9C36 X-CRM114-Status: GOOD ( 10.37 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-efi@vger.kernel.org, linux-btrfs@vger.kernel.org, yuchao0@huawei.com, linux-mm@kvack.org, clm@fb.com, adilger.kernel@dilger.ca, matthew.garrett@nebula.com, linux-nilfs@vger.kernel.org, hch@infradead.org, linux-ext4@vger.kernel.org, devel@lists.orangefs.org, josef@toxicpanda.com, reiserfs-devel@vger.kernel.org, dsterba@suse.com, jaegeuk@kernel.org, tytso@mit.edu, ard.biesheuvel@linaro.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, jk@ozlabs.org, jack@suse.com, linux-fsdevel@vger.kernel.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org On Tue, Jun 25, 2019 at 07:33:31PM -0700, Darrick J. Wong wrote: > --- a/fs/attr.c > +++ b/fs/attr.c > @@ -236,6 +236,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de > if (IS_IMMUTABLE(inode)) > return -EPERM; > > + if (IS_SWAPFILE(inode)) > + return -ETXTBSY; > + > if ((ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) && > IS_APPEND(inode)) > return -EPERM; Er... So why exactly is e.g. chmod(2) forbidden for swapfiles? Or touch(1), for that matter... > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 596ac98051c5..1ca4ee8c2d60 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -3165,6 +3165,19 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > if (error) > goto bad_swap; > > + /* > + * Flush any pending IO and dirty mappings before we start using this > + * swap file. > + */ > + if (S_ISREG(inode->i_mode)) { > + inode->i_flags |= S_SWAPFILE; > + error = inode_drain_writes(inode); > + if (error) { > + inode->i_flags &= ~S_SWAPFILE; > + goto bad_swap; > + } > + } Why are swap partitions any less worthy of protection? ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/ From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Date: Wed, 26 Jun 2019 04:51:51 +0100 Subject: [Ocfs2-devel] [PATCH 5/5] vfs: don't allow writes to swap files In-Reply-To: <156151641177.2283603.7806026378321236401.stgit@magnolia> References: <156151637248.2283603.8458727861336380714.stgit@magnolia> <156151641177.2283603.7806026378321236401.stgit@magnolia> Message-ID: <20190626035151.GA10613@ZenIV.linux.org.uk> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: "Darrick J. Wong" Cc: matthew.garrett@nebula.com, yuchao0@huawei.com, tytso@mit.edu, ard.biesheuvel@linaro.org, josef@toxicpanda.com, hch@infradead.org, clm@fb.com, adilger.kernel@dilger.ca, jack@suse.com, dsterba@suse.com, jaegeuk@kernel.org, jk@ozlabs.org, reiserfs-devel@vger.kernel.org, linux-efi@vger.kernel.org, devel@lists.orangefs.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-xfs@vger.kernel.org, linux-mm@kvack.org, linux-nilfs@vger.kernel.org, linux-mtd@lists.infradead.org, ocfs2-devel@oss.oracle.com, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org On Tue, Jun 25, 2019 at 07:33:31PM -0700, Darrick J. Wong wrote: > --- a/fs/attr.c > +++ b/fs/attr.c > @@ -236,6 +236,9 @@ int notify_change(struct dentry * dentry, struct iattr * attr, struct inode **de > if (IS_IMMUTABLE(inode)) > return -EPERM; > > + if (IS_SWAPFILE(inode)) > + return -ETXTBSY; > + > if ((ia_valid & (ATTR_MODE | ATTR_UID | ATTR_GID | ATTR_TIMES_SET)) && > IS_APPEND(inode)) > return -EPERM; Er... So why exactly is e.g. chmod(2) forbidden for swapfiles? Or touch(1), for that matter... > diff --git a/mm/swapfile.c b/mm/swapfile.c > index 596ac98051c5..1ca4ee8c2d60 100644 > --- a/mm/swapfile.c > +++ b/mm/swapfile.c > @@ -3165,6 +3165,19 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) > if (error) > goto bad_swap; > > + /* > + * Flush any pending IO and dirty mappings before we start using this > + * swap file. > + */ > + if (S_ISREG(inode->i_mode)) { > + inode->i_flags |= S_SWAPFILE; > + error = inode_drain_writes(inode); > + if (error) { > + inode->i_flags &= ~S_SWAPFILE; > + goto bad_swap; > + } > + } Why are swap partitions any less worthy of protection?