Received: by 2002:ac0:a582:0:0:0:0:0 with SMTP id m2-v6csp3938803imm; Mon, 8 Oct 2018 12:01:08 -0700 (PDT) X-Google-Smtp-Source: ACcGV612wXe7VnChr2ouicX80agSCw/wTuCd4/kNAg17o28Qner6bHaOaHc4i6hMMpBhM1ojUvbz X-Received: by 2002:a62:2fc1:: with SMTP id v184-v6mr26560771pfv.115.1539025268032; Mon, 08 Oct 2018 12:01:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1539025268; cv=none; d=google.com; s=arc-20160816; b=hx4ja0fm40lobvurM9tYUjHW+l0vqKuz6M2Z3u9K1HHnmJqmMlrp5XhO63x+e0xp0P jLLzt5ysR7BVfzFJLWc0QcqLR2yClgSb1lyT9/y/qkzZsJaCkGqmoUWa4GmF1T1mclM+ wGYbez1Ukf6/dKm4vlirh4fx/EqPxHr0TlBlCWaiz7s4JseLaL9lLn98cjENwKXTu04T Yp3txxM8ByoMOkz6S3X6CJgLSmeCNOYN97tDAk2CKr97ELdiE7P+U9WJxWu3Lji0ewLW HoXo/vmslpPnFwNbGo5MUlteRC953ZnGuOBfNWU55Uy6wf6vqrcsCdcnqpsASyVQeRti G2Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AH3VGHaJaX+AKX9eMzNHzJpG7PkGLbyyhEBaZKYiZf4=; b=V5WILWNKWpDgl0lElx32++EmZ64QVREaSyXgBkDALfFM/E4j0FMKeUsjJS0W9oZpAn /C2g5BThZ2P+RiFvr8mwB3i1qTvHhs/eP4OdYnl5TS2wCB78mAqDVa0YZGTncGpBHemG tqwa6pLs8m/BRFxyz1Osf7mfkO05Cfs9e3kdLCFZu3bMRJratGTP+ZzAxAnRNkOaDYeo 9TN+N1GTep+lH8sjumpfjBc+bH/N+Et666noKA9MlREYbdO9S74ZrSAImNqSaJcEp3S4 dsZsTnJgHhMbQbP+EbrVh1RMaKInuil+1aF4AEETjUWYPiZebkE5aanFqSYOlztEpIe2 eNcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=m5SaWmQV; 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 cc10-v6si21861751plb.97.2018.10.08.12.00.52; Mon, 08 Oct 2018 12:01:08 -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=@kernel.org header.s=default header.b=m5SaWmQV; 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 S1731732AbeJICBx (ORCPT + 99 others); Mon, 8 Oct 2018 22:01:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:51020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726991AbeJICBw (ORCPT ); Mon, 8 Oct 2018 22:01:52 -0400 Received: from localhost (ip-213-127-77-176.ip.prioritytelecom.net [213.127.77.176]) (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 477C2204FD; Mon, 8 Oct 2018 18:48:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1539024524; bh=M/BlrZN7jZBMbRQPa4sEW7xwiFdSpS4tCj+aadDLulQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=m5SaWmQVD1wTuUazTD/sZcshiFswgaN1g+Y4+Je53WsdHujleHSa8E/s52zlkernw scH+uObMFXkHX/FvGOOKfKDcd+PrlR0clfyL0l0eBQlVmBecd3mhpDtdGOuLsBGiVO OlheXozJ8YU+wnnYjvtg3+p6hudjd18NKscwkqEY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Zong Li , Greentime Hu , Sasha Levin Subject: [PATCH 4.18 069/168] nds32: Fix get_user/put_user macro expand pointer problem Date: Mon, 8 Oct 2018 20:30:49 +0200 Message-Id: <20181008175622.686667495@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20181008175620.043587728@linuxfoundation.org> References: <20181008175620.043587728@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Zong Li [ Upstream commit 6cce95a6c7d288ac2126eee4b95df448b9015b84 ] The pointer argument of macro need to be taken out once first, and then use the new pointer in the macro body. In kernel/trace/trace.c, get_user(ch, ubuf++) causes the unexpected increment after expand the macro. Signed-off-by: Zong Li Acked-by: Greentime Hu Signed-off-by: Greentime Hu Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/nds32/include/asm/uaccess.h | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) --- a/arch/nds32/include/asm/uaccess.h +++ b/arch/nds32/include/asm/uaccess.h @@ -78,8 +78,9 @@ static inline void set_fs(mm_segment_t f #define get_user(x,p) \ ({ \ long __e = -EFAULT; \ - if(likely(access_ok(VERIFY_READ, p, sizeof(*p)))) { \ - __e = __get_user(x,p); \ + const __typeof__(*(p)) __user *__p = (p); \ + if(likely(access_ok(VERIFY_READ, __p, sizeof(*__p)))) { \ + __e = __get_user(x, __p); \ } else \ x = 0; \ __e; \ @@ -99,10 +100,10 @@ static inline void set_fs(mm_segment_t f #define __get_user_err(x,ptr,err) \ do { \ - unsigned long __gu_addr = (unsigned long)(ptr); \ + const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ unsigned long __gu_val; \ - __chk_user_ptr(ptr); \ - switch (sizeof(*(ptr))) { \ + __chk_user_ptr(__gu_addr); \ + switch (sizeof(*(__gu_addr))) { \ case 1: \ __get_user_asm("lbi",__gu_val,__gu_addr,err); \ break; \ @@ -119,7 +120,7 @@ do { \ BUILD_BUG(); \ break; \ } \ - (x) = (__typeof__(*(ptr)))__gu_val; \ + (x) = (__typeof__(*(__gu_addr)))__gu_val; \ } while (0) #define __get_user_asm(inst,x,addr,err) \ @@ -169,8 +170,9 @@ do { \ #define put_user(x,p) \ ({ \ long __e = -EFAULT; \ - if(likely(access_ok(VERIFY_WRITE, p, sizeof(*p)))) { \ - __e = __put_user(x,p); \ + __typeof__(*(p)) __user *__p = (p); \ + if(likely(access_ok(VERIFY_WRITE, __p, sizeof(*__p)))) { \ + __e = __put_user(x, __p); \ } \ __e; \ }) @@ -189,10 +191,10 @@ do { \ #define __put_user_err(x,ptr,err) \ do { \ - unsigned long __pu_addr = (unsigned long)(ptr); \ - __typeof__(*(ptr)) __pu_val = (x); \ - __chk_user_ptr(ptr); \ - switch (sizeof(*(ptr))) { \ + __typeof__(*(ptr)) __user *__pu_addr = (ptr); \ + __typeof__(*(__pu_addr)) __pu_val = (x); \ + __chk_user_ptr(__pu_addr); \ + switch (sizeof(*(__pu_addr))) { \ case 1: \ __put_user_asm("sbi",__pu_val,__pu_addr,err); \ break; \