Received: by 2002:a25:5b86:0:0:0:0:0 with SMTP id p128csp1700953ybb; Fri, 29 Mar 2019 09:32:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqwwbI7ZInuSxOmII1Q270bJPFwIY4xuK71x7l5+mn5sS12iZBHAcaDnEVOhhsmZfddhM7aH X-Received: by 2002:a17:902:820c:: with SMTP id x12mr37560403pln.199.1553877136256; Fri, 29 Mar 2019 09:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553877136; cv=none; d=google.com; s=arc-20160816; b=JRaMic7eIhY0VuwebjEF1IKw0/5jW2YzH56jHK1Xqzv6SW9XyS1S5kpKG2hskkexGi R2RqRMmk1GPvI5GMK22baOUXCxaSY8dnaaR4KLJ8A83H+xm/wk/aBa2h14J99k9Oi2AA yfPTzFC6dgaEBzcSfnkvgJvwOWrWO1iiHWZdOjxAIQO7gcXN51jrwfIJCRba16l5OZ35 877LhxVkFH9E3sFuIyI29NYIgKr1LaiGGy1zmnbfTKlL3+RIukulyMvwCCLRH8cyXnys FYaGwvoSN3aWID4MEADdhvRVxq/P4F60Bl/CAji6TD3JeQkHjjMrkdmCP029r5CZG3us Rnfg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=VDhFgWJ/56vXJisR9dcHKiBzroB9HEmnMiZSpGUlpdE=; b=006J0wAfLKXax0SExRrABS90Nem51ue02HceAAsfzGdY4EAUg+jFJIB4ZySOWZ4195 8+pzSdoTMbmN2S0Rc5CLqTC40H8e36GlO+o+BrMkK+7fUB7jtII2dFVIIaPgsauyDY6m eQYx2sWrjw6I0RpHYsKY9gab3QPxnyDVVN/eLq3peEg2piqXoZ3kFHnFlHzDtgdu3Ct7 ajs2QTx/9Vp+UmdhztimYy99L5/FAR0MEEK0ShoEs7ZGdXVQ/Sgf5V5QH3RLuQ/msCXl 22aZdkOSl5dWsW/xg9Ld2qbcXrZXT1v1WJpUpqWhA2X0OW6wVDa1+4PywZ9QJoVpQtwq iE+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=KZdqR4+T; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m7si2275014pfb.272.2019.03.29.09.32.00; Fri, 29 Mar 2019 09:32:16 -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=@google.com header.s=20161025 header.b=KZdqR4+T; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729833AbfC2QbG (ORCPT + 99 others); Fri, 29 Mar 2019 12:31:06 -0400 Received: from mail-qk1-f202.google.com ([209.85.222.202]:48824 "EHLO mail-qk1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728839AbfC2QbE (ORCPT ); Fri, 29 Mar 2019 12:31:04 -0400 Received: by mail-qk1-f202.google.com with SMTP id b188so2243887qkg.15 for ; Fri, 29 Mar 2019 09:31:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=VDhFgWJ/56vXJisR9dcHKiBzroB9HEmnMiZSpGUlpdE=; b=KZdqR4+TFEn7QsE/4nZtLwoH2wc4UDFBAuDcjfLltrQEOnnf2CFcXNN44qcY3xlbAP 0zQnZw9mfSXOEqRDL0PddyXoqlnuQu2frreQ7dQVwFBLe4+pEV0cismBmNqxYnH/GC1S EohjyqrxdXdUVrlYl8ihoiOnVsx7QU0WhDX200wzukYX4PlQFtXeAVtrPmZ0G6tezjxf rvM47Ra5SER77P0bHWeR+1u/LkGFCPv8UWZPbCBocfzKiQSQqMSXAguQHZ4iudvXk2fR rbrD6+uV+WY63NyWAVNRPnZ8MwTHYfUofY5VhYJrNOescEzqCU+NdOBppolbutKlsk5+ +8Hg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=VDhFgWJ/56vXJisR9dcHKiBzroB9HEmnMiZSpGUlpdE=; b=ifBN/3Co8lXH5qDYrZETGxA8kbqK7kUWf7pfvtr3aole8p1FF5HbEtRox5NyzcUhFX OxXb1816Lagoy65KZjwaGBjn6kxIguSMLCph9PlCutIvaSBJIpqED1ZgxqXs2JRneCa7 WraupRiwMYuGH+1X7mFjPBobJ2IPVOAtvzC5XZ4lGX7CgI2+0BLWn9jWy1bCyUtAeK3X YOGT23C3SwZbJZjwBZ0uL+Ferok4BbfxY/aSjfjS/GsYLjrF0qE6xdCP+SPAsMndeBAz 1oIkLD1ZX96R8DCDJhXgMaNevET3dgrsMGa8ho/KFThMrbvr83iSpPFnBewtDPcruzNz L1mw== X-Gm-Message-State: APjAAAXsm0lMHTF9Z140+1MU18bvuPGUEzkgESHJ8ElDbFR6WTt49iiM cubxlSJPrGm6z1XQ5DSr0F04M/dhfw== X-Received: by 2002:a0c:94b9:: with SMTP id j54mr3790002qvj.44.1553877063522; Fri, 29 Mar 2019 09:31:03 -0700 (PDT) Date: Fri, 29 Mar 2019 17:30:47 +0100 In-Reply-To: <20190329163047.223508-1-jannh@google.com> Message-Id: <20190329163047.223508-4-jannh@google.com> Mime-Version: 1.0 References: <20190329163047.223508-1-jannh@google.com> X-Mailer: git-send-email 2.21.0.392.gf8f6787159e-goog Subject: [PATCH v2 4/4] x86/uaccess: Fix implicit cast of __user pointer From: Jann Horn To: Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H. Peter Anvin" , jannh@google.com Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Qiaowei Ren Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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; \ }) -- 2.21.0.392.gf8f6787159e-goog