Received: by 2002:a05:6a10:2726:0:0:0:0 with SMTP id ib38csp2168812pxb; Fri, 25 Mar 2022 12:19:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzdytlp5EdxjuOcJEsVmb5TJtfnOdX0sdPi/q19sGUAw2haagpijN7/6DAXOprRF9oJg0p5 X-Received: by 2002:a17:90b:1bc6:b0:1c7:69d:e80f with SMTP id oa6-20020a17090b1bc600b001c7069de80fmr26474708pjb.202.1648235952358; Fri, 25 Mar 2022 12:19:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1648235952; cv=none; d=google.com; s=arc-20160816; b=U51vVLc7GLFLDrW2e1rORv2HYXvF3jSWlMAkgwQ6BevEHSObu+t/IDmhRIBHKb/bVC IWAbMAlynHedFtU2sK3TtpNk6yM5sAfekL761wZmMS//ZHaB3o3Lr28jQQXfZXx/LL1P IJMQ6Mgu6LcczO09LnAJVH/JJhyg6iXlM40wYVqX2qv5Cply1byTgWtsR6N9CufKT3OT U2WrOus/UEowcbdAuqbuDBbVhQDWV/dPBKYuiTwZNYioQ1IOOg7iEFQZFSr5qEquarCM Zge/evNF1aOg07FdYaaA8psY44ia0LJkj157dr6DXBMfbmVcTDSenRbVbZrj3WSShvxh 2YQw== 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=7IzHpsJ+2kKuqyyDjXsPAadLsPzyG8VJioeqFckfh/4=; b=sPuiVhzIplQzjD+c3oR5/4GP+qZz4o2MUT/sIqvdqRk3qpWMhBxP0WFtt8z/SmZ9Wf mXMX5uUnDQCYBUq2/VAWogiln29an47q7Yi2cKAynBVvEqlWj2K9KAqVgNUNVzh064gu rFFk5nrevpWdRV114R0igMr1HeiKyBPEMtPNI5baDDWwhLDdyx12NiO8MUIyHHX2/7B8 spGysUwneckDfiYvSZk6PUpCHWEMRjM8w1lVjpkyvaegY7leTr2kKNFcscPs99dAzDjB urM0nZ+/kun3Pyk5bC05yaNvZLnRcFw1qNlSsCbIZ34V/E8eBvjuMO5DtV8Hhm7hNU38 NXsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=LPJ6oNB8; 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 n126-20020a622784000000b004fa98040016si3182515pfn.142.2022.03.25.12.19.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 25 Mar 2022 12:19: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=LPJ6oNB8; 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 BBC0224B09E; Fri, 25 Mar 2022 11:24:19 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376825AbiCYPcU (ORCPT + 99 others); Fri, 25 Mar 2022 11:32:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60432 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378263AbiCYPZP (ORCPT ); Fri, 25 Mar 2022 11:25:15 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 410C6ECC44; Fri, 25 Mar 2022 08:20:11 -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 dfw.source.kernel.org (Postfix) with ESMTPS id CECCA61451; Fri, 25 Mar 2022 15:20:10 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DB2D3C340E9; Fri, 25 Mar 2022 15:20:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1648221610; bh=2Y7SEJ45GUxU9Jc1FeEiiIgPS7sVZVqp/nNW4EwEPk4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=LPJ6oNB8Y+tArCj0kT7KH3Fqfw8SpD2KCiGXFjyqNsehnV3f1P6+5P75opywYm2Wi Kw5eH06SoyJtvttv1/KeTvLU7TNXzXKVNI+hS7AYisXiS7uN2A9O6YhVxob6BAnbez Ows6j88lYeaX58L3Chosnu1QKLjA3K0YktHxjVIA= 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 38/39] m68k: fix access_ok for coldfire Date: Fri, 25 Mar 2022 16:14:53 +0100 Message-Id: <20220325150421.333278681@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 26509034bef198525d5936c116cbd0c3fa491c0b upstream. While most m68k platforms use separate address spaces for user and kernel space, at least coldfire does not, and the other ones have a TASK_SIZE that is less than the entire 4GB address range. Using the default implementation of __access_ok() stops coldfire user space from trivially accessing kernel memory. Reviewed-by: Christoph Hellwig Cc: stable@vger.kernel.org Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- arch/m68k/include/asm/uaccess.h | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) --- a/arch/m68k/include/asm/uaccess.h +++ b/arch/m68k/include/asm/uaccess.h @@ -12,14 +12,17 @@ #include /* We let the MMU do all checking */ -static inline int access_ok(const void __user *addr, +static inline int access_ok(const void __user *ptr, unsigned long size) { - /* - * XXX: for !CONFIG_CPU_HAS_ADDRESS_SPACES this really needs to check - * for TASK_SIZE! - */ - return 1; + unsigned long limit = TASK_SIZE; + unsigned long addr = (unsigned long)ptr; + + if (IS_ENABLED(CONFIG_CPU_HAS_ADDRESS_SPACES) || + !IS_ENABLED(CONFIG_MMU)) + return 1; + + return (size <= limit) && (addr <= (limit - size)); } /*