NetBSD Problem Report #57388

From www@netbsd.org  Mon May  1 20:26:53 2023
Return-Path: <www@netbsd.org>
Received: from mail.netbsd.org (mail.netbsd.org [199.233.217.200])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "mail.NetBSD.org CA" (not verified))
	by mollari.NetBSD.org (Postfix) with ESMTPS id D1E941A9238
	for <gnats-bugs@gnats.NetBSD.org>; Mon,  1 May 2023 20:26:52 +0000 (UTC)
Message-Id: <20230501202430.07FEB1A9239@mollari.NetBSD.org>
Date: Mon,  1 May 2023 20:24:30 +0000 (UTC)
From: apokusinski@o2.pl
Reply-To: apokusinski@o2.pl
To: gnats-bugs@NetBSD.org
Subject: Minor bug fix in bcopy.S
X-Send-Pr-Version: www-1.0

>Number:         57388
>Category:       port-arm
>Synopsis:       Minor bug fix in bcopy.S
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    skrll
>State:          closed
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 01 20:30:00 +0000 2023
>Closed-Date:    Sun Jul 23 09:53:33 +0000 2023
>Last-Modified:  Sun Jul 23 09:53:33 +0000 2023
>Originator:     Antoni Pokusinski
>Release:        2023-05-01
>Organization:
>Environment:
>Description:
This patch fixes a minor bug in lib/libc/arch/aarch64/string/bcopy.S.
The spotted problem is a wrong address alignment check in backward_copy, which results in executing inappropriate piece of code (samealign_backward_small instead of notaligned_backward_small). The values being checked are SRC0 and DST0 which are addresses of the beginning of source buffer and the end of destination buffer respectively. Instead, we should check for alignment of the ends of buffers (so the addresses being checked should be SRC0 and DST), as we are about to perform a backward copy.

>How-To-Repeat:

>Fix:
diff --git a/common/lib/libc/arch/aarch64/string/bcopy.S b/common/lib/libc/arch/aarch64/string/bcopy.S
index 36918d576..bf0b5bd96 100644
--- a/common/lib/libc/arch/aarch64/string/bcopy.S
+++ b/common/lib/libc/arch/aarch64/string/bcopy.S
@@ -306,7 +306,7 @@ backward_tiny:
 	ret
 9:
 	/* length is small(<32), and src or dst may be unaligned */
-	eor	TMP_X, SRC0, DST0
+	eor	TMP_X, SRC0, DST
 	ands	TMP_X, TMP_X, #7
 	bne	notaligned_backward_small


>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: port-arm-maintainer->skrll
Responsible-Changed-By: skrll@NetBSD.org
Responsible-Changed-When: Wed, 03 May 2023 09:27:12 +0000
Responsible-Changed-Why:
Take


State-Changed-From-To: open->closed
State-Changed-By: skrll@NetBSD.org
State-Changed-When: Sun, 23 Jul 2023 09:53:33 +0000
State-Changed-Why:
fix applied. thanks for the PR.


>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.47 2022/09/11 19:34:41 kim Exp $
$NetBSD: gnats_config.sh,v 1.9 2014/08/02 14:16:04 spz Exp $
Copyright © 1994-2023 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.