NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

port-arm/57388: Minor bug fix in bcopy.S



>Number:         57388
>Category:       port-arm
>Synopsis:       Minor bug fix in bcopy.S
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-arm-maintainer
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon May 01 20:30:00 +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
 



Home | Main Index | Thread Index | Old Index