mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: [musl] [BUG] ioctl: overflow in implicit constant conversion
Date: Mon, 20 Jan 2020 12:14:25 -0500	[thread overview]
Message-ID: <20200120171425.GL30412@brightrain.aerifal.cx> (raw)
In-Reply-To: <alpine.LNX.2.20.13.2001201544180.7204@monopod.intra.ispras.ru>

On Mon, Jan 20, 2020 at 03:57:33PM +0300, Alexander Monakov wrote:
> 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'm not sure. I'm guessing there were more influential proprietary
unices at the time whose definitions won out in committee. After all,
the POSIX ioctl definition was built around STREAMS, not other
historic use which seems to have been deemed sufficiently
system-specific not to standardize despite having widespread
overlapping parts. :(

But in any case, portable software already has to be tolerant of
either version.

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

If this is actually an issue it can be fixed with:

-	int r = __syscall(SYS_ioctl, fd, req, arg);
+	int r = __syscall(SYS_ioctl, fd, (unsigned)req, arg);

It has no relation to the public interface of the function.

Rich

  reply	other threads:[~2020-01-20 17:14 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-20 10:39 Olaf Meeuwissen
2020-01-20 12:09 ` Szabolcs Nagy
2020-01-20 12:57   ` Alexander Monakov
2020-01-20 17:14     ` Rich Felker [this message]
2020-01-20 13:08   ` Alexander Monakov
2020-01-21 12:27   ` Olaf Meeuwissen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200120171425.GL30412@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).