linux syscall modify_ldt() returning wrong errno
Alexander Best
alexbestms at math.uni-muenster.de
Thu Jun 25 22:25:33 UTC 2009
hi there,
i'm currently playing a bit with the linux test project (ltp). it seems the
linux syscall modify_ldt() isn't implemented correctly. the following code
should set errno to ENOSYS, but instead EINVAL is being returned:
int main(int ac, char **av)
{
int lc; /* loop counter */
char *msg; /* message returned from parse_opts */
void *ptr;
int retval, func;
int flag;
int seg[4];
/* parse standard options */
if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) != (char
*)NULL) {
tst_brkm(TBROK, cleanup, "OPTION PARSING ERROR - %s", msg);
/*NOTREACHED*/}
setup(); /* global setup */
/* The following loop checks looping state if -i option given */
for (lc = 0; TEST_LOOPING(lc); lc++) {
/* reset Tst_count in case we are looping */
Tst_count = 0;
//block1:
/*
* Check for ENOSYS.
*/
tst_resm(TINFO, "Enter block 1");
flag = 0;
ptr = (void *)malloc(10);
func = 100;
retval = modify_ldt(func, ptr, sizeof(ptr));
if (retval < 0) {
if (errno != ENOSYS) {
tst_resm(TFAIL, "modify_ldt() set invalid "
"errno, expected ENOSYS, got: %d",
errno);
flag = FAILED;
}
here's the way linux does it:
http://fxr.watson.org/fxr/source/arch/x86_64/kernel/ldt.c?v=linux-2.6;im=bigexcerpts#L233
and this is how the syscall was implemented in freebsd:
http://fxr.watson.org/fxr/source/i386/linux/linux_machdep.c#L861
here's the modify_ldt() manual:
http://linux.about.com/library/cmd/blcmdl2_modify_ldt.htm
cheers.
oh...and we're talking HEAD of course. ;-)
More information about the freebsd-hackers
mailing list