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 AFB81C54798 for ; Tue, 5 Mar 2024 20:09:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E8DDA6B0074; Tue, 5 Mar 2024 15:09:10 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E3C966B0075; Tue, 5 Mar 2024 15:09:10 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D2BDD6B007B; Tue, 5 Mar 2024 15:09:10 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id C0F6F6B0074 for ; Tue, 5 Mar 2024 15:09:10 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 8E8211A03FC for ; Tue, 5 Mar 2024 20:09:10 +0000 (UTC) X-FDA: 81864074460.06.0735842 Received: from casper.infradead.org (casper.infradead.org [90.155.50.34]) by imf01.hostedemail.com (Postfix) with ESMTP id 6757540013 for ; Tue, 5 Mar 2024 20:09:07 +0000 (UTC) Authentication-Results: imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bAm7pxGO; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1709669349; 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: in-reply-to:in-reply-to:references:references:dkim-signature; bh=vjXgqWOC4/Lhe5Ap8xLALor9sJ4GjkzXx0nM/FOgmFw=; b=AHQHsFBbA8JTAtar2ZNU2p0QnXyjLaRsh/ID8SVlp4HubqomOzHU3H33vOIOHEwuB/ygOG uNBbXtVHXhjXOWYRKbqNK2i8qs8vnz06lbLNmYfRulVapG94VPj8Ys5flh6GT0qGXB2aOn 6GVe0aQEYOgilhXFGbS96wvr9MkqrBU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1709669349; a=rsa-sha256; cv=none; b=3zQUV9IOg8l5/hKabRZcClHbxHOq3fr9u56iqEJARHmnij+cL8ekjUUUoaBPA5Gs2h7vv0 6SvuFH/2jWZ30mOHMn4FYyYl1ib+anXxj+zE35Z9lhiMj/kFAEfgsRXFa7Ko+lIvNOKabi g3bA7y4VgSlBNqN3AM09QT9gT2V/1Wc= ARC-Authentication-Results: i=1; imf01.hostedemail.com; dkim=pass header.d=infradead.org header.s=casper.20170209 header.b=bAm7pxGO; spf=none (imf01.hostedemail.com: domain of willy@infradead.org has no SPF policy when checking 90.155.50.34) smtp.mailfrom=willy@infradead.org; dmarc=none DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=vjXgqWOC4/Lhe5Ap8xLALor9sJ4GjkzXx0nM/FOgmFw=; b=bAm7pxGOqdGs9osJxaYQ656yx9 BYBgvcJafaU3bxbgUOtPx22Mgj84rtZ/5LvnrophfuirRvgNQZZjXq9xwlH1QIHAHZ/RFa9AE+Sc/ PeDW4lOInG7M7YRFAzpLJyaLte+o563jye1bdAuLTNpvIrPPv8rHaukeGz0/0oxErgZwC4W2GMajX IF+RN9AEphesEKviRgPtl6Hn9OzbvbB5ZfpM1CuKRl23RB8QFVVwvqb2Airwrf2UNzgtA6XadGcRY zhs7wNml+0VsOz3a0j7vs8Hh39lGbcNnD3xQl4vMOUfEOF4U/ngu90Be4svjQKBPeYP6etsQK2vHV qSo/WmMw==; Received: from willy by casper.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rhb5x-00000005A7K-09Pg; Tue, 05 Mar 2024 20:09:01 +0000 Date: Tue, 5 Mar 2024 20:09:00 +0000 From: Matthew Wilcox To: Miaohe Lin Cc: linux-mm@kvack.org, Naoya Horiguchi , Andrew Morton Subject: Re: [PATCH 3/8] mm: Return the address from page_mapped_in_vma() Message-ID: References: <20240229212036.2160900-1-willy@infradead.org> <20240229212036.2160900-4-willy@infradead.org> <6a173610-9805-650b-60e7-b2a2aa504178@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <6a173610-9805-650b-60e7-b2a2aa504178@huawei.com> X-Rspamd-Queue-Id: 6757540013 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: ocbrty9bxgx84nmdfwantfhyz46qjt74 X-HE-Tag: 1709669347-615417 X-HE-Meta: U2FsdGVkX1+jEDP+yiYtUfyPSXAMVs+vCRMUwYnagHDlUOtuC2OWdN2ixujmYveCVJmGc36OzxLQk/lmmgKGoUWQTKtVrVcRFy4h0p18264fUDhx/YUoQyqeebTiiOashUElzDV6reXX+enMfJotkebsVP+T/voj+ax+pyrcJl8Cd4hYl+KGY8SoPIKzFelt68hGcal+TObUdPUXo46wbzzQA3XWBA/3F5cSwZf3lYFJ+jttsC6Vvs/1aoB0JYJIOJ690oUicnn5sbDLgaOhhgoovIp+oSI+qcBX9fBN5YwK91Ru5X2fYYGEyWLrP9KeU+jEHEFLpbWMbUFnxIIRgItKlwq7M/kn3iBmy3QZ5T+fHXaCbHOxZ0HSsGYUZi3Q5Fx4x2g2NY+DQv2cY1gJWOJLXgImUxan9M72JGEP0iytetyhPfleX9OdhtUw98BAZIyVoYRA/sUcNOHOsmNVww4Okokf+DbGckm7Ae2+N6GAJGUPxYVk7SAcZ5p9A1S1Y9ACNeCc3uoj6VGkwEZyq3a6w8BUrezRRFGO3S3TGOPaoPLB5Z2KICk7r2YPE8gt6U+k+FeYD3Qq9Lnw6XSQW5gfvc5PEw5/vd1xL0e2z/3fpDvdtq8B/94nAPT2Lx4QQ7glGhiQdyGlFdTPlCLnoJzA8BQIGCyS8OkHiZbqw58WgaG/qH5EziU5PMg4Zx+AOO8El5cpgcRheCu1PzOASSfys5CMzP2t9iJ87YKzWvIn4QV9pM3N3t4AMBw+HQff0Q6Ep9OHVLNMHsH0cz0dBY5cay1P/UZZfbXLdcev4GT4msEIEja9GtCIfBilcxfDZoIdP0U7sSMj1KfwoPSGlJ1nyjfpyBbaqATJaJGNUwBa7BuiUk8aDvqy+UKBzGmRIHX6Rnd3R8zQlJBRNwb0hD3yUQSH8nPQ6FoiltlIGV+O6yxhbLVJwm4Bcn5d4IF3W7Lr2fT5rNDc0aTDmI0 SjLwqMBS YWuey0Y4UtZ9CLv9xBVpkBON2+CZvcqpDbqwdB9LTnHhfQwe+DHWVcD4THKNqLB0Cbwrs1kUxI1zOtYwZLwM/YMz5xtqKCy41gU/tIYDjgJcSuOIkEdWSTysDA5hG4Pbnpc8b0VoVZbJWzhHkcdFoWrGOWlmhReVGInj5s3pTZi/qbxVamUNmx07Mog== 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 Mon, Mar 04, 2024 at 08:31:56PM +0800, Miaohe Lin wrote: > On 2024/3/1 5:20, Matthew Wilcox (Oracle) wrote: > > The only user of this function calls page_address_in_vma() immediately > > after page_mapped_in_vma() calculates it and uses it to return true/false. > > Return the address instead, allowing memory-failure to skip the call > > to page_address_in_vma(). > > IIUC, this patch will change the semantic slightly. There is one corner > case where page_mapped_in_vma() returns true but page_address_in_vma() > returns -EFAULT if mremap is done after the check. In that case, > SIGKILL will be sent to the user. But with this patch applied, SIGBUS > will be sent to the user with address before doing mremap. Or am I > miss something? Isn't that an example of a race that userspace can't possibly rely on? It can't observe where the kernel has got to in its processing of the fault, so it's OK if we behave if the mremap() has happened before, during or after the two calls.