From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.110 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796201949; b=GWePXLMSyaVhBgKLtOLz/9BcWsdGxqwKOFiblRcs6nkmWEaYwX4svpcSJ0gSzpg0X43T XrG/ys0xaemmJbe4MK7aXgZjGJO6cYqneoVXfKoSEWVxbFbdAPpKz6PJxCsDLNiS3rFFt dvDPCJhspwIgU7ckttjVvJL6HyCdYNJ9zFWdPJt2g1BFWxgsOin0Ga5j2EXnaeZoI5VQn zjcougULorxORwEk2LpdkhlPfOdYB/edP1v+3WVFpANtTKDwNeCj4qnHi+2dg93pLcKC2 UuHsxLImPphw+Yw/nPV8A7IFp1hSr78J/VPKJAKh9kCLODHowiRgwkDQDGroAS75rjg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796201949; h=DMARC-Filter:DKIM-Signature:X-Alimail-AntiSpam:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References:From: In-Reply-To:Content-Type:Content-Transfer-Encoding; bh=Pdt04Q+lP75LEv98gsQarQnrKp2EgQoWKPkV0LudkTA=; b=fpsbFX8y8dOB4bAMnmiayIiHF+nXwypPE4cE2PeJG5qJ8qLNnr0ZMb8L6jRwn9Dilldy O8QXU6vG8ZMFDJ/015lyt9IfLFaNQ0MX1syQUcJHUb1ZRZNytwtkXX/49vMfT5KN314jb wG1bmmeUGeH7dcFsr5mZHZF4O/F0JTo2kCjzLEhAnj2v0HCmT1FLpK4JQcCjp6H3IEDIw h3McUwSXOeOaVXZ1qPPCMWHDdLgILDIJ1MC82NF9n0pnSYvxwNXJP1wH9q3AScWEWj2ep fIb1yjXljZ4W5drjhc+R3wbVczHR99y9jhb0nNoyWri+S/e4IjCb0p27+OwkA9AQ+gQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=CPwGrUXE; arc=none smtp.remote-ip=115.124.30.110 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C3B7E606A327; Wed, 2 Dec 2026 08:59:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org C3B7E606A327 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=CPwGrUXE DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796201944; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=Pdt04Q+lP75LEv98gsQarQnrKp2EgQoWKPkV0LudkTA=; b=CPwGrUXE8Hkafc6+FLo7TiYH9SMzkj2UXLPEFE71l6MVH3F+IJEZT0H2thXv4Uc7iYwWwIOvmb5vMpjPMFjRFpdlgFksSOoV6ja5DNhFi+yGqBixCtBtwIwWsim6qtwmF+wQ+uomUpd6JiKB2yYpgIY8Of89oeO1kRsziLXTf9o= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R141e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037026112;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=81;SR=0;TI=SMTPD_---0XG95GVL_1796201935; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG95GVL_1796201935 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 16:58:58 +0800 Message-ID: <1bdd5934-39e1-44c6-b9c5-6bbac87eeb24@linux.alibaba.com> Date: Wed, 2 Dec 2026 16:58:55 +0800 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 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 06/32] mm/shmem: seal the size of SysV and shared anon files To: "David Hildenbrand (Arm)" , Hugh Dickins , 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 Cc: 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 References: <20261129-fixes_core_3-v1-0-f66094116801@kernel.org> <20261129-fixes_core_3-v1-6-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-6-f66094116801@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/29/26 6:06 PM, 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) > --- Make sense to me. Reviewed-by: Baolin Wang