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.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,T_DKIMWL_WL_HIGH,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable 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 C45B7C04AB3 for ; Thu, 9 May 2019 18:58:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 54AE220656 for ; Thu, 9 May 2019 18:58:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557428334; bh=0VqV0jJX90eYH8l9rKoIsmKTEX47Oti3YPtNJj6Ig/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=NydX3DtInGdyraCYw9TeZfnv/whVzVPWLgnDdvR+wJp497aD9xPfoQrjTLXyGIm1t NpVvTUyCMrvF783NYxQ08F7+WxjTJGllPtXqYUnkzDyKq4crzX5OSE7dwE+b/U1J8l CEerGQqaNVBECYOl7OPOw4Yhw4V5oQpdYuA/U5sw= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728786AbfEIS6x (ORCPT ); Thu, 9 May 2019 14:58:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:47184 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728026AbfEISwy (ORCPT ); Thu, 9 May 2019 14:52:54 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 44C95217D7; Thu, 9 May 2019 18:52:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557427973; bh=0VqV0jJX90eYH8l9rKoIsmKTEX47Oti3YPtNJj6Ig/s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jPO1gznbFLZg9dNkyFJokq7xinXr5cdFzXX9P+EJ7xnmKdvNt2GKK0PkyEG4PfV1U JcjwLbxXrWkMkrEb6Hv+HdDeO9Az3BfkkUFn4DwxNeKKDmxas86cQHQS8CusFeeTtm u05a8v0mUkc2Y47430p46U4khQ5zzSEaY7BAzs5s= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jann Horn , Borislav Petkov , Mukesh Ojha , Andrei Vagin , Andrew Morton , Dan Carpenter , "H. Peter Anvin" , Ingo Molnar , Jani Nikula , Kees Cook , Masahiro Yamada , NeilBrown , Peter Zijlstra , Qiaowei Ren , Thomas Gleixner , x86-ml , Sasha Levin Subject: [PATCH 5.0 38/95] linux/kernel.h: Use parentheses around argument in u64_to_user_ptr() Date: Thu, 9 May 2019 20:41:55 +0200 Message-Id: <20190509181311.994204612@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190509181309.180685671@linuxfoundation.org> References: <20190509181309.180685671@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [ Upstream commit a0fe2c6479aab5723239b315ef1b552673f434a3 ] Use parentheses around uses of the argument in u64_to_user_ptr() to ensure that the cast doesn't apply to part of the argument. There are existing uses of the macro of the form u64_to_user_ptr(A + B) which expands to (void __user *)(uintptr_t)A + B (the cast applies to the first operand of the addition, the addition is a pointer addition). This happens to still work as intended, the semantic difference doesn't cause a difference in behavior. But I want to use u64_to_user_ptr() with a ternary operator in the argument, like so: u64_to_user_ptr(A ? B : C) This currently doesn't work as intended. Signed-off-by: Jann Horn Signed-off-by: Borislav Petkov Reviewed-by: Mukesh Ojha Cc: Andrei Vagin Cc: Andrew Morton Cc: Dan Carpenter Cc: Greg Kroah-Hartman Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jani Nikula Cc: Kees Cook Cc: Masahiro Yamada Cc: NeilBrown Cc: Peter Zijlstra Cc: Qiaowei Ren Cc: Thomas Gleixner Cc: x86-ml Link: https://lkml.kernel.org/r/20190329214652.258477-1-jannh@google.com Signed-off-by: Sasha Levin --- include/linux/kernel.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 8f0e68e250a76..fd827b2400596 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -73,8 +73,8 @@ #define u64_to_user_ptr(x) ( \ { \ - typecheck(u64, x); \ - (void __user *)(uintptr_t)x; \ + typecheck(u64, (x)); \ + (void __user *)(uintptr_t)(x); \ } \ ) -- 2.20.1