Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2140816pxb; Fri, 25 Mar 2022 11:49:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJztJasVJW9jSSDJLVHLrF2DNzgjDTbVQvv8vkhN23U/84QWso2eAbG5fCnVAs+JnYUL00ta X-Received: by 2002:a17:90b:3904:b0:1c6:c1f8:cbd8 with SMTP id ob4-20020a17090b390400b001c6c1f8cbd8mr14005217pjb.53.1648234145401; Fri, 25 Mar 2022 11:49:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648234145; cv=none; d=google.com; s=arc-20160816; b=AWqRw9byHC2Cv6Z9wLYMm0iHExf1fKXK04jkP250qjMUSJe1mvJga7Ggq10tw1ka5Z Hnck5DwrS7eNWj9Yd/TZvX8H375l1mD/gyMzjPmYzSJlgJai7cPO7oChnMysK41bfsXu RS+H7gBAdh3dP8l71+tbOd5BCuCd8Yr2C2rDRzVeTISEKbn7IeDI/olj/6QhYbHFnRQm 1VhCmbsNdztxiwMuyw2My1oq5nbKhqGM9eQ8Sv4YAe3dmtu31Y6AmAlnvL/RjJVPrmwd X/RLA+JKvSI9k1Yi80JPXpYBMBotyu+BM+WMqxtTDuWtrhg45kdSUYaIGFbkac8RfATI OT9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=umiydfXxPkSTpGDr9mc3nRleX6FL1kYZtRmAGhTzYD0=; b=VNyaa/WtL+gcf8DG6s4boxNb12RuU0/a98bk7G6B3Ve/efAFTeKNEDG8N4Wf7cF7Yi ICO4Tt6Qn6fXIlbT12hjx2YGV+kPu2RAPB5aamSKFImuMk33NwaJn3T33HbMR1U9rlHP 87Lc1aWEBid+nINa5+YPXxfwAfIlnd1URqTuw58tdyGP3WLwpISLr/u7gpYAxmu59dc/ qWO3D7kdehT+f19kqQDcVa6QDE/KUeeRjMiXOxd9yBqWa3TD98P4W0ytiJwPG1f+m3U5 4mE0Z2EobX0n4UlR4uhweQpYAAbh4vAAXfMXh3RHFxqy2Z87HtjBDpRc5W3UVMrLuWhe 9I/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AzanBU55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j4-20020a170902758400b00153b2d16448si3120372pll.80.2022.03.25.11.49.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 11:49:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AzanBU55; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id DFD021A9C98; Fri, 25 Mar 2022 11:01:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378530AbiCYPey (ORCPT + 99 others); Fri, 25 Mar 2022 11:34:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378319AbiCYPZT (ORCPT ); Fri, 25 Mar 2022 11:25:19 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52B51ECDAE; Fri, 25 Mar 2022 08:20:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 59D42B827DC; Fri, 25 Mar 2022 15:20:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD161C340E9; Fri, 25 Mar 2022 15:20:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648221613; bh=3snGlK3kA7ZUY+R0MwdxzWSgKKQaA0DAwJcsXL42dfk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AzanBU55UqfJAUGTrhEYo3rlghLbQQTv7ST75AyTy6WPs5AXkqPKBnEUxfLId6ben j9kazFEccRBKpQTl7KOOKEPYshyTR4rv1qfCjDjFZap2yAEKUsPBGqzsmxunDkgURX HHfRWnxBbeKCLb/QKuiBX3ZL69DwQYaWeyjjZrD4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Arnd Bergmann Subject: [PATCH 5.17 39/39] nds32: fix access_ok() checks in get/put_user Date: Fri, 25 Mar 2022 16:14:54 +0100 Message-Id: <20220325150421.361292101@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150420.245733653@linuxfoundation.org> References: <20220325150420.245733653@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Arnd Bergmann commit 8926d88ced46700bf6117ceaf391480b943ea9f4 upstream. The get_user()/put_user() functions are meant to check for access_ok(), while the __get_user()/__put_user() functions don't. This broke in 4.19 for nds32, when it gained an extraneous check in __get_user(), but lost the check it needs in __put_user(). Fixes: 487913ab18c2 ("nds32: Extract the checking and getting pointer to a macro") Cc: stable@vger.kernel.org @ v4.19+ Reviewed-by: Christoph Hellwig Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/nds32/include/asm/uaccess.h | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) --- a/arch/nds32/include/asm/uaccess.h +++ b/arch/nds32/include/asm/uaccess.h @@ -70,9 +70,7 @@ static inline void set_fs(mm_segment_t f * versions are void (ie, don't return a value as such). */ -#define get_user __get_user \ - -#define __get_user(x, ptr) \ +#define get_user(x, ptr) \ ({ \ long __gu_err = 0; \ __get_user_check((x), (ptr), __gu_err); \ @@ -85,6 +83,14 @@ static inline void set_fs(mm_segment_t f (void)0; \ }) +#define __get_user(x, ptr) \ +({ \ + long __gu_err = 0; \ + const __typeof__(*(ptr)) __user *__p = (ptr); \ + __get_user_err((x), __p, (__gu_err)); \ + __gu_err; \ +}) + #define __get_user_check(x, ptr, err) \ ({ \ const __typeof__(*(ptr)) __user *__p = (ptr); \ @@ -165,12 +171,18 @@ do { \ : "r"(addr), "i"(-EFAULT) \ : "cc") -#define put_user __put_user \ +#define put_user(x, ptr) \ +({ \ + long __pu_err = 0; \ + __put_user_check((x), (ptr), __pu_err); \ + __pu_err; \ +}) #define __put_user(x, ptr) \ ({ \ long __pu_err = 0; \ - __put_user_err((x), (ptr), __pu_err); \ + __typeof__(*(ptr)) __user *__p = (ptr); \ + __put_user_err((x), __p, __pu_err); \ __pu_err; \ })