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
This commit is contained in:
kib 2017-10-09 16:20:39 +00:00
parent 8844e99855
commit 8bde9fde3b

View File

@ -556,12 +556,12 @@ amd64_get_ldt(struct thread *td, struct i386_ldt_args *uap)
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);