From patchwork Tue Jun 11 10:09:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yanjun Yang X-Patchwork-Id: 13693376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 388ACC27C5E for ; Tue, 11 Jun 2024 10:10:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=IlbqCAD+O+zI5wuLaSbWLeyNZ8LXgTW2j9VBJ4B8FeI=; b=ft8ZV7hEakakY+ bu2Ce4yMht33zHqbvM53TF/rAOGhW9gIn4QtWzoVroHKQA78Ot5inWS//hYC3p43BlA6smZoH7qxq 8Mw5jth/uWeooB9Wi/yVYZZtfjS92nel74zcbnKHiX4HruvQT4RhYxbSgcXSvQbESgt0SO0U4ko3A lQtphp7ud5bq3u+3jYnpiVsorXBHERQXZ0O7hy8cgSl9I3tirciyFB2NCdTRVQUMxtb5HGswv0ud/ jRTS3cKMjc8L8UQkXhBr95n4WSfLnNd83JfWk0eAjSPBllUjQkA7c2oEJ7hJOL2nv9StUPcSDFXoA y4VwirwFp3/dHVgy1g3w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGySA-00000008OFe-1Tyy; Tue, 11 Jun 2024 10:10:10 +0000 Received: from mail-qk1-x734.google.com ([2607:f8b0:4864:20::734]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sGyRx-00000008ODJ-3QPm for linux-arm-kernel@lists.infradead.org; Tue, 11 Jun 2024 10:10:08 +0000 Received: by mail-qk1-x734.google.com with SMTP id af79cd13be357-795310c1698so68645785a.0 for ; Tue, 11 Jun 2024 03:09:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718100596; x=1718705396; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=EReJtLG7noJcschZzZpqBgTl0az4BMt5Z/DTeKVrhAo=; b=bdIx5qIJoXD6ELf9eXEb0GcuihNKZhk4BNCNLl5roPyQbv+Eg2v/mHSlNSe2Tk1IPX K5w0ZBhC4cPFPDm7IEGstXHZd2c9Ja8AEeeghvc83OyPk5ThKV7cFQLw4y41R0AcX6Hp yiPklKqra0FqihDKF9fdr1G51zqm2vEXVaSyfdlUpNXYDTfgXIJu3yk4sOdzSpPLwsUq APmpvntCfCk/+t/Fv1JSIkaYGwGIrH6odQu2MkXN8X8GzwCuOMKzMFaab7IpHU04Swxm dsNYzAZDigKoAPX8/LVMt3rr1GUttj43KaH1SmduyUcaf2/xKVAa5teYXYH6gnaTXHeV LKQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718100596; x=1718705396; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=EReJtLG7noJcschZzZpqBgTl0az4BMt5Z/DTeKVrhAo=; b=H6uBLmJiooOkZ5tCRT6qkDaMwAFmZOZXwhTT2YyHGGMsCRbOjAFZbZf4mnKJpGT+t1 2Nr9AVeb0QrlkJOj021elSamxjlBFcIb7rCtAqiID1SvIIgpO4IZW6R5fQ3zoUN0Z8uN nJBebP0oaC1oMZ8k6Nyzfwh4jSNbmKZu0/WD0jRHmzDGF8UbD4TkQLuQfQdH27SCLVbP golwM0m35eCipgjD6/Cl97EP0UY4V8zYCSjB4jqanQrsaySGCNVABkbdGU4QUnNi7v7o j1Ws2a8sPA9eM1Ea/p49Jris6gi5gHlpNglYAM61xrm/Y2ZTTKJ/yU0/OToKaU7Xru1V gETg== X-Gm-Message-State: AOJu0Yx4VikSlTW54p6wmZQF84t0n4rTpQOP7+TN81p7I4rDDot7780k /oOBEn2psqcghLbJJAX1pZra8loyCiWmXpO0GBNwUwM+Cmr6jlOWJz3MZw== X-Google-Smtp-Source: AGHT+IE+Mr5gSCoPsIJiisbTBlpCObLKq2aHqpg1JK1NQvaToQqotAgT7y7CJxYptkqjYabBQ/WMyg== X-Received: by 2002:a05:6214:5bc5:b0:6b0:4b83:1f55 with SMTP id 6a1803df08f44-6b059f95cf3mr119294286d6.56.1718100595634; Tue, 11 Jun 2024 03:09:55 -0700 (PDT) Received: from void.tail05c47.ts.net ([45.77.110.149]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b04f6c3a68sm55809506d6.52.2024.06.11.03.09.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Jun 2024 03:09:55 -0700 (PDT) From: Yanjun Yang To: linux-arm-kernel@lists.infradead.org Cc: Yanjun Yang Subject: [PATCH] ARM: Remove address checking for MMUless devices Date: Tue, 11 Jun 2024 18:09:47 +0800 Message-ID: <20240611100947.32241-1-yangyj.ee@gmail.com> X-Mailer: git-send-email 2.45.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240611_030959_263389_8295DC3C X-CRM114-Status: GOOD ( 12.79 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Commit 169f9102f9198b ("ARM: 9350/1: fault: Implement copy_from_kernel_nofault_allowed()") added the function to check address before use. However, for devices without MMU, addr > TASK_SIZE will always fail. This patch move this function after the #ifdef CONFIG_MMU statement. Also reported at https://bugzilla.kernel.org/show_bug.cgi?id=218953 Signed-off-by: Yanjun Yang Acked-by: Ard Biesheuvel --- arch/arm/mm/fault.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/mm/fault.c b/arch/arm/mm/fault.c index 67c425341a95..ab01b51de559 100644 --- a/arch/arm/mm/fault.c +++ b/arch/arm/mm/fault.c @@ -25,6 +25,8 @@ #include "fault.h" +#ifdef CONFIG_MMU + bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) { unsigned long addr = (unsigned long)unsafe_src; @@ -32,8 +34,6 @@ bool copy_from_kernel_nofault_allowed(const void *unsafe_src, size_t size) return addr >= TASK_SIZE && ULONG_MAX - addr >= size; } -#ifdef CONFIG_MMU - /* * This is useful to dump out the page tables associated with * 'addr' in mm 'mm'.