Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp248768pxb; Wed, 15 Sep 2021 00:48:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhRZE72fI1U+y+xlbT+0csuEVnsAk/njw1jy7il2V05nuAYsN4DtKtTXseMnKC3uGhd7SR X-Received: by 2002:a19:6a15:: with SMTP id u21mr13622981lfu.11.1631692081362; Wed, 15 Sep 2021 00:48:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631692081; cv=none; d=google.com; s=arc-20160816; b=gPMJ7KMOA2s4RPGeKFWNv4xufMwDwW2tZ6nqvVtF9vUTZHPBwuN3lY+xtGFP2vE/3T qFjfpxjzrt2wY0V0kYFgEkHwciQhNYZZ1gJr0WPN4T2zF4B03edRSCIEt7PTogfRJshT z/gLADaSvpqSK4l2kvRggl/XUCeT391T9aIfWj9IL2pDPuI3OINcdiMtvLV3eueA48U+ 8xbpcUNZIAytk+KthO6mskydLp9OlN60EGcInlAysz5une3ZZJrm5E1p9ExqMmBJHyNT c+VwKFqeEAUYa8nu+S4r00+IEDTqVkaHNwrslunKZXSwLZmyaavuKC7LG3ELKPXlU1Jy jHwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=HxQjhQXN3bRnhRUJpqv4hHysfQ80FIOsFoJ2cZMAAUM=; b=GURdHoYivcYOthqb8vaEGebf/mNZ2r3uET8bgogtfxPOG09mJZ+7+FgTymEG3bMHHm uZCsXALgrjY6jukY2gSDRZVaV/DAWtTgXbKq9sHLI90R0jRCFB69KXdEWtKsUpVj9nLV 2u6MmpOQillVBOOj9wyzj2E9YjufV6z+94lyvouqzEe4w7H2IIpFMiZYUUmrp40RAnCY ucfuc/Ml2vAgztyB1w3iqAHz3eITAqU0en7EobYEq366RRskouhrtGUZ4g5KSoF1QCpf rQi2CeK4w+ctART34SLpA7ikfIl9BysttyWid26ApczRXJLYyN/T14z5MDJhzfe9fxDa 3Ejg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKUx5Cxp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si15545698lfg.497.2021.09.15.00.47.29; Wed, 15 Sep 2021 00:48:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=cKUx5Cxp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236687AbhIOHqq (ORCPT + 99 others); Wed, 15 Sep 2021 03:46:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231364AbhIOHqf (ORCPT ); Wed, 15 Sep 2021 03:46:35 -0400 Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DDBC5C061574 for ; Wed, 15 Sep 2021 00:45:16 -0700 (PDT) Received: by mail-ed1-x532.google.com with SMTP id c21so3022558edj.0 for ; Wed, 15 Sep 2021 00:45:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=HxQjhQXN3bRnhRUJpqv4hHysfQ80FIOsFoJ2cZMAAUM=; b=cKUx5CxpCpbAAq2qCxIMvKNBhIz0fx5suWBiceWCMArEhS2ray50WNIn86PB3s2gwF g3llTqFtrqh4uhD8cyU6G07ebbdkkRrs6hJ5b1vCVC7jHW8xl6vm+KyvH7iPbvQej8XL DEbEG39H8zUZAwIrvMgU20zMi1WAll0xX8E+MY5Cjr44MK5jAL8qieKpEDVSSs2GiVNx GkP7uIL82ZWMoclgFUixzYZCH9uuCQoHvcxLmAK2WKrAQ6GZKQUAo/25GDTJwkkHy+th n0Zys+DP4glpLPMpAJDO0cUF24R6zBbi2Y6QZalxpbnAqu7XCHY6JHQbJvYkK5utgM5P Tdjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=HxQjhQXN3bRnhRUJpqv4hHysfQ80FIOsFoJ2cZMAAUM=; b=AdXLB/lQkozHsmcCJDvdZKOr7X1mT7lvml2yri2tQsdkd3SPUCvWafR1xH/xQRzi+a zg2e5lQ9jKsUOOJtKVwJqJSl9tUs/ZMY0yW7TxjTyjxUsAELO6jSoeyAYUqmJBVqWpP3 de7kqJH4VETS7WmLaWr7gpWfKrl2r5lEz+HurOrPzoMYFt7XuO+F4+vqax1FrfPIFxLM xVZQ1NSp/1fo5ZCHTyd9JEqwAMhsYaGJBQcR6r7HFg/CcHVPkYmvYLJp4ELW/EhqLU8y 4TLDTHjOwBngi7J0+jqTU6qtJf2JK4OaEdwOF9CEy/Tjw76XFVKqINpNugfUscgEE+2d uFtg== X-Gm-Message-State: AOAM533Txr0NFTI+gz73Ke+7bKKLo7yULVl5YivUakcdWPZxessIFHii 4L4OK/VYI9UiqegjgFMiVpgfqrb6ArkcxmXPCG4+VMSPeG8geA== X-Received: by 2002:aa7:dcd0:: with SMTP id w16mr24185019edu.288.1631691915298; Wed, 15 Sep 2021 00:45:15 -0700 (PDT) MIME-Version: 1.0 References: <20210913163547.5156-1-will@kernel.org> In-Reply-To: <20210913163547.5156-1-will@kernel.org> From: Naresh Kamboju Date: Wed, 15 Sep 2021 13:15:03 +0530 Message-ID: Subject: Re: [PATCH] x86/uaccess: Fix 32-bit __get_user_asm_u64() when CC_HAS_ASM_GOTO_OUTPUT=y To: Will Deacon Cc: open list , X86 ML , Nick Desaulniers , Bill Wendling , Linus Torvalds , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Peter Zijlstra , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 13 Sept 2021 at 22:06, Will Deacon wrote: > > Commit 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT") > added an optimised version of __get_user_asm() for x86 using 'asm goto'. > > Like the non-optimised code, the 32-bit implementation of 64-bit get_user() > expands to a pair of 32-bit accesses. Unlike the non-optimised code, the > _original_ pointer is incremented to copy the high word instead of loading > through a new pointer explicitly constructed to point at a 32-bit type. > Consequently, if the pointer points at a 64-bit type then we end up > loading the wrong data for the upper 32-bits. > > This was observed as a mount() failure in Android targetting i686 after > b0cfcdd9b967 ("d_path: make 'prepend()' fill up the buffer exactly on > overflow") because the call to copy_from_kernel_nofault() from > prepend_copy() ends up in __get_kernel_nofault() and casts the source > pointer to a 'u64 __user *'. An attempt to mount at "/debug_ramdisk" > therefore ends up failing trying to mount "/debumdismdisk". > > Use the existing '__gu_ptr' source pointer to unsigned int for 32-bit > __get_user_asm_u64() instead of the original pointer. > > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Linus Torvalds > Cc: Thomas Gleixner > Cc: Ingo Molnar > Cc: Borislav Petkov > Cc: Peter Zijlstra > Reported-by: Greg Kroah-Hartman > Fixes: 865c50e1d279 ("x86/uaccess: utilize CONFIG_CC_HAS_ASM_GOTO_OUTPUT") > Signed-off-by: Will Deacon This patch merged into Linux next (next-20210914) and the reported problem has been fixed. Tested-by: Linux Kernel Functional Testing -- Linaro LKFT https://lkft.linaro.org