Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2198516pxb; Fri, 25 Mar 2022 12:53:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaaY0JsXAdbYfhOpAjU95dSFdPPe92gLxuC+MGPDI+t2N/3o6oryphiixwnb7oOBVvWLl1 X-Received: by 2002:a63:4448:0:b0:382:6f3e:a1d8 with SMTP id t8-20020a634448000000b003826f3ea1d8mr931684pgk.334.1648237992519; Fri, 25 Mar 2022 12:53:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648237992; cv=none; d=google.com; s=arc-20160816; b=QMEh0HrUX/bfoEx6cdpxYHX/YgII7oln7Q2GpHezbHoN+pvAf5vUJh1pUykIV07WBR 3tNluXFCoHCiUjloTR5NuN6g9rfzut9rLdix+G+G+gC6YMsuCfqD6GQ5k12bgSztvZNj mXb0dMA+r25CbKNNALE/uTU32Y4N1tlfVKBRuVu8Wee7ixmNoCJPLqw6oPPw/IIE2gT2 Nk+MbHw2UFZ6oF5E9NdLC4j3LpOlJnxmdJ6E9kP+2CokH9to8G5Jo5ZLyfP4ehiP2UKj Vc3yI/TW8Lmgk6eTV7ny/TbdcyztbF9QIbOGicF4Y9diA8edxAaWjMbt+aFqOXpjyKNy U4Mg== 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=6gt+atxl3cg5F5kUir4VYotWGUCYxKNQ/unwORuAf4Y=; b=vGzXQKDnOh3TOKtv8aOcKzeIsX79V9cM4pqSBmeIrOnxsjm7j0PEZPrm6+dGt9PBWq lvz0rpbTQHBZyChnekHdvhwWCL49VQ12NJdUGAggOgEp3w62Uwgm4k6sktkRssuSl3qv ivRwo0eO56grjg98igoXTuGbDu0jbSURcpEzSZ21xK5N7rmF8FXSXxTAM17/2aTA8/rz Tqu1gJjc1NWXE7S2O2r55DxGh976dgGX8exn0ldx+bcTY50uhC3gos5v71cw0Zil3wm1 kITh0Rh2VP9Puhjok/CGo/DuXNstevWgB4zM03DENeU39j7M1a8uRv8/p4Y1t3zuCyvZ 2jfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q3CG+74b; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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. [23.128.96.19]) by mx.google.com with ESMTPS id r13-20020a635d0d000000b003816043ee4esi3387036pgb.67.2022.03.25.12.53.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:53:12 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Q3CG+74b; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 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 BC06C2DB5B7; Fri, 25 Mar 2022 11:42:20 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1359803AbiCYPKk (ORCPT + 99 others); Fri, 25 Mar 2022 11:10:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1359637AbiCYPIv (ORCPT ); Fri, 25 Mar 2022 11:08:51 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DCA06C974; Fri, 25 Mar 2022 08:07:04 -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 C05D3B828FE; Fri, 25 Mar 2022 15:07:02 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31B99C340E9; Fri, 25 Mar 2022 15:07:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648220821; bh=Vbg25bV/TpMfiE09glKTOw6xxIqJBuABTUh2tukgtP8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Q3CG+74bt29o4lNkH6h33JT9s/f+b7JJ9nT2zI9c8gqzcm98KdsLig4v4DdPL15NV kFqQzMG+D/2i7HZZSxLCDpGoj8uS0oYhSBhqC2HCVWzeo9kc4gKL3qWtiXmONGATP+ KNRMtIWv+11rtxda9cT6dCCUcCEBtFY72ai+VKO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Arnd Bergmann Subject: [PATCH 4.19 20/20] nds32: fix access_ok() checks in get/put_user Date: Fri, 25 Mar 2022 16:04:58 +0100 Message-Id: <20220325150417.593583228@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220325150417.010265747@linuxfoundation.org> References: <20220325150417.010265747@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 @@ -75,9 +75,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); \ @@ -90,6 +88,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); \ @@ -170,12 +176,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; \ })