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 CFF0DC433F5 for ; Thu, 13 Jan 2022 11:15:11 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1BB376B0080; Thu, 13 Jan 2022 06:15:11 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 16A236B0081; Thu, 13 Jan 2022 06:15:11 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 059A56B0082; Thu, 13 Jan 2022 06:15:11 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0040.hostedemail.com [216.40.44.40]) by kanga.kvack.org (Postfix) with ESMTP id EAE896B0080 for ; Thu, 13 Jan 2022 06:15:10 -0500 (EST) Received: from smtpin22.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id 95368181DA094 for ; Thu, 13 Jan 2022 11:15:10 +0000 (UTC) X-FDA: 79025007180.22.28CB061 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by imf12.hostedemail.com (Postfix) with ESMTP id 3164E40002 for ; Thu, 13 Jan 2022 11:15:10 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 23C7960F5D for ; Thu, 13 Jan 2022 11:15:09 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8B118C36AED for ; Thu, 13 Jan 2022 11:15:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1642072508; bh=tmokVRuMXpkRXv8oyzytWI3owOE0aSeiLqaiU0qB/+Q=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=F/jx0aBe8ep2hAZigf+cBZzT5PCjEoM6TUCokq1sCt6wGpHi8Au3IqVQrAmWU0IzB 7/nQh7AA/oTI3LZIWixmZbLTfKU6QgoMURzFf+10m9VhA7c7bEFErwuYBmu7SjmdMx LmxgkVX8OCtZkDdEuNRQMjcsEbeGsJQl3lL8W0g4tfDTwiKf+jzPBj8Y6cyLH9Cwkq 2WiPrUlDRfuOwe/noRrmCVAIXrDSue6P+PyOtIB1yU936ZcwGoslCx1DLXMYLG0MQY 9bGyqoXCC0E/2dmEUGkpqH7M/A7tq4wSX4hL1nFB3UxK1QcsQkqC/aRQ5hv1bu0kge iY6bBlzU20uSQ== Received: by mail-wm1-f41.google.com with SMTP id o7-20020a05600c510700b00347e10f66d1so2448262wms.0 for ; Thu, 13 Jan 2022 03:15:08 -0800 (PST) X-Gm-Message-State: AOAM5315S4vOU96dPz+bQ+w4A4wREULOUUa3UYutdOVFy252HbX+SJPe 7bD4OjJXnBhIf39FzH3YIJyQlu0sjrtMRfhow/w= X-Google-Smtp-Source: ABdhPJwst+Tin12ujQYauaQcgLDiP82T5o8Qz/3cNaqDiW6X+iWOz0mouWb+fJ3aWoJYBb323ZOOm+CRoGY0Ep7lBUY= X-Received: by 2002:a1c:4c19:: with SMTP id z25mr10512756wmf.173.1642072506896; Thu, 13 Jan 2022 03:15:06 -0800 (PST) MIME-Version: 1.0 References: <20210726141141.2839385-1-arnd@kernel.org> <20210726141141.2839385-9-arnd@kernel.org> <20220113094754.6ei6ssiqbuw7tfj7@maple.lan> In-Reply-To: <20220113094754.6ei6ssiqbuw7tfj7@maple.lan> From: Arnd Bergmann Date: Thu, 13 Jan 2022 12:14:50 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v5 08/10] ARM: uaccess: add __{get,put}_kernel_nofault To: Daniel Thompson Cc: "Russell King (Oracle)" , Arnd Bergmann , Linux Kernel Mailing List , Linux ARM , linux-arch , Linux-MM , Alexander Viro , Linus Walleij Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 3164E40002 X-Stat-Signature: jqs73bdcyu1ff5iojrf8p9r617waih4c Authentication-Results: imf12.hostedemail.com; dkim=pass header.d=kernel.org header.s=k20201202 header.b="F/jx0aBe"; spf=pass (imf12.hostedemail.com: domain of arnd@kernel.org designates 139.178.84.217 as permitted sender) smtp.mailfrom=arnd@kernel.org; dmarc=pass (policy=none) header.from=kernel.org X-Rspamd-Server: rspam07 X-HE-Tag: 1642072510-900418 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: On Thu, Jan 13, 2022 at 10:47 AM Daniel Thompson wrote: > On Wed, Jan 12, 2022 at 06:08:17PM +0000, Russell King (Oracle) wrote: > > > The kernel attempted to access an address that is in the userspace > > domain (NULL pointer) and took an exception. > > > > I suppose we should handle a domain fault more gracefully - what are > > the required semantics if the kernel attempts a userspace access > > using one of the _nofault() accessors? > > I think the best answer might well be that, if the arch provides > implementations of hooks such as copy_from_kernel_nofault_allowed() > then the kernel should never attempt a userspace access using the > _nofault() accessors. That means they can do whatever they like! > > In other words something like the patch below looks like a promising > approach. Right, it seems this is the same as on x86. > From f66a63b504ff582f261a506c54ceab8c0e77a98c Mon Sep 17 00:00:00 2001 > From: Daniel Thompson > Date: Thu, 13 Jan 2022 09:34:45 +0000 > Subject: [PATCH] arm: mm: Implement copy_from_kernel_nofault_allowed() > > Currently copy_from_kernel_nofault() can actually fault (due to software > PAN) if we attempt userspace access. In any case, the documented > behaviour for this function is to return -ERANGE if we attempt an access > outside of kernel space. > > Implementing copy_from_kernel_nofault_allowed() solves both these > problems. > > Signed-off-by: Daniel Thompson Reviewed-by: Arnd Bergmann