Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Mon, 20 Jan 2020 15:57:33 +0300 (MSK)
From: Alexander Monakov <amonakov@...ras.ru>
To: musl@...ts.openwall.com
cc: Olaf Meeuwissen <paddy-hack@...ber.fsf.org>
Subject: Re: [BUG] ioctl: overflow in implicit constant conversion

I'll reiterate points raised previously in https://www.openwall.com/lists/musl/2017/08/30/10

On Mon, 20 Jan 2020, Szabolcs Nagy wrote:

> this is a conformance bug, since posix specifies int.
> 
> one could argue that linux requires unsigned long, but
> the correct way to introduce linux specific apis is to
> give them a different name, not something that clashes
> with standard names that have specified semantics.

But _why_ does POSIX specify 'int' there? Checking on freebsd.org
man pages I see that all BSD flavours had 'unsigned long' and Linux
followed that. Did POSIX fail to document prevailing practice in
this case?


I still think the warning points to a bigger problem that with
musl the kernel receives a sign-extended value.

So I think ioctl.c should be fixed to not sign-extend the value,
_IO macros could be changed to use (int)sizeof(c) instead of
sizeof(c), and if silencing -Wsign-conversion is also desired,

#ifdef __GNUC__
#define ioctl(fd, req, ...) ioctl(fd, (int)(req), ##__VA_ARGS__)
#endif

Alexander

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.