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 056A1C761A6 for ; Sat, 1 Apr 2023 01:44:59 +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=aoynOtWQQA7cOw8kKQ9FjOj1pUTRBs/u30982jNT8nw=; b=1VSgU/JNLamtmC 4tJwnyGVWs8DbFfIiVVLDZzaHm9C8ZzQS3USGnxH8YOCpMintFAHGKrxaBxt4qnrlwxR1rNQUZ5YU PARJtR6qKeOco1fA9POsNHJ5NYlplzIvgLDIqQ6U5jhL9XwdISigoBgZsu54/HNW0LdPtgSlQANa0 kpVX5GA/ylULPi+XJULANeEJuXSIv9kfBAmWXFzEI7pnwcQCtKsdfjgcE0IVAaU9jcxynK/NT312c CgZ0YxDgSVZXj93D7gznkNN8MMozkXQGQgDrutkpzvS12ss8anp4pYforIT2WKjBtH/3/crw1c4/H mCgpb+ZEjibbza+RTy+A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1piQHe-009UWP-2M; Sat, 01 Apr 2023 01:43:58 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1piQHa-009UTv-22 for linux-arm-kernel@lists.infradead.org; Sat, 01 Apr 2023 01:43:56 +0000 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 0D1766240C; Sat, 1 Apr 2023 01:43:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6A016C433D2; Sat, 1 Apr 2023 01:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1680313433; bh=+CQiA2TpuPtNk29w+WbITPO+Y/iqiI7Ncoa4XcxFW/I=; h=From:To:Cc:Subject:Date:From; b=BfttM5nAReRBBPaZ6JQkvC80GgSXaoPOJVn4JyRK7XXO+Ow3ssbtljnW56CXYl/3h iEJKnrI1vx4tWZGmzsIHkvFHdPwUA1SxiffGPOsLxxa330MiY/oT6W1jIr/f0pHbK4 Gd5uMql/PUiMrf8dgqELlliSEyMRa02GOYdXEe8i/ke3ng8A4A9PW5aIh9uJOGt+Gb oe6zgnA5fwdJ02bfjMJ4jb+ttPKaSx4YyNX7yScyGTdw5rhq4ArscQHXRlm5chupmK Z/jpwf+c4sF+OWOdo6ORz8UCsiOxhiLFI89KQYSTcwv09/CZ0sEOIWH/ELNc3adLgn mK+Y+ejXWNnmQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Andrew Jeffery , Zev Weiss , Arnd Bergmann , Russell King , Sasha Levin , linux@armlinux.org.uk, akpm@linux-foundation.org, anshuman.khandual@arm.com, linux-arm-kernel@lists.infradead.org Subject: [PATCH AUTOSEL 5.15 01/11] ARM: 9290/1: uaccess: Fix KASAN false-positives Date: Fri, 31 Mar 2023 21:43:39 -0400 Message-Id: <20230401014350.3357107-1-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230331_184354_710582_34E88309 X-CRM114-Status: GOOD ( 12.11 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Andrew Jeffery [ Upstream commit ceac10c83b330680cc01ceaaab86cd49f4f30d81 ] __copy_to_user_memcpy() and __clear_user_memset() had been calling memcpy() and memset() respectively, leading to false-positive KASAN reports when starting userspace: [ 10.707901] Run /init as init process [ 10.731892] process '/bin/busybox' started with executable stack [ 10.745234] ================================================================== [ 10.745796] BUG: KASAN: user-memory-access in __clear_user_memset+0x258/0x3ac [ 10.747260] Write of size 2687 at addr 000de581 by task init/1 Use __memcpy() and __memset() instead to allow userspace access, which is of course the intent of these functions. Signed-off-by: Andrew Jeffery Signed-off-by: Zev Weiss Reviewed-by: Arnd Bergmann Signed-off-by: Russell King (Oracle) Signed-off-by: Sasha Levin --- arch/arm/lib/uaccess_with_memcpy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/arm/lib/uaccess_with_memcpy.c b/arch/arm/lib/uaccess_with_memcpy.c index 106f83a5ea6d2..35e03f6a62127 100644 --- a/arch/arm/lib/uaccess_with_memcpy.c +++ b/arch/arm/lib/uaccess_with_memcpy.c @@ -121,7 +121,7 @@ __copy_to_user_memcpy(void __user *to, const void *from, unsigned long n) tocopy = n; ua_flags = uaccess_save_and_enable(); - memcpy((void *)to, from, tocopy); + __memcpy((void *)to, from, tocopy); uaccess_restore(ua_flags); to += tocopy; from += tocopy; @@ -188,7 +188,7 @@ __clear_user_memset(void __user *addr, unsigned long n) tocopy = n; ua_flags = uaccess_save_and_enable(); - memset((void *)addr, 0, tocopy); + __memset((void *)addr, 0, tocopy); uaccess_restore(ua_flags); addr += tocopy; n -= tocopy; -- 2.39.2 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel