From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.131 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796200326; b=Adnx6AWRFhmnSIlh7YCtRMAyr7aayqeX/AcZ5HW56PyTYmxAldoOOExFOmfGBH+5+5J4 yZw5xPu7UGFRWgE3i+NDCKgH9PnbvUcJ7KTc5Q0GTUPHFLnEcHLfxDQvJFTP/UiLGsdpn bo+99hk9PVfjvwKJ60bF2GbAXaXVg6JwxPL3Q2236zjOQNyCMaxIFBuQnrwC9/3csX0yS qVSXxL8pY474tU0Mke2ArFbn4O3MwzwBQNglCdxLnRy0eTBZodtrKTcF6c3d1q/d6Z2Xr Wh86WA/Qr49sv+2+kvocKIGKmnBCQLBw/CLo2HQWw7vzVn9wCGc+JqSp9f8DkDoeN5g== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796200326; 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=vJF2nULP1HV2KdgZZN4783ExZJRHxtgruPatlGfKziE=; b=HA3cXi22Me+ethCasWuFN8EmrSWrw47spxmig4VwZXKELkZLnfuJrF5btSjLgXR+SR6i 7NIPjCOLprFmFZmIei7yHDHkmb4EnX+Xc1MTcaRVAM9XvOJ02DeLsKAWiuI9kVPLSfsUu IR8OYfgL7jHPezhUuuNRVMwIixtQiqGlaX2bmniBJ0dDJ39yKcCWNJk0cvgQ2Ec/mkFeg rVRJmISP4dA+2qySbJJ2Wit3LB/kKv8VJy5oSUGgN2lasqvzPYIZGA6pwMxWPWb1xDpH5 tqY5rVTnaVuphlxR/oxNrYq99iEIABp35Wt7qhhGxB6n2dJGKGHav6bjonJodE48eWg== 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=ixnA3bTG; arc=none smtp.remote-ip=115.124.30.131 Received: from out30-131.freemail.mail.aliyun.com (out30-131.freemail.mail.aliyun.com [115.124.30.131]) (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 ABF97606A323; Wed, 2 Dec 2026 08:32:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org ABF97606A323 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=ixnA3bTG DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1796200322; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=vJF2nULP1HV2KdgZZN4783ExZJRHxtgruPatlGfKziE=; b=ixnA3bTGOBoKyrcKsKLpzcfl0oAVJiYCPq60JWIgvP2Xs/C1tCmVaC8GqL89PJpHpXQSFVniPS9OX6oKq3Z/PUpF2eeGyu7+RqonckDx/SmKzCe/E9ihar+7r7H44aQKwY4/VfIn7quQpb0LI1ZssNhdoI2T/aesFPZ3XEQriwg= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R921e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037009110;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=81;SR=0;TI=SMTPD_---0XG8XEoq_1796200313; Received: from 30.74.144.133(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XG8XEoq_1796200313 cluster:ay36) by smtp.aliyun-inc.com; Wed, 02 Dec 2026 16:31:57 +0800 Message-ID: Date: Wed, 2 Dec 2026 16:31:52 +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 04/32] mm/shmem: fix commit limit bypass with very large shmem sizes 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-4-f66094116801@kernel.org> From: Baolin Wang In-Reply-To: <20261129-fixes_core_3-v1-4-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: > VM_ACCT() uses PAGE_ALIGN() on a loff_t, a signed type, which overflows > for sizes in the last page up to LLONG_MAX (MAX_LFS_FILESIZE on 64-bit). > > With the default shmmax and shmall, userspace can trigger this through > shmget(IPC_PRIVATE, LLONG_MAX, IPC_CREAT). > > Consequently, the resulting negative count makes __vm_enough_memory() > succeed and lowers vm_committed_as such that it will go negative. This > effectively disables the commit limit with vm.overcommit_memory = 2 for > as long as the shmem file exists. > > Let's fix it by avoiding PAGE_ALIGN() and just using DIV_ROUND_UP_POW2(), > which cannot overflow. We now reject such problematic sizes with ENOMEM, > like any other size above the limit. > > On 32-bit, VM_ACCT() can still return numbers that don't fit into > the long that __vm_enough_memory() consumes. However, only ftruncate() > to 8 TiB or more, through an fd obtained via /proc/$PID/map_files for a > shared anonymous mapping, can trigger that, which requires CAP_SYS_ADMIN > or CAP_CHECKPOINT_RESTORE. So we'll leave that alone for now. > > This has low urgency, as it only affects systems with > vm.overcommit_memory = 2. > > Fixes: 09cbfeaf1a5a ("mm, fs: get rid of PAGE_CACHE_* and page_cache_{get,release} macros") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Signed-off-by: David Hildenbrand (Arm) > --- LGTM. Reviewed-by: Baolin Wang