From owner-freebsd-hackers@FreeBSD.ORG Thu Jun 25 22:25:33 2009 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B3BC106564A for ; Thu, 25 Jun 2009 22:25:33 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) Received: from zivm-out1.uni-muenster.de (ZIVM-OUT1.UNI-MUENSTER.DE [128.176.192.8]) by mx1.freebsd.org (Postfix) with ESMTP id D454B8FC17 for ; Thu, 25 Jun 2009 22:25:32 +0000 (UTC) (envelope-from a_best01@uni-muenster.de) X-IronPort-AV: E=Sophos;i="4.42,292,1243807200"; d="scan'208";a="275475461" Received: from zivmaildisp2.uni-muenster.de (HELO ZIVMAILUSER01.UNI-MUENSTER.DE) ([128.176.188.143]) by zivm-relay1.uni-muenster.de with ESMTP; 26 Jun 2009 00:25:32 +0200 Received: by ZIVMAILUSER01.UNI-MUENSTER.DE (Postfix, from userid 149459) id DA7C21B0763; Fri, 26 Jun 2009 00:25:31 +0200 (CEST) Date: Fri, 26 Jun 2009 00:25:31 +0200 (CEST) From: Alexander Best Sender: Organization: Westfaelische Wilhelms-Universitaet Muenster To: Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Subject: linux syscall modify_ldt() returning wrong errno X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 25 Jun 2009 22:25:33 -0000 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. ;-)