From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=209.85.222.181 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796078520; b=xI5S5n8xBt68nag3ltMb8ZjswVeDsfgd06kyNN4MouyP7QIlYQ4pHcM3VWujKeclVH52 uzNnSwx3CiXa139ewwg3lYvMaI4+ta4l57k15ltNVU5Ey0/YDu0tR294Udi+mmiTxAEGK fNTxM3FvHq/hivL1+0GgC7krgp+EecCO7BawwxkhTYE43HS/J0jLWmiA9vI4/IAa2//Ly cQkzQ3D4f6sk2nJTrl7LZC6rr4SUroSiEZXm8a2rPFFsYo5A6rDxOoXg94uYZmfRS6kdc cmm9mC570iJ9mMcpclqlLeh+vsViNZDXrXJv9dWNo9RC0RQ3v5VZEwfbJT+MJOnVfGA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796078520; h=DMARC-Filter:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received:Received: MIME-Version:Content-Type:Content-Transfer-Encoding:Subject:From:To: Cc:In-Reply-To:References:Date:Message-Id:X-Mailer; bh=2Ti4oC34FwT9UyrsVvfSJW0F8NguvOmdJxqFC8bZEq0=; b=bAq0QbEEzNrteGdyCwLpe/+VTCfRdOI3VFPS1iSZgHvzVxRtpZGgKV36SnTZEced5sqj r128XcU3+9TivUhB/UNN6IUUM+tZuYl5I96VpLsILrct+nXXN/htIGkOKiFAhjXit7jpT KfFQsDh0iwj04q56D8IjrRZEAICH8zdr06jr3paMA+U7/ziap9CcEOsLLJcphDaEbWo/G 8jvbm1/Pb6dvnIK+mmpJYZ3fBc9Y8+h9uvbB74JKZuUYxKXFqkGLf9CZL7jm/LFuEutDi yC3w2joYACuzfG3MNDO1k3pf9wqxj7Qfkn/Kf2WNqX7yl2c8tGgNzlaP4Uqug2liAXA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=W84Yp4vy; arc=none smtp.remote-ip=209.85.222.181 Received: from mail-qk1-f181.google.com (mail-qk1-f181.google.com [209.85.222.181]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E7069606A320 for ; Mon, 30 Nov 2026 22:41:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org E7069606A320 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.a=rsa-sha256 header.s=google header.b=W84Yp4vy Received: by mail-qk1-f181.google.com with SMTP id af79cd13be357-94960131b30so1002684385a.0 for ; Mon, 30 Nov 2026 14:41:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1796078518; x=1796683318; darn=vger.kernel.org; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:from:to:cc :subject:date:message-id:reply-to:content-type; bh=2Ti4oC34FwT9UyrsVvfSJW0F8NguvOmdJxqFC8bZEq0=; b=W84Yp4vye86SFhU6H/Vf4is25k9K+x5C1srqJFn4NnfJtVtLC3PP5qL8ibM9H2x5hp uCzJBgYQe70GN+dDVBOSoBNyFLDQ3hNX653Tszy2WwZG8erP+E0INMQBM1tGqY/+Fjnl IYzI9xl+vk/zZD2uKNLn4CYgbVBXYrm2PltieXevE29lPS74MlmZ9HacYdC7m1Y0ba5C 6Fg2S3iU2k0YqhvE4/5CC3J96i9nJAy/za378EVIckAN0XLRLq7LT8sCUMaGnDH+UUII wD4/mxsZyvTHgH7NV4AVzSi8zqpbM/9rtWPy5A/i//T3QsoDSHLhY2yAA+j/Njs/jyiO HgLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796078518; x=1796683318; h=message-id:date:references:in-reply-to:cc:to:from:subject :content-transfer-encoding:content-type:mime-version:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=2Ti4oC34FwT9UyrsVvfSJW0F8NguvOmdJxqFC8bZEq0=; b=pu8Mpqa5jy95FX+kmFa7fyu20DyYEL/SdauOCpxcwclJO7g+JCw90C8gQBQkBynqdl Jaq50cB3ZLsdBug5jg4VZ89gdE16OarV5WKXBiTuA+wjtsIQGoIINVAWwhDeGKIHaL57 ciL5U0S9fp3aXJL4ddkW6+wOu5w3Xhh+EL9hmJ0o2/VocK8dXVjIklY2ed99bh4uzqX0 mG1QwAdFb3MAfu/K916lDLd7MjugmacMiof5G4Ui1E4rAjGkzmsFremBYEgdhU211AwM IBofdGwyyr+eIZ325jkGRWFH1RAYTPvtvgcoi1ME2glorvdNWyHCsd/qjMKtuq+8Zu5i 7EqA== X-Forwarded-Encrypted: i=1; AL+hErF8tuwEkBB2alIqD5YFEC6UYeB8OH0c/QX1HdvAIh8pJsgjkYEu9eOuxI8GwQRkdBU/C3NPmdouQeXqa/I=@vger.kernel.org X-Gm-Message-State: APuU4Z/N4aL5IOob9eQbOjWPSYyM9ANWKYv7GblOj5cQpkIrih3siuM/ YxcJDn/cjWBxf085mbluPFKW5bCHtyRHJIE+7pZONLOvjWUoM5fL0Ms3S0EOPKGY7eA= X-Gm-Gg: AZFdTZd4gr3A0ALYl9e2ZfYNbV1LlJIEkw3tIB0UkX24Xmzg3Ux2OGvvRIFe2dHnAI0 Df5tjb+Ugv7Us4dzyIXEHZjmi54OHpf/pAx9DvnAsBYKere7SRc2UbunSOWd6LPYC4YY7MApQtN qdkqI7sbdPWIddhPLSBqGMjNdNT8Ww4D02iJeJkUHlPeckuTezz8Yv2WO6wTxldiMFhzier6OMz 4OSFqgRsAyJJRCPsg0i2h0JEgLvoxBbdRHptpNIcWoPzjKWKJ97BYibv4me4tXZx7kiq31zKLh8 39vtlwU00my9pfY4O332WrWrTMHNmHLNsUqZdvkQ1msm1za98uj7n6dTrbWRfzOC2WAZhNotho5 gJ7Q+USQoJUxkAHuezCA6sDUKCxLXJCuJGzXzSWihITyeA6hR/upxVsPoFLAQjPXSoghv0dc6Wx E+NyjDdFI0dnELgtrWAjxBbPqbOQw7uIMnHgPxbiFiu+73V03g/mz7LPrJYLr+n0CqF0ap1ErlQ 2/4iga6P2fooooN8ylnKCRs6bW8ilR61Pi1KFg3Bm9PKvGfYv0EM69410nDiwnPhQBNmgTLTO7q 7fL9hiupkAfJYrvn7Eu8MAzC2f7PEiJNAENLfqJnlc4+hUCmVV0eqXxEFnqYhknVfOFXboG2DnL D0DEfRC6rH2exUhZ1/1iBmNQNntvN X-Received: by 2002:a05:620a:27ce:b0:949:9388:41db with SMTP id af79cd13be357-949ba9f1bcbmr6728232885a.58.1796078517821; Mon, 30 Nov 2026 14:41:57 -0800 (PST) Received: from [192.168.50.231] (pool-71-191-145-202.washdc.fios.verizon.net. [71.191.145.202]) by smtp.gmail.com with ESMTPSA id af79cd13be357-949ca6a0693sm2422051385a.20.2026.11.30.14.41.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 14:41:57 -0800 (PST) X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Subject: Re: [PATCH 06/32] mm/shmem: seal the size of SysV and shared anon files From: "Gregory Price (Meta)" To: "David Hildenbrand (Arm)" Cc: Hugh Dickins , Baolin Wang , Andrew Morton , Mike Rapoport , Peter Xu , Michal Hocko , Kiryl Shutsemau , Manfred Spraul , Davidlohr Bueso , Cyrill Gorcunov , Zi Yan , "Liam R. Howlett" , Nico Pache , Ryan Roberts , Dev Jain , Barry Song , Lance Yang , Usama Arif , Lorenzo Stoakes , Rik van Riel , Vlastimil Babka , Harry Yoo , Jann Horn , Yang Shi , Zach O'Keefe , Song Liu , David Stevens , Kefeng Wang , Alex Williamson , Suren Baghdasaryan , Dave Jiang , Matthew Wilcox , Miaohe Lin , David Rientjes , Shakeel Butt , Jan Kara , Mel Gorman , Jason Gunthorpe , John Hubbard , Gerd Hoffmann , Vivek Kasireddy , Dave Airlie , Matthew Brost , Joshua Hahn , Byungchul Park , Gregory Price , Ying Huang , Alistair Popple , Hagen Paul Pfeifer , James Bottomley , Felix Kuehling , Alex Sierra , Balbir Singh , Kairui Song , Qi Zheng , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , Oscar Salvador , Muchun Song , Dan Williams , Rakie Kim , Hao Li , Christoph Lameter , Roman Gushchin , Sebastian Andrzej Siewior , Clark Williams , Steven Rostedt , Alexei Starovoitov , Xu Xin , Chengming Zhou , Shivank Garg , linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-rt-devel@lists.linux.dev, SJ Park , stable@vger.kernel.org, Chris Mason In-Reply-To: <20261129-fixes_core_3-v1-6-f66094116801@kernel.org> References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-6-f66094116801@kernel.org> Date: Mon, 30 Nov 2026 17:41:55 -0500 Message-Id: <179607851565.412063.2683253406086915180.b4-reply@b4> X-Mailer: b4 0.17-dev On 2026-11-29 11:06 +0100, David Hildenbrand (Arm) wrote: > A process can resize the underlying shmem file of a SysV shm segment or of > a shared anonymous mapping through /proc//map_files. > > We account these files by their size when creating them and unaccount > them by their size when destroying them, so resizing them can underflow > vm_committed_as and the RLIMIT_MEMLOCK count of SHM_LOCK, and add pages > that are charged to neither. > > Consequently, an underflowed vm_committed_as lets the whole system commit > memory beyond the limit of vm.overcommit_memory=2, and the RLIMIT_MEMLOCK > underflow triggers a WARN_ON_ONCE(). > > Since commit 77142517990f ("shmem: update memory reservation on truncate") > we adjust the commit charge on truncation, but not when writing or > fallocating beyond EOF, and we never adjust the RLIMIT_MEMLOCK count. > > Let's fix it by sealing these files against growing and shrinking when > creating them instead, similar to what is being done for SysV segments on > hugetlbfs [1]. > > Truncating such files and writing or fallocating to them beyond EOF will > now fail with EPERM, and F_GET_SEALS will now report these two seals. > As udmabuf requires F_SEAL_SHRINK, it will now accept these files, which > shouldn't matter, as obtaining an fd for them requires > CAP_CHECKPOINT_RESTORE. > > It's highly unlikely that any user would rely on this: e.g., CRIU only > maps and reads these files through /proc//map_files, and only > resizes memfds. A search didn't reveal any other relevant cases. > > This has low urgency, as it requires CAP_CHECKPOINT_RESTORE. > > [1] https://lore.kernel.org/all/20261125-hugetlb_fixes_2-v1-17-db27fd2f71a8@kernel.org/ > > Fixes: 640708a2cff7 ("procfs: introduce the /proc//map_files/ directory") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) reproduced the wrong seal reporting and that previously successful operations now fail with EPERM Tested-by: Gregory Price (Meta) Reviewed-by: Gregory Price (Meta) -- ~Gregory