Date: Wed, 9 Sep 2015 11:51:15 +0000 (UTC) From: Andrew Turner <andrew@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287596 - head/sys/arm64/arm64 Message-ID: <201509091151.t89BpFaC062695@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: andrew Date: Wed Sep 9 11:51:14 2015 New Revision: 287596 URL: https://svnweb.freebsd.org/changeset/base/287596 Log: Rework copyinstr to: * Fail when the length passed in is 0 * Remove an unneeded increment of the count on success * Return ENAMETOOLONG when the input pointer is too long Sponsored by: ABT Systems Ltd Modified: head/sys/arm64/arm64/copyinout.S Modified: head/sys/arm64/arm64/copyinout.S ============================================================================== --- head/sys/arm64/arm64/copyinout.S Wed Sep 9 09:19:07 2015 (r287595) +++ head/sys/arm64/arm64/copyinout.S Wed Sep 9 11:51:14 2015 (r287596) @@ -95,6 +95,7 @@ END(copyin) */ ENTRY(copyinstr) mov x5, xzr /* count = 0 */ + mov w4, #1 /* If zero return faulure */ cbz x2, 3f /* If len == 0 then skip loop */ adr x6, copyio_fault /* Get the handler address */ @@ -102,17 +103,18 @@ ENTRY(copyinstr) 1: ldrb w4, [x0], #1 /* Load from uaddr */ strb w4, [x1], #1 /* Store in kaddr */ - cbz w4, 2f /* If == 0 then break */ - sub x2, x2, #1 /* len-- */ add x5, x5, #1 /* count++ */ + cbz w4, 2f /* Break when NUL-terminated */ + sub x2, x2, #1 /* len-- */ cbnz x2, 1b 2: SET_FAULT_HANDLER(xzr, x7) /* Clear the handler */ 3: cbz x3, 4f /* Check if done != NULL */ - add x5, x5, #1 /* count++ */ str x5, [x3] /* done = count */ -4: mov x0, xzr /* return 0 */ +4: mov w1, #ENAMETOOLONG /* Load ENAMETOOLONG to return if failed */ + cmp w4, #0 /* Check if we saved the NUL-terminator */ + csel w0, wzr, w1, eq /* If so return success, else failure */ ret END(copyinstr)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201509091151.t89BpFaC062695>