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 X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1CD5DC433DF for ; Fri, 29 May 2020 04:30:39 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C3D262074D for ; Fri, 29 May 2020 04:30:38 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C3D262074D Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 49YBSr5VGGzDqVs for ; Fri, 29 May 2020 14:30:36 +1000 (AEST) Received: from ozlabs.org (bilbo.ozlabs.org [IPv6:2401:3900:2:1::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 49YBKY2XMszDqcW for ; Fri, 29 May 2020 14:24:17 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=ellerman.id.au Received: by ozlabs.org (Postfix, from userid 1034) id 49YBKX1lDgz9sT2; Fri, 29 May 2020 14:24:15 +1000 (AEST) X-powerpc-patch-notification: thanks X-powerpc-patch-commit: d02f6b7dab8228487268298ea1f21081c0b4b3eb In-Reply-To: <20200407041245.600651-1-npiggin@gmail.com> To: Nicholas Piggin , linuxppc-dev@lists.ozlabs.org From: Michael Ellerman Subject: Re: [PATCH v3] powerpc/uaccess: evaluate macro arguments once, before user access is allowed Message-Id: <49YBKX1lDgz9sT2@ozlabs.org> Date: Fri, 29 May 2020 14:24:15 +1000 (AEST) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Nicholas Piggin Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, 2020-04-07 at 04:12:45 UTC, Nicholas Piggin wrote: > get/put_user can be called with nontrivial arguments. fs/proc/page.c > has a good example: > > if (put_user(stable_page_flags(ppage), out)) { > > stable_page_flags is quite a lot of code, including spin locks in the > page allocator. > > Ensure these arguments are evaluated before user access is allowed. > This improves security by reducing code with access to userspace, but > it also fixes a PREEMPT bug with KUAP on powerpc/64s: > stable_page_flags is currently called with AMR set to allow writes, > it ends up calling spin_unlock(), which can call preempt_schedule. But > the task switch code can not be called with AMR set (it relies on > interrupts saving the register), so this blows up. > > It's fine if the code inside allow_user_access is preemptible, because > a timer or IPI will save the AMR, but it's not okay to explicitly > cause a reschedule. > > Signed-off-by: Nicholas Piggin Applied to powerpc topic/uaccess-ppc, thanks. https://git.kernel.org/powerpc/c/d02f6b7dab8228487268298ea1f21081c0b4b3eb cheers