From owner-svn-src-head@freebsd.org Wed Sep 9 11:51:15 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9F9269CD77F; Wed, 9 Sep 2015 11:51:15 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9057113C9; Wed, 9 Sep 2015 11:51:15 +0000 (UTC) (envelope-from andrew@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t89BpFm1062696; Wed, 9 Sep 2015 11:51:15 GMT (envelope-from andrew@FreeBSD.org) Received: (from andrew@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t89BpFaC062695; Wed, 9 Sep 2015 11:51:15 GMT (envelope-from andrew@FreeBSD.org) Message-Id: <201509091151.t89BpFaC062695@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: andrew set sender to andrew@FreeBSD.org using -f From: Andrew Turner Date: Wed, 9 Sep 2015 11:51:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r287596 - head/sys/arm64/arm64 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Sep 2015 11:51:15 -0000 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)