Messages in this thread | | | Date | Mon, 13 Dec 2004 23:37:54 +0200 | From | "Michael S. Tsirkin" <> | Subject | Re: how to detect a 32 bit process on 64 bit kernel |
| |
Hello! Quoting r. Brian Gerst (bgerst@didntduck.org) "Re: how to detect a 32 bit process on 64 bit kernel": > Michael S. Tsirkin wrote: > > >Hello! > >Quoting r. Christoph Hellwig (hch@infradead.org) "Re: how to detect a 32 > >bit process on 64 bit kernel": > > > >>>If no - would not it make a sence to add e.g. a flag in the > >>>task struct, to make it possible? > >> > >>The kernel code shouldn't know. If your driver needs this information > >>something is seriously wrong with it. > > > > > >A character driver I am working on gets passed a structure > >from user space by implementing a write file operation. > >The structure includes a pointer and so the format varies > >between a 32 and 64 bit processes. > > The most portable way to do this is to have the first member of the > structure be a 32-bit value containing the size of the structure. This > can then be used to identify what the structure format is. This also > has the advantage of future-proofing the interface (add a field? no > problem, the new size can be checked for). Just be very careful that > the size from userspace is not trusted (ie. only allow known sizes). > > -- > Brian Gerst
The size wont be sufficient here since its variable size (ends with an array).
Sure, I could also just ask everyone to pass pointers in a packed long long, but either way it will break the applications.
Why wouldnt it make sence for struct task to have a bit that tells me its a compat system?
MST - To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
| |