All of lore.kernel.org
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@linux-foundation.org>
To: Dan Williams <dan.j.williams@intel.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Thomas Gleixner <tglx@linutronix.de>,
	Will Deacon <will.deacon@arm.com>, Ingo Molnar <mingo@kernel.org>,
	stable <stable@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] linux/nospec.h: allow index argument to have const-qualified type
Date: Thu, 15 Feb 2018 14:03:51 -0800	[thread overview]
Message-ID: <CA+55aFz7g4wuwgc7hNFfYf+OqgPax3-F=yz8Xar7iemTin=FEg@mail.gmail.com> (raw)
In-Reply-To: <CAPcyv4hFn7jXLY43xTVPgzXVjECkpqhuj24mn5XXAyjiJq3Hyg@mail.gmail.com>

On Thu, Feb 15, 2018 at 1:56 PM, Dan Williams <dan.j.williams@intel.com> wrote:
>
> So I don't mind removing it, but I don't think it is garbage. It's
> there purely as a notification to the odd kernel developer that wants
> to pass "insane" index values,

But the thing is, the "index" value isn't even kernel-supplied.

Here's a test:  run a 32-bit kernel, and then do an ioctl() or
something with a negative fd.

What I think will happen is:

 - the negative fd will be seen as a big 'unsigned int' here:

        fcheck_files(struct files_struct *files, unsigned int fd)

which then does

                fd = array_index_nospec(fd, fdt->max_fds);

and that existing *STUPID* and *WRONG* WARN_ON() will trigger.

Sure, you can't trigger it on 64-bit kernels because there the
"unsigned int" will be small compared to LONG_MAX, but..

It is simply is *wrong* to check the "index".  It really fundamentally
is complete garbage.

Because the whole - and ONLY - *point* of this is that you have an
untrusted index. So checking it and giving a warning when it's out of
range is pure garbage.

Really. That warning must go away. Stop arguing for it, it's stupid and wrong.

Checking _size_ is one thing, but honestly, that's questionable too.

                  Linus

  reply	other threads:[~2018-02-15 22:03 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-15 13:27 [PATCH] posix-timers: Protect posix clock array access against speculation Thomas Gleixner
2018-02-15 14:05 ` Rasmus Villemoes
2018-02-15 14:39   ` Dan Williams
2018-02-15 14:53     ` Thomas Gleixner
2018-02-15 16:21       ` [PATCH V2] " Thomas Gleixner
2018-02-15 17:01         ` Peter Zijlstra
2018-03-07 18:13           ` Dan Williams
2018-03-22 11:34         ` [tip:timers/urgent] " tip-bot for Thomas Gleixner
2018-02-15 19:52     ` [PATCH] linux/nospec.h: allow index argument to have const-qualified type Rasmus Villemoes
2018-02-15 20:59       ` Linus Torvalds
2018-02-15 21:56         ` Dan Williams
2018-02-15 22:03           ` Linus Torvalds [this message]
2018-02-15 22:08             ` Dan Williams

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='CA+55aFz7g4wuwgc7hNFfYf+OqgPax3-F=yz8Xar7iemTin=FEg@mail.gmail.com' \
    --to=torvalds@linux-foundation.org \
    --cc=dan.j.williams@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    --cc=mingo@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=will.deacon@arm.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.