Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1888329ybb; Fri, 29 Mar 2019 13:28:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqy2N7kUI0kwRBhHZH1sHIwiaOsjZNUTWJIwrzkpk42ty4HEbUYYKDp8Tdwx0EQ3GIWaektR X-Received: by 2002:a63:c00c:: with SMTP id h12mr48084845pgg.423.1553891303622; Fri, 29 Mar 2019 13:28:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553891303; cv=none; d=google.com; s=arc-20160816; b=U+082zpWkqzWHM8EdUZx7pbQGyV2ASwdUCfBSpM2MZpkwbV637SjlxDjzfrhu9OeWl kRkmqLr6k5WPyZAN9/y2HQM59NkQwux3qz+jj+JQj+XaiIDp0YRRWukdLJpZ4Icii/Bf hrsNZaT09T17reKMUHZ76f/rFV1RkMXIICKtPb30Plxs+V7E4ZkXj3tIZTNTrkEPTRZ5 KdphY275G8paJy6diYP+z3q62WXb0C956+PRRV9mdV6B5m1CyhLTEz+S2jVS+TG77oRa 4ctVQKCN0+c4oMC+Em0rPQQW/gJuwWh3GJKkPctj3OJNAiKqm/hCAwzzcrQqXIYmf8pF Mb0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dmarc-filter :dkim-signature:dkim-signature; bh=9YWZvtiVQ8TFY5CT7zY307bR5/dqaQh0kR13nqBi2I8=; b=GMsbls/PedieFhgdd+OwR3QVnUOFyv0j5ETtohqCO6A/OPZD2S/9i0hmj1NczEBonv n7dVDfswYY7bfs2qRQFwyWF+WR8o1At0VxcCvn8ZkKdOR2yFBH3apBIk8+4dQrnnQSFV iJu95qxsm7AR32EhIE6LDqTKg0sTWfs/eDGcc5j1xbmr/U1sk44aCobMyL6iiyCZoVvI dxV4MfWk56kyCT3+U1FR+HP+EkHqycemd8AlzLNYAcAUqG8gPydPLDOao7iUGlBpSHva aPiD0P+PCsE10DR7qPyASjh+gWNPdDtT6v5DHv3+GvlxZDHUeIKv3FFwLqnSsrfnRqJY I9RA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KkTtldlW; dkim=pass header.i=@codeaurora.org header.s=default header.b=jErErcb3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h185si2551932pge.84.2019.03.29.13.28.07; Fri, 29 Mar 2019 13:28:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@codeaurora.org header.s=default header.b=KkTtldlW; dkim=pass header.i=@codeaurora.org header.s=default header.b=jErErcb3; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730123AbfC2U1X (ORCPT + 99 others); Fri, 29 Mar 2019 16:27:23 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:54580 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729906AbfC2U1X (ORCPT ); Fri, 29 Mar 2019 16:27:23 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 6F2376087F; Fri, 29 Mar 2019 20:27:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553891242; bh=H+AqADjiFgVNVwUfC56fZtiDkhNO3BWn2kahfXt+VJo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=KkTtldlWnuUxl7e2ndqqyNVZL5q1/1oX9cT7KcXRdOemO3+YICdviQJ/YpiqJ4oo0 x1VWqHWhWPrGM/Y29r8m8lZzVqU83VHwM7y0BS/+V8+lVDUADevoVgiUcJUjHlUawi OFZN0rOLVS/m9lC9iN8whlRv5B/M53nV4tU3tbaQ= X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on pdx-caf-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.7 required=2.0 tests=ALL_TRUSTED,BAYES_00, DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.0 Received: from [10.79.168.116] (blr-bdr-fw-01_globalnat_allzones-outside.qualcomm.com [103.229.18.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: mojha@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2396A60735; Fri, 29 Mar 2019 20:27:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1553891241; bh=H+AqADjiFgVNVwUfC56fZtiDkhNO3BWn2kahfXt+VJo=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=jErErcb3zyLQpQ0gSv4Wqa/yAy2Nx4ILsCORlv/LpqPOPnONt2zPobwgxzPtZ4dlI nNqlkZVAsur84AIskwScDyfOTidCbiF2AmYdjTGDBV1KjSy7FqcBVAWYoYRuwRKdPC olCccnbIww+68A+69mH66gw1IdN7aJHqIeflUsCE= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2396A60735 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=mojha@codeaurora.org Subject: Re: [PATCH v2 4/4] x86/uaccess: Fix implicit cast of __user pointer To: Jann Horn , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Qiaowei Ren References: <20190329163047.223508-1-jannh@google.com> <20190329163047.223508-4-jannh@google.com> From: Mukesh Ojha Message-ID: Date: Sat, 30 Mar 2019 01:57:12 +0530 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <20190329163047.223508-4-jannh@google.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/29/2019 10:00 PM, Jann Horn wrote: > The first two arguments of __user_atomic_cmpxchg_inatomic() are: > > - `uval` is a kernel pointer into which the old value should be stored > - `ptr` is the user pointer on which the cmpxchg should operate > > This means that casting `uval` to `__typeof__(ptr)` is wrong. Since `uval` > is only used once inside the macro, just get rid of __uval and use `(uval)` > directly. > > Signed-off-by: Jann Horn Looks good to me. Reviewed-by: Mukesh Ojha Cheers, -Mukesh > --- > arch/x86/include/asm/uaccess.h | 3 +-- > 1 file changed, 1 insertion(+), 2 deletions(-) > > diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h > index 1954dd5552a2..a21f2a2f17bf 100644 > --- a/arch/x86/include/asm/uaccess.h > +++ b/arch/x86/include/asm/uaccess.h > @@ -585,7 +585,6 @@ extern void __cmpxchg_wrong_size(void) > #define __user_atomic_cmpxchg_inatomic(uval, ptr, old, new, size) \ > ({ \ > int __ret = 0; \ > - __typeof__(ptr) __uval = (uval); \ > __typeof__(*(ptr)) __old = (old); \ > __typeof__(*(ptr)) __new = (new); \ > __uaccess_begin_nospec(); \ > @@ -661,7 +660,7 @@ extern void __cmpxchg_wrong_size(void) > __cmpxchg_wrong_size(); \ > } \ > __uaccess_end(); \ > - *__uval = __old; \ > + *(uval) = __old; \ > __ret; \ > }) >