From: Ian Kent <raven@themaw.net>
To: Matthew Wilcox <willy@infradead.org>,
autofs@vger.kernel.org, linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>
Subject: Re: [PATCH] Harden autofs ioctl table
Date: Thu, 20 Aug 2020 13:11:11 +0800 [thread overview]
Message-ID: <5ce39603821b0108a58d3be547d97b65b9c31fdb.camel@themaw.net> (raw)
In-Reply-To: <20200818122203.GO17456@casper.infradead.org>
On Tue, 2020-08-18 at 13:22 +0100, Matthew Wilcox wrote:
> The table of ioctl functions should be marked const in order to put
> them
> in read-only memory, and we should use array_index_nospec() to avoid
> speculation disclosing the contents of kernel memory to userspace.
>
> Signed-off-by: Matthew Wilcox (Oracle) <willy@infradead.org>
Acked-by: Ian Kent <raven@themaw.net>
Thanks Matthew, I certainly want to know about changes to autofs
made by others so thanks for sending this to me.
At the same time I need to send my patches via someone else as
Linus asked me to do ages ago now.
So, once again Andrew, if you would be so kind as to include this
in your tree please.
Ian
>
> diff --git a/fs/autofs/dev-ioctl.c b/fs/autofs/dev-ioctl.c
> index 75105f45c51a..322b7dfb4ea0 100644
> --- a/fs/autofs/dev-ioctl.c
> +++ b/fs/autofs/dev-ioctl.c
> @@ -8,6 +8,7 @@
> #include <linux/compat.h>
> #include <linux/syscalls.h>
> #include <linux/magic.h>
> +#include <linux/nospec.h>
>
> #include "autofs_i.h"
>
> @@ -563,7 +564,7 @@ static int autofs_dev_ioctl_ismountpoint(struct
> file *fp,
>
> static ioctl_fn lookup_dev_ioctl(unsigned int cmd)
> {
> - static ioctl_fn _ioctls[] = {
> + static const ioctl_fn _ioctls[] = {
> autofs_dev_ioctl_version,
> autofs_dev_ioctl_protover,
> autofs_dev_ioctl_protosubver,
> @@ -581,7 +582,10 @@ static ioctl_fn lookup_dev_ioctl(unsigned int
> cmd)
> };
> unsigned int idx = cmd_idx(cmd);
>
> - return (idx >= ARRAY_SIZE(_ioctls)) ? NULL : _ioctls[idx];
> + if (idx >= ARRAY_SIZE(_ioctls))
> + return NULL;
> + idx = array_index_nospec(idx, ARRAY_SIZE(_ioctls));
> + return _ioctls[idx];
> }
>
> /* ioctl dispatcher */
prev parent reply other threads:[~2020-08-20 5:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-18 12:22 Matthew Wilcox
2020-08-20 5:11 ` Ian Kent [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=5ce39603821b0108a58d3be547d97b65b9c31fdb.camel@themaw.net \
--to=raven@themaw.net \
--cc=akpm@linux-foundation.org \
--cc=autofs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=willy@infradead.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®