lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Date:	Thu, 14 Sep 2006 00:24:13 -0700
From:	Zachary Amsden <zach@...are.com>
To:	Albert Cahalan <acahalan@...il.com>
Cc:	"Eric W. Biederman" <ebiederm@...ssion.com>, torvalds@...l.org,
	jeremy@...p.org, mingo@...e.hu, ak@...e.de, arjan@...radead.org,
	linux-kernel@...r.kernel.org
Subject: Re: Assignment of GDT entries

Albert Cahalan wrote
>>
>> There are only 32 possible GDT entries in 32-bit i386 Linux, and only
>> three of them are usable for userspace.  You can't find out which slots
>> are in use, but you can cause one to be allocated and returned to you.
>> This seems like a perfectly reasonable API to me, why do you think it is
>> so ugly?
>
> Eh, "returned to you" doesn't work for me. I need to
> figure out what other code (not written by me) uses.

I don't understand.  Why do you need to figure that out?  You need a 
selector, you ask for one, and you get assigned one.  It is that 
simple.  You can't figure out what other code uses, and the kernel has 
no way to tell you, because that is an application level allocation 
problem, not a kernel responsibility.  The kernel has no visibility into 
userspace intentions regarding segment usage.

> I may need to "borrow" a slot if all three slots are in
> use. Without using evil knowledge of the GDT, how
> am I to do that? I don't know what slots might have
> been allocated by other libraries.

What kind of libraries are you using?  Unless this is really, really, 
special purpose, they are going to allocate at most one, and that is 
only if you use TLS libraries.

If all three slots are in use (i.e. your allocation fails), you'll have 
to allocate an LDT selector, just like wine:

void wine_ldt_init_fs( unsigned short sel, const LDT_ENTRY *entry )
{
    if ((sel & ~3) == (global_fs_sel & ~3))
    {
#ifdef __linux__
        struct modify_ldt_s ldt_info;
        int ret;

        ldt_info.entry_number = sel >> 3;
        fill_modify_ldt_struct( &ldt_info, entry );
        if ((ret = set_thread_area( &ldt_info ) < 0)) perror( 
"set_thread_area" );
#elif defined(__APPLE__)
        int ret = thread_set_user_ldt( wine_ldt_get_base(entry), 
wine_ldt_get_limit(entry), 0 );
        if (ret == -1) perror( "thread_set_user_ldt" );
        else assert( ret == global_fs_sel );
#endif  /* __APPLE__ */
    }
    else  /* LDT selector */
    {
        internal_set_entry( sel, entry );  <---- just like this
    }
    wine_set_fs( sel );
}

Zach
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ