mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Markus Wichmann <nullplan@gmx.net>
Cc: musl@lists.openwall.com
Subject: Re: [musl] Re: [BUG] ioctl: overflow in implicit constant conversion
Date: Wed, 22 Feb 2023 10:53:49 -0500	[thread overview]
Message-ID: <20230222155349.GC4163@brightrain.aerifal.cx> (raw)
In-Reply-To: <20230222042244.GH1903@voyager>

On Wed, Feb 22, 2023 at 05:23:12AM +0100, Markus Wichmann wrote:
> On Tue, Feb 21, 2023 at 10:17:31PM -0500, Rich Felker wrote:
> > Unless you're seeing something I'm not, there's no UB. The shifts take
> > place on the unsigned type, and the conversion from unsigned to signed
> > is implementation-defined, not undefined. The implementation-defined
> > definition relevant to us is modular reduction.
> >
> 
> Yeah, sorry, I had missed that the directions are defined as unsigned
> constants. That turns any shift that might have been undefined into an
> unsigned shift, where it is defined. As I said in the other mail, the
> compiler is just warning about nothing here, and it should probably not
> warn for system header files, anyway.
> 
> We may be able to silence the compiler by adding an explicit int
> conversion to the _IOC macro. But I'm not sure if we want to set a
> precedent that we will add code just to shut up overeager warnings.

I think it's reasonably arguable that the ioctl command macros should
have the right type matching the type the ioctl function takes. But
it's possible there could be places where sign extension bites you
then. As a stupid example, if someone bypassed the libc function and
tried to make the ioctl syscall directly, having the macros be of
signed type would cause the kernel to receive them with a bunch of
ones in the high bits, and possibly reject them as a result. I'm not
sure if there's any reasonable usage that would be impacted, though.

Rich

      reply	other threads:[~2023-02-22 15:54 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-21  5:26 Ralph Little
2023-02-21 16:04 ` Markus Wichmann
2023-02-21 16:42   ` Florian Weimer
2023-02-21 16:53     ` alice
2023-02-21 16:57   ` Jeffrey Walton
2023-02-21 18:25     ` Ralph Little
2023-02-21 21:28     ` Markus Wichmann
2023-02-22  6:33       ` NRK
2023-02-22  3:17   ` Rich Felker
2023-02-22  4:23     ` Markus Wichmann
2023-02-22 15:53       ` Rich Felker [this message]

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=20230222155349.GC4163@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=nullplan@gmx.net \
    /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).