Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 9 Oct 2017 16:20:39 +0000 (UTC)
From:      Konstantin Belousov <kib@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r324439 - head/sys/amd64/amd64
Message-ID:  <201710091620.v99GKdVI059609@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: kib
Date: Mon Oct  9 16:20:39 2017
New Revision: 324439
URL: https://svnweb.freebsd.org/changeset/base/324439

Log:
  Change amd64_get_ldt() to return 'EOF' when the LDT is not yet
  allocated, when requested range of descriptors does not fit into
  currently allocated LDT, or trim the return if the range fits
  partially.  Before, the function returned EINVAL.
  
  Reviewed by:	bde
  Sponsored by:	The FreeBSD Foundation
  MFC after:	1 week

Modified:
  head/sys/amd64/amd64/sys_machdep.c

Modified: head/sys/amd64/amd64/sys_machdep.c
==============================================================================
--- head/sys/amd64/amd64/sys_machdep.c	Mon Oct  9 16:19:26 2017	(r324438)
+++ head/sys/amd64/amd64/sys_machdep.c	Mon Oct  9 16:20:39 2017	(r324439)
@@ -556,12 +556,12 @@ amd64_get_ldt(struct thread *td, struct i386_ldt_args 
 	    uap->start, uap->num, (void *)uap->descs);
 #endif
 
-	if (uap->start >= max_ldt_segment)
-		return (EINVAL);
-	num = min(uap->num, max_ldt_segment - uap->start);
 	pldt = td->td_proc->p_md.md_ldt;
-	if (pldt == NULL)
-		return (EINVAL);
+	if (pldt == NULL || uap->start >= max_ldt_segment || uap->num == 0) {
+		td->td_retval[0] = 0;
+		return (0);
+	}
+	num = min(uap->num, max_ldt_segment - uap->start);
 	lp = &((struct user_segment_descriptor *)(pldt->ldt_base))[uap->start];
 	data = malloc(num * sizeof(struct user_segment_descriptor), M_TEMP,
 	    M_WAITOK);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201710091620.v99GKdVI059609>