This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [WIP] BZ #14361: POSIX vs. BSD and the `ioctl' interface.


On Wed, Jul 25, 2012 at 07:48:55PM -0400, Chris Metcalf wrote:
> On 7/25/2012 5:39 PM, Roland McGrath wrote:
> > The tilegx and mipsn64 code to explicitly sign-extend seems
> > misguided to me.  As Linus said in bugzilla, Linux always treats it
> > as a 32-bit quantity so it really should not care at all whether it
> > was sign-extended to 64 bits or not.
> 
> The problem is that for kernels not configured with HAVE_SYSCALL_WRAPPERS,
> calling ioctl() with a value that has bit 31 set will result in a value
> that does not compare equal within the kernel:  the passed-in value will
> have zero high bits (since the ioctl argument was prototyped as a long) but
> the kernel constant that the comparison is done against will be
> sign-extended (since it's prototyped as an int).  So the comparison fails. 
> This is true for both tilegx and mipsn64 as far as I know.

Why, when this issue first came up, could the kernel developers not be
bothered to add a simple (int) cast to the argument before it gets
used in kernelspace? That would have fixed the whole problem and made
it so fixing the userspace would be an _independent_ issue to address
rather than something with ugly kernel interaction, and it would also
have fixed hypothetical programs that use syscall(SYS_ioctl, ...) to
make ioctls...

Rich


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]