Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2704767ybi; Sun, 9 Jun 2019 18:53:42 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOdwDRQv4o7I2+IcSaG7MKA4DVNEoGLjnjH27Ox97vNhUiEU99mn+4JryfcSrcMi7dis6i X-Received: by 2002:a17:90a:2e87:: with SMTP id r7mr17798112pjd.112.1560131622361; Sun, 09 Jun 2019 18:53:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560131622; cv=none; d=google.com; s=arc-20160816; b=0QjjYJDtCjN4NVhdGC0Sm1BslbSia7iFPnrxeRm+bSt/hazeY2hVDlZjnCaZDdUnwu LmOX83uOt5Tv8QFwKFqM1WYf+wQ79WdU4n7PnSG4FxHkQkJojQK90IZA4mXda8vbF/pL /2u0xtof6lL5ihafrMcFLDdhTdL8RYEU98HxGzRLCX8n2xoBQwoCMdsCEhz6E/fps33y q+E+7D87HiCwBrv45GVViuPLg6VwMIEF6+1L7l6HwwT9GAs0InE8YsBGrk+W4SATTGin LNh6Mcm4CXj6N55Hl6FQYF60jlscFc8ssYi6BTzlI/FpJtPrIDiY7GKCVzTH8YIc2+UL UbSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=tb+JzOwVOTLv433ezXVmPOE0ZFocomL8gQwNfPZ6/cY=; b=aAeidJCM5N3osk+LiMgBeytEvwTmLGFRo+BvwDyqZC4wXxLt69gzAdkJf+cCIIzTV3 qzwueyuQ15BybCS4u1/Dqu6Y2ll7GbmfSvkEUktZB0TX6bWnCwww4xCj/41UGUQaN3pO 4b30JFIeeRiDbZTXzSllFX3Wg2UQdRk9V2XPwMG0vAH1fdZ+1rRqXhBzQzFUPhzQ4ufp uA2vtEWSxzsBDVZHXJ8cCv4M7iSy0HWYCCveGEYiLSVtMM59vGLzknU3TOg7AuFTs8u1 onnUxu+8mg5OTWgCSj6dfbsPPuvVpZQ+zwD6/2y8JggfqE2jInEPtsiq6v7b7m9Yrr3f kKUA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a5si8025698pgt.281.2019.06.09.18.53.27; Sun, 09 Jun 2019 18:53:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730275AbfFJBvy (ORCPT + 99 others); Sun, 9 Jun 2019 21:51:54 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50881 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729703AbfFJBvy (ORCPT ); Sun, 9 Jun 2019 21:51:54 -0400 Received: from callcc.thunk.org ([66.31.38.53]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id x5A1pjIR002876 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 9 Jun 2019 21:51:46 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id C99A2420481; Sun, 9 Jun 2019 21:51:45 -0400 (EDT) Date: Sun, 9 Jun 2019 21:51:45 -0400 From: "Theodore Ts'o" To: "Darrick J. Wong" Cc: linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-mm@kvack.org Subject: Re: [PATCH 1/8] mm/fs: don't allow writes to immutable files Message-ID: <20190610015145.GB3266@mit.edu> References: <155552786671.20411.6442426840435740050.stgit@magnolia> <155552787330.20411.11893581890744963309.stgit@magnolia> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <155552787330.20411.11893581890744963309.stgit@magnolia> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Apr 17, 2019 at 12:04:33PM -0700, Darrick J. Wong wrote: > diff --git a/mm/memory.c b/mm/memory.c > index ab650c21bccd..dfd5eba278d6 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2149,6 +2149,9 @@ static vm_fault_t do_page_mkwrite(struct vm_fault *vmf) > > vmf->flags = FAULT_FLAG_WRITE|FAULT_FLAG_MKWRITE; > > + if (vmf->vma->vm_file && IS_IMMUTABLE(file_inode(vmf->vma->vm_file))) > + return VM_FAULT_SIGBUS; > + > ret = vmf->vma->vm_ops->page_mkwrite(vmf); > /* Restore original flags so that caller is not surprised */ > vmf->flags = old_flags; Shouldn't this check be moved before the modification of vmf->flags? It looks like do_page_mkwrite() isn't supposed to be returning with vmf->flags modified, lest "the caller gets surprised". - Ted