From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=115.124.30.130 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1793591554; b=E09TPEfHaAmQmg4ZifugMCwEIbQ1RDbDUBeOImIVfmKCnEy9nKxoJp0w8MuKtHZiWsQ7 QELFtODJnpVxJRgEnRbj0dnDAl+nE+Gyotfr+kww+Hny3aa9UzFcwC3NdyGbNl9nySz4B E6HJvhtWeaQPGOD9JsTbjfQTPCMoCJy78WboUGNqz+XimLfgDYWWII2/HEwyfYszMJcEL szbiIGt/NxSyC/M5qOKjuv9NGqE0OSK+6t0e7sCCxd7q904OKd1d0RdVNSsC4vgRkHfff FrW1WXqLScxiTfZyKppHbnmvSE/Zca4UkKjCpQ1LudKG78Q/KUnsO9r+Wx3XygmXpuA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1793591554; 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=UsyOruPU/4uzHcmKvCXiECAPVPbvFO7B0tp+W3CdJrI=; b=v9Eo0pEypBTt+sYV/RqDvG71QtehyaoAEW8EwL0AZKouM4sQ+yAzn5dTjOPfMzsCSDtc +Zp11JaNvy6IW2gJSWmvMEis/eRjTKa7DWpSWYrM3DF5hJM4fYsnmlAN1+Knr8GkGhzBR 8Cfd14iyiHURedOCQmbMkcYAb3ZKvlpKHP4JkVYPrS8uZcHr+TKWqR+6uocpy9bi5G25q YZA41HV2Lb0YNoEL00h1SFpavgkm5+I3N3fueJsL+txUGKWtFmNxm51urAHG2R6V3AxTS rWVu4cCHNKE9CIc4BTT2z+CbmRcCzwwBeowSXjk3s67xmtzAvlq/rCWf9sweuex4c8A== 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=YuLJD6aa; arc=none smtp.remote-ip=115.124.30.130 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) (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 CB4CE606A324; Mon, 2 Nov 2026 03:52:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org CB4CE606A324 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, unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=YuLJD6aa DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1793591543; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=UsyOruPU/4uzHcmKvCXiECAPVPbvFO7B0tp+W3CdJrI=; b=YuLJD6aaRbBiLnm3A58MYJlJirznc7UZkbvfmHSz8ZsaGLWCBdLt1bvaMeXvpxnAJwWKWTrl9K4jcZncte9Va/POuK6mPuOFOV0nA/f1nMLb9JI2mb08eNgpTZMLFPskdgZiJCtoO1qW1xSjbuFotKYhbFU+wU6a5QVKUiYn5zI= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R791e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033032089153;MF=baolin.wang@linux.alibaba.com;NM=1;PH=DS;RN=65;SR=0;TI=SMTPD_---0XDsjDyn_1793591534; Received: from 30.74.144.167(mailfrom:baolin.wang@linux.alibaba.com fp:SMTPD_---0XDsjDyn_1793591534 cluster:ay36) by smtp.aliyun-inc.com; Mon, 02 Nov 2026 11:52:15 +0800 Message-ID: Date: Mon, 2 Nov 2026 11:52:13 +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 v3 03/47] mm/shmem: make shmem_file() check the file's inode To: "David Hildenbrand (Arm)" , Andrew Morton , Johannes Weiner , Michal Hocko , Qi Zheng , Shakeel Butt , Lorenzo Stoakes , Kairui Song , Barry Song , Axel Rasmussen , Yuanchu Xie , Wei Xu , Baoquan He , "Liam R. Howlett" , Vlastimil Babka , Mike Rapoport , Suren Baghdasaryan , Michal Hocko , Kees Cook , Peter Zijlstra , Jann Horn , Pedro Falcato , Hugh Dickins , Pasha Tatashin , Pratyush Yadav , "Matthew Wilcox (Oracle)" , Jan Kara , Zi Yan , Lance Yang , Rik van Riel , Harry Yoo , Alistair Popple , Nico Pache , Ryan Roberts , Dev Jain , Usama Arif , Kiryl Shutsemau , Matthew Brost , John Hubbard , Peter Xu , Will Deacon , "Aneesh Kumar K.V" , Nick Piggin , Oscar Salvador , Minchan Kim , Muchun Song , Xu Xin , Chengming Zhou , Chris Li , Kemeng Shi , Nhat Pham , Youngjun Park , Gregory Price , Joshua Hahn , Rakie Kim , Ying Huang , Jason Gunthorpe Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, kexec@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, linux-cxl@vger.kernel.org, stable@vger.kernel.org, Chris Mason References: <20261031-fixes_core-v3-0-d6437171ecc3@kernel.org> <20261031-fixes_core-v3-3-d6437171ecc3@kernel.org> From: Baolin Wang In-Reply-To: <20261031-fixes_core-v3-3-d6437171ecc3@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 10/31/26 5:39 PM, David Hildenbrand (Arm) wrote: > shmem_file() only checks if file->f_mapping is a shmem mapping. This > mapping can belong to another file, however, as with a Coda file backed > by a tmpfs container after mmap(). > > So it does not guarantee that the file inode is an actual shmem inode. > > Seal handling and memfd preservation use this check before accessing > shmem inode state, so they can access an inode of the wrong type. > > Let's make shmem_file() check the inode's file operations instead, to > identify shmem inodes reliably. This will identify regular shmem inodes, > including memfds and ordinary tmpfs files, independently of wrapper file > operations. > > Use shmem_mapping() in collapse_file() instead to not change the behavior > of collapse_file(): it operates on the page cache and uses mapping->host > for shmem inode operations. Focusing on the file does not seem relevant. > > Fixes: c49fcfcda8b5 ("mm/shmem: update file sealing comments and file checking") > Fixes: b3749f174d68 ("mm: memfd_luo: allow preserving memfd") > Cc: stable@vger.kernel.org > Reported-by: Chris Mason > Suggested-by: Pratyush Yadav > Reviewed-by: Pratyush Yadav (Google) > Signed-off-by: David Hildenbrand (Arm) > --- Make sense to me. Reviewed-by: Baolin Wang