Ah, thanks. It didn't occur to me that set_thread_area and modify_ldt would have different behavior w.r.t. allowing code segments.
I'll play around with it and see what happens.
On Sun, May 19, 2019 at 5:42 PM Zebediah Figura z.figura12@gmail.com wrote:
On 5/19/19 4:58 PM, Andrew Wesie wrote:
On Sun, May 19, 2019 at 4:07 PM Ken Thomases ken@codeweavers.com wrote:
Perhaps 4: use a different code segment so that the %cs segment selector doesn't look like a WoW64 environment. Kind of specific to this particular app's behavior, so not great, but maybe passable.
This possibility was considered but I didn't think it was possible to do this on Linux any more without patching the kernel. Notably from the man page for set_thread_area: "Since Linux 3.19, set_thread_area() cannot be used to write non-present segments, 16-bit segments, or code segments, although clearing a segment is still acceptable." The associated source code: https://elixir.bootlin.com/linux/v3.19/source/arch/x86/kernel/tls.c#L63.
Please let me know if my understanding is incorrect.
Presumably we could use the LDT [and modify_ldt(2)] instead, as we already do for NE segmentation?