From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13E19C5B552 for ; Mon, 9 Jun 2025 10:18:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 703636B0096; Mon, 9 Jun 2025 06:18:49 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B4256B0098; Mon, 9 Jun 2025 06:18:49 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5CA9E6B0099; Mon, 9 Jun 2025 06:18:49 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3DCC46B0096 for ; Mon, 9 Jun 2025 06:18:49 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E439B12187D for ; Mon, 9 Jun 2025 10:18:48 +0000 (UTC) X-FDA: 83535463536.27.615B8E1 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) by imf05.hostedemail.com (Postfix) with ESMTP id 7E445100006 for ; Mon, 9 Jun 2025 10:18:46 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=11zMFZTr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="+q5k/oef"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TZJRvWOL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=6Xknxy53; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1749464327; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=lLu2PYhhLFvmoqjPyHQGzIdkpfrvEfN1IyEqTgHPDIs=; b=evuDxr0JplSZ8Icyc2QAdekbOpk8kE0XhGLKPbUV6Vxa3FcxKJIsz6P8KNuyo8GAFgc74B p3jajvlQbcw24SS3y57J7vN82GfkjBxpHdkZztc4UxXOZlGzj8HDaNFvhDNpJ0TSUx3pJd hO4z+elUyfsXY8GTEwyXYIK8SBRv5ME= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1749464327; a=rsa-sha256; cv=none; b=66BsAcPKNHScFRYkheHM9aRR6DlnDVkjMpchdIJlnP/9Vyks/59ken3tLjbaWJgrVApuph FM+8woeRGJczWKpvs8x7t119GTxobokTmfVOj5QntDZqCvAstzFNT1W197L68jp7/RK57A +MVQNEh7rI1x/Uxym9Ze1QraSdDl7UM= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=11zMFZTr; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b="+q5k/oef"; dkim=pass header.d=suse.cz header.s=susede2_rsa header.b=TZJRvWOL; dkim=pass header.d=suse.cz header.s=susede2_ed25519 header.b=6Xknxy53; dmarc=none; spf=pass (imf05.hostedemail.com: domain of vbabka@suse.cz designates 195.135.223.130 as permitted sender) smtp.mailfrom=vbabka@suse.cz Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id DBD8221185; Mon, 9 Jun 2025 10:18:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1749464325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lLu2PYhhLFvmoqjPyHQGzIdkpfrvEfN1IyEqTgHPDIs=; b=11zMFZTroGbF22Zg57HPIzEniGUNzzxFEO+QdSdFJLwBFIiP6BrIQKDv3FmUPDu1wbx1tg pzN2XpUE6OP4tM2t61iso06AJyOY2lU0nez5iCXNYtA8PiPDtlXyV+h15v0wkHaDKKQzbB Z1mQWtlrysEIg7ApZP9JXyuDsOvSYRw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1749464325; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lLu2PYhhLFvmoqjPyHQGzIdkpfrvEfN1IyEqTgHPDIs=; b=+q5k/oefSrPJTTw0Jm+a8ikAhhJnqE199XEawSQO0F9ooChMOXSDcGbq1c6+9ds2vx2K5Y rnlbN3II2uDGsXCg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1749464324; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lLu2PYhhLFvmoqjPyHQGzIdkpfrvEfN1IyEqTgHPDIs=; b=TZJRvWOLkN69a6/fSj+CRJ/fvUSyuBZ7Qh/OfdRdSH+5278i6oBTOlfiCEp6QHWdfgsGer fVVbPdT2jUKfix2dVX3NqUhUQOEGeVm81/PtNSHNCfrVhKNJvdy9VJkgWRr7vTCQj2uz1X CxFBE8xBc4hxyk6eLZ+YOi0qnBtEgfU= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1749464324; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lLu2PYhhLFvmoqjPyHQGzIdkpfrvEfN1IyEqTgHPDIs=; b=6Xknxy53gri1TPO7vGTjGnLn5m7Mm/lDvulWPOW+asRzDm3S4xr+AQtXjtm+9pNxFgitQL DplbhbAZRhFHqCDg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id B476F13A1D; Mon, 9 Jun 2025 10:18:44 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id pwyPKwS1Rmg4KAAAD6G6ig (envelope-from ); Mon, 09 Jun 2025 10:18:44 +0000 Message-ID: <30533e96-75f9-4568-add8-05a0be484cfe@suse.cz> Date: Mon, 9 Jun 2025 12:18:40 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm: add mmap_prepare() compatibility layer for nested file systems To: Lorenzo Stoakes , Andrew Morton Cc: Alexander Viro , Christian Brauner , Jan Kara , "Liam R . Howlett" , Jann Horn , Pedro Falcato , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org References: <20250609092413.45435-1-lorenzo.stoakes@oracle.com> From: Vlastimil Babka Content-Language: en-US In-Reply-To: <20250609092413.45435-1-lorenzo.stoakes@oracle.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 7E445100006 X-Stat-Signature: m9fimyib1raa3kmaah676uqo61oraumx X-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FYzaumothHBAnq6D5+f+PA/n7z2IfpSnTeC8tm5J6pUv5l+r+1o+niJ4WANatCsL4IZcboGY7Vc9OX4tLsVfS6hU55VGVd1xuxJeMAhgBMcDiiqXKRubPWUObIiaxgQU4RkzjYv65Etoy6vF8up+UXDZB2JIdgB2siq5LAnKsLHhqiJ5AJ8zhqe1nF59zFi40UaTt0ZRQVHdsslN6bzZiuqKk8HsIFiY0r0tvm6E/yFkzocSeDiX6HK4oc/oeVqaA561kX1lCrXVAntodR/x7+efkrjlFQwZwHmq+qH7ODlD0MRcZsXHWHq7uFx9WWPNkv/ez8K4Dhi/JtNdkgN0JRxlvD97W9bJICEjHph8DzjL7P0IyLDg38= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On 6/9/25 11:24 AM, Lorenzo Stoakes wrote: > Nested file systems, that is those which invoke call_mmap() within their > own f_op->mmap() handlers, may encounter underlying file systems which > provide the f_op->mmap_prepare() hook introduced by commit > c84bf6dd2b83 ("mm: introduce new .mmap_prepare() file callback"). > > We have a chicken-and-egg scenario here - until all file systems are > converted to using .mmap_prepare(), we cannot convert these nested > handlers, as we can't call f_op->mmap from an .mmap_prepare() hook. > > So we have to do it the other way round - invoke the .mmap_prepare() hook > from an .mmap() one. > > in order to do so, we need to convert VMA state into a struct vm_area_desc > descriptor, invoking the underlying file system's f_op->mmap_prepare() > callback passing a pointer to this, and then setting VMA state accordingly > and safely. > > This patch achieves this via the compat_vma_mmap_prepare() function, which > we invoke from call_mmap() if f_op->mmap_prepare() is specified in the > passed in file pointer. > > We place the fundamental logic into mm/vma.c where VMA manipulation > belongs. We also update the VMA userland tests to accommodate the changes. > > The compat_vma_mmap_prepare() function and its associated machinery is > temporary, and will be removed once the conversion of file systems is > complete. > > Signed-off-by: Lorenzo Stoakes > Reported-by: Jann Horn > Closes: https://lore.kernel.org/linux-mm/CAG48ez04yOEVx1ekzOChARDDBZzAKwet8PEoPM4Ln3_rk91AzQ@mail.gmail.com/ > Fixes: c84bf6dd2b83 ("mm: introduce new .mmap_prepare() file callback"). So this is a hotfix for 6.16-rc1 but doesn't need cc: stable. Also probably nothing wraps yet the filesystems with .mmap_prepare? But good to have this handled within 6.16. Reviewed-by: Vlastimil Babka