Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2700585ybi; Sun, 9 Jun 2019 18:46:19 -0700 (PDT) X-Google-Smtp-Source: APXvYqxIfZiKG2NKDKI+1oilq1NEjVlqGGCsAbDh8GgL+3h4PpYBsZ+UXb1cbF9mogT9v3mMoOjL X-Received: by 2002:a17:902:324:: with SMTP id 33mr68159310pld.284.1560131179608; Sun, 09 Jun 2019 18:46:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560131179; cv=none; d=google.com; s=arc-20160816; b=FQt/uQqofWRgjqnLxBHwrrnxcLigHD+3aw9X2y9h3vc2cTJ2SXeNbKECEpmOFg1Ale 6G7gd5eLLp8mEFSh0I4WA7OW6InSLR0ZlJyV4ObK1jJEhlrEGY6/PuW1RuQbNLBrsPwT EuFAcKV0EZqyvvRyP8UN0HaMSFj+nIE8WB8bslinzsFlHnLqmCMZ+4e//G/48a+bnyzT 2yoeb8kLjzDIlZiHut2lTL62/jmFPvE+nocbzEwKYzCzgYBCo0NH1zABNCf6+4ao7vXO bu4nMC3TesISjrM6Vtr2jxVHs5wTr8Ri7aKJMd2YB0xF81g+ZqWnB61J5xRO/LoKZGmY a8lA== 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=agQ2QJU1XwbHQq46yP+XGXkj2wp9ZpFAIxnWm3mvt30=; b=ZNcLxBrKYe62/qLtwhivOlWDYTG6v2XhQw4pJorLPKs66Y40M1UZewN1t9ezkSIt7X bTyx5NlkFXgGWn6Guv728ywcppjcdUhWG8YbiFz2CTfp3LSZYGUnwtdIogou5VwCaPhX 9PBB0nxJdJa0kxPetTKkiSLtyQR8IirXTlJNgwXJQkh93CmN7dag/7CZIp+X/oQZzIID rciPP7bkjwYkTWO3CnyhtoVg6JGik4c9oo1Aszi1zPosJQzobLEqIAf6d9ZrQkM5jAPV pucAbF3GERkcWPwT1Xrj+66VFD3K+jBefvtMIRsiTkLoz144hiczCIBC9wLVNSSkNTpI iRHw== 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 f15si8308452pgf.303.2019.06.09.18.45.55; Sun, 09 Jun 2019 18:46:19 -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 S2387398AbfFJBnj (ORCPT + 99 others); Sun, 9 Jun 2019 21:43:39 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:49573 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1730055AbfFJBni (ORCPT ); Sun, 9 Jun 2019 21:43:38 -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 x5A1hTAK032337 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sun, 9 Jun 2019 21:43:30 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id A857F420481; Sun, 9 Jun 2019 21:43:29 -0400 (EDT) Date: Sun, 9 Jun 2019 21:43:29 -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: <20190610014329.GA3266@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: > From: Darrick J. Wong > > The chattr manpage has this to say about immutable files: > > "A file with the 'i' attribute cannot be modified: it cannot be deleted > or renamed, no link can be created to this file, most of the file's > metadata can not be modified, and the file can not be opened in write > mode." > > Once the flag is set, it is enforced for quite a few file operations, > such as fallocate, fpunch, fzero, rm, touch, open, etc. However, we > don't check for immutability when doing a write(), a PROT_WRITE mmap(), > a truncate(), or a write to a previously established mmap. > > If a program has an open write fd to a file that the administrator > subsequently marks immutable, the program still can change the file > contents. Weird! > > The ability to write to an immutable file does not follow the manpage > promise that immutable files cannot be modified. Worse yet it's > inconsistent with the behavior of other syscalls which don't allow > modifications of immutable files. > > Therefore, add the necessary checks to make the write, mmap, and > truncate behavior consistent with what the manpage says and consistent > with other syscalls on filesystems which support IMMUTABLE. > > Signed-off-by: Darrick J. Wong Thanks, looks good. I'm going to take this patch through the ext4 tree since it doesn't have any dependencies on the rest of the patch series. - Ted