From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-yw1-f181.google.com (mail-yw1-f181.google.com [209.85.128.181]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 794B5274FEF for ; Wed, 10 Dec 2025 05:59:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.181 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765346375; cv=none; b=nsGpadYm/ogHUCpFWkJJU7DVZjDgt1ga0FOQN1snDZUA9DgiPY8CKlHhHp1IaOQ/6d6DpZnqlfm7CsBtHSM8lpRG0khKcSYfNr5oxULjFlLB9G0uTEpfuEoZ3aLAzc+/z/t96m35K/jz/Q1iTl8Khcwsk82+ZfVBlNvsywo4CGo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765346375; c=relaxed/simple; bh=GTRCtGEyCPeIDAEAsYjvD8gFAZcZN/SMX8UD5Q3ZU7g=; h=Date:From:To:cc:Subject:In-Reply-To:Message-ID:References: MIME-Version:Content-Type; b=aYMYnA/BFUxHfB4pSbwLciUbnmcfUFCBYNLYvkXITmW7AGP+Scra4bKfiL9Jn0j0uIPccEr0TXNl9oIqrUv0+JK4xy7unPGXj6MhEifIwGVVGx96VAMUl+OFX0Y+2HhFhaly5EbtIAzMzJMMerfm7+H4Bbg73+0M820x+Cp1np0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=oqvK6JdJ; arc=none smtp.client-ip=209.85.128.181 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="oqvK6JdJ" Received: by mail-yw1-f181.google.com with SMTP id 00721157ae682-787da30c50fso64354537b3.3 for ; Tue, 09 Dec 2025 21:59:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1765346371; x=1765951171; darn=vger.kernel.org; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to; bh=AkKmEmlmy8ELaJoQUHf2BKQunA/3LKCRjsVDxaDzqrg=; b=oqvK6JdJFcG6MMgKCrtELZ1klGDw+kOoASSqR8Lb6xhVf7QYDkhbsDzLjHKCdcKmAu DG1Ylt948CufhY3YJO4lUhrgLZbAL+v43yg5fNadlfqVJ5LwJUrANax8QczEE6kf2OhR cu/3NTTpaBX0Dbn5OxLNfZdFVyPqioIfzYzHK8iVgct7mli9dapcW2leVuxNG23Sprt9 oLGiJ8i06f5S0VXVwRypTsj89R6mBVce+sz0hJ/dTX+7FU20EpStGpvRhGahauKXuJP2 cTbiFG/+IBDQZJkwF7MY2dOaNyw/T6RGzToaxamSHXAsfCavpLwZGDC3pI8vTp+4YkxS CXsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765346371; x=1765951171; h=mime-version:references:message-id:in-reply-to:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=AkKmEmlmy8ELaJoQUHf2BKQunA/3LKCRjsVDxaDzqrg=; b=E8+8QtoEDIJTLvSJw1QNGl/vKzCm1shyTisuN7ujqaLwthWSZQd3XmRM7no1A8HY+R 94AsaG83vDYS9jgbXrzd1tCRlJdEOm6a/JugdqTZyDNfmoENmo7OU2HubQdarRqHtVLh P7GKGLjvgC0EQe/g67FlUMpkos7zzOMesnCGgHhkGJJqJuZ2NtSUVbMbIs8T4V8MdWf6 qoF7M7RWX+EEglxrteLMI9unSM6Z8efwIP2fdD/l7R/Xtnun8v6bnF5ALNH4feoFu/oB cPDEnXFS1AnjX13vrCX4/zXRf+OIp0YLKkDOOHXc44kiOSux7zoPIicWg2g+6k7ESb/r vj3Q== X-Forwarded-Encrypted: i=1; AJvYcCUIJ6r/pyzN7jiZNyd/ARZ0XD91VV6xkq38++DLyKQ4V70UqwguEyeiXz8Fl7mtaUT4BZmimAzlgMeURic=@vger.kernel.org X-Gm-Message-State: AOJu0YwVzCMyDeYif/6ADKUyhc0C/T/xLU5R0AgHtOxArV2rvi/lHpEJ QuynPhZ9cb54usR9BUT9BGLC8uwEyWpYOe7E/bGbictxYz5UAxfD3vtI66W/z3RZ/w== X-Gm-Gg: AY/fxX60g9sA+J9TpibzpHHJkQ2IJgattH8OcBbS0OzMZIPuxJAIGXNQrce9ZWRKq7X KcAQEr0c0iKoL/sHQhlzihKFgDbZpXs5Y4j41MD6gHkiSxVXGj5VNFqlTOQ6Kl/X4U1sZnOFjcx j6glzqmrQ4BlbAZxgbCRMzR5OXINetL7oV4WXGBuP1WK77h1eBY0mREPvwX9okfjXTeE2VMHFlB Fk0BoDZv3eScsLaFcjfPNUBN7J1QeMJ2HV4mV1cEulLW0o2EWoRPorabzOUetU9OSAGtB/qYOgt jTFTvskVQy9Xg8XCV7UMvudeLZKKmvCBPQS9ksqDYRmXWnAz+HYjmp9zv65v/U3T6WNWJGk2C4I uqcD7YmoxZ250JhUSmbD+1KUJGcqGy2vOPDk7ytRbomIOxZ71oovvDAjbBuWonu+juOMzldruz7 iVocKwJn5KKcHwMdnSnCbgg3LdWnD09SecMKSAT5CO7R9dgULiYtZ9otwbDtgkhStzJDMFmrRg4 AJ+LnwEag== X-Google-Smtp-Source: AGHT+IHnYfs/FNwfsBlpEOywYrB4YmggQz7ScEEsHZ6ji5edm/7oBhWYVx7J+CQpa4h3kxU6P5oVKw== X-Received: by 2002:a05:690c:3382:b0:78c:7b51:bdf4 with SMTP id 00721157ae682-78c95a4faacmr21928597b3.13.1765346371280; Tue, 09 Dec 2025 21:59:31 -0800 (PST) Received: from darker.attlocal.net (172-10-233-147.lightspeed.sntcca.sbcglobal.net. [172.10.233.147]) by smtp.gmail.com with ESMTPSA id 00721157ae682-78c1b779458sm67535757b3.35.2025.12.09.21.59.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Dec 2025 21:59:30 -0800 (PST) Date: Tue, 9 Dec 2025 21:59:16 -0800 (PST) From: Hugh Dickins To: =?UTF-8?Q?Ahelenia_Ziemia=C5=84ska?= cc: Hugh Dickins , Baolin Wang , Andrew Morton , Matthew Wilcox , Christian Brauner , Theodore Ts'o , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] tmpfs: enforce the immutable flag on open files In-Reply-To: Message-ID: <57e2e227-e464-bd7f-f69e-573a772cd4c5@google.com> References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="-1463770367-805250018-1765346370=:9638" This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. ---1463770367-805250018-1765346370=:9638 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: QUOTED-PRINTABLE On Tue, 9 Dec 2025, Ahelenia Ziemia=C5=84ska wrote: > On Mon, Dec 08, 2025 at 08:14:44PM -0800, Hugh Dickins wrote: > > On Mon, 8 Dec 2025, Ahelenia Ziemia=C5=84ska wrote: > > > This useful behaviour is implemented for most filesystems, > > > and wants to be implemented for every filesystem, quoth ref: > > > There is general agreement that we should standardize all file syst= ems > > > to prevent modifications even for files that were opened at the tim= e > > > the immutable flag is set. Eventually, a change to enforce this at > > > the VFS layer should be landing in mainline. > > >=20 > > > References: commit 02b016ca7f99 ("ext4: enforce the immutable flag on > > > open files") > > > Signed-off-by: Ahelenia Ziemia=C5=84ska > > Sorry: thanks, but no thanks. > >=20 > > Supporting page_mkwrite() comes at a cost (an additional fault on first > > write to a folio in a shared mmap). It's important for space allocatio= n > > (and more) in the case of persistent writeback filesystems, but unwelco= me > > overhead in the case of tmpfs (and ramfs and hugetlbfs - others?). >=20 > Yeah, from the way page_mkwrite() was implemented it looked like > enough of a pessimisation to be significant, and with how common > an operation this is, I kinda expected this result. >=20 > (I was also gonna post the same for ramfs, > but it doesn't support FS_IOC_SETFLAGS attributes at all.) >=20 > > tmpfs has always preferred not to support page_mkwrite(), and just fail > > fstests generic/080: we shall not slow down to change that, without a > > much stronger justification than "useful behaviour" which we've got > > along well enough without. >=20 > How do we feel about just the VFS half of this, > i.e. open(WR)/chattr +i/write() =3D -EPERM? > That shouldn't have a performance impact. I don't think tmpfs should implement half of the ext4 behaviour (at write time) and not the other half (at page_mkwrite time): it would leave IMMUTABLE on tmpfs as neither guaranteeing immutabiity, nor behaving in the way IMMUTABLE was traditionally supported. I do think it's surprisingly asymmetic, that IMMUTABLE should forbid opening for write, but holding open for write should not forbid setting IMMUTABLE. But that's the traditional behaviour, which surprised you, and which those ext4 mods improve upon for ext4. But I couldn't find any filesystem other than ext4 and f2fs implementing it that way. If the VFS and other filesystems agreed to implement the stricter IMMUTABLE (I imagine relying on i_writecount), then tmpfs would probably be glad to participate; but not go its own way. Hugh ---1463770367-805250018-1765346370=:9638--