Re: how to detect a 32 bit process on 64 bit kernel

From: Jan Engelhardt
Date: Sun Dec 12 2004 - 17:04:31 EST


>Hello!
>Is there a reliable way e.g. on x86-64 (or ia64, or any other
>64-bit system), from the char device driver,
>to find out that I am running an operation in the context of a 32-bit
>task?

I doubt you can distinguish these two (with the exception of looking at the
ELF header of a file), because

mov eax, 12345;

is valid for classic IA-32 -and- amd64, just as "mov ax,12" works for
any >= 80286.

>If no - would not it make a sence to add e.g. a flag in the
>task struct, to make it possible?

I do not see a reason why I would want to know this kind of information ATM,
so this is something you will probably have keep in your own tree.

Basically, it is possible, you probably have to patch fs/binfmt_elf.c
a little to store a flag whether an ELF32 or ELF64 is currently being
executed, and store it preferably in current->some_var_name;

Then you will also need to poke in fs/proc/* to export this information to
userspace, otherwise there is no meaning in patching the task struct.



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