From: Jann Horn <jannh@google.com>
To: Samuel Thibault <samuel.thibault@ens-lyon.org>,
William Hubbs <w.d.hubbs@gmail.com>,
Christopher Brannon <chris@the-brannons.com>,
kirk@reisers.ca, Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
kernel list <linux-kernel@vger.kernel.org>,
speakup@linux-speakup.org, devel@driverdev.osuosl.org
Subject: Re: [PATCH] staging: speakup: fix wraparound in uaccess length check
Date: Tue, 10 Jul 2018 13:34:33 -0700 [thread overview]
Message-ID: <CAG48ez3bFxC-MrCKSNtr9di8qWAessD-ZP+51PAMiC2TMZSXOw@mail.gmail.com> (raw)
In-Reply-To: <20180707082926.66zbedgq5zqjfbjx@var.youpi.perso.aquilenet.fr>
On Sat, Jul 7, 2018 at 1:29 AM Samuel Thibault
<samuel.thibault@ens-lyon.org> wrote:
>
> Re,
>
> Could you review, test, and resubmit the patch below instead?
Er... you mean, you want me to take your patch, add my Signed-off-by
below yours, and then send that?
> Samuel
>
>
> If softsynthx_read() is called with `count < 3`, `count - 3` wraps, causing
> the loop to copy as much data as available to the provided buffer. If
> softsynthx_read() is invoked through sys_splice(), this causes an
> unbounded kernel write; but even when userspace just reads from it
> normally, a small size could cause userspace crashes.
This looks sane to me. I've also tested it, and it seems to work.
Some random thing I noticed, but I don't think it has anything to do
with this issue: In some runs, when the console is repeatedly printing
"Debian GNU/Linux 9 debian tty1\n\ndebian login: " in response to me
pressing enter repeatedly, /dev/softsynthu (read in 1-byte steps)
seems to return things like "Debian GNU slash Linux 9 debian tty1 \n
debi login: ". I don't understand why it sometimes says "debi login"
instead of "debian login".
> Fixes: 425e586cf95b ("speakup: add unicode variant of /dev/softsynth")
> Cc: stable@vger.kernel.org
> Signed-off-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
>
> --- a/drivers/staging/speakup/speakup_soft.c
> +++ b/drivers/staging/speakup/speakup_soft.c
> @@ -198,11 +198,15 @@ static ssize_t softsynthx_read(struct fi
> int chars_sent = 0;
> char __user *cp;
> char *init;
> + size_t bytes_per_ch = unicode ? 3 : 1;
> u16 ch;
> int empty;
> unsigned long flags;
> DEFINE_WAIT(wait);
>
> + if (count < bytes_per_ch)
> + return -EINVAL;
> +
> spin_lock_irqsave(&speakup_info.spinlock, flags);
> while (1) {
> prepare_to_wait(&speakup_event, &wait, TASK_INTERRUPTIBLE);
> @@ -228,7 +232,7 @@ static ssize_t softsynthx_read(struct fi
> init = get_initstring();
>
> /* Keep 3 bytes available for a 16bit UTF-8-encoded character */
> - while (chars_sent <= count - 3) {
> + while (chars_sent <= count - bytes_per_ch) {
> if (speakup_info.flushing) {
> speakup_info.flushing = 0;
> ch = '\x18';
next prev parent reply other threads:[~2018-07-10 20:35 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-07 1:53 [PATCH] staging: speakup: fix wraparound in uaccess length check Jann Horn
2018-07-07 8:01 ` Greg Kroah-Hartman
2018-07-07 8:13 ` Samuel Thibault
2018-07-07 8:22 ` Jann Horn
2018-07-07 8:32 ` Samuel Thibault
2018-07-07 8:29 ` Samuel Thibault
2018-07-07 14:03 ` Greg Kroah-Hartman
2018-07-10 20:34 ` Jann Horn
2018-07-11 9:27 ` Greg Kroah-Hartman
2018-07-10 20:34 ` Jann Horn [this message]
2018-07-11 9:44 ` Samuel Thibault
2018-07-12 22:29 Jann Horn
2018-07-12 22:47 ` Al Viro
2018-07-12 23:12 ` Jann Horn
2018-07-13 8:31 ` Greg Kroah-Hartman
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=CAG48ez3bFxC-MrCKSNtr9di8qWAessD-ZP+51PAMiC2TMZSXOw@mail.gmail.com \
--to=jannh@google.com \
--cc=chris@the-brannons.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kirk@reisers.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=samuel.thibault@ens-lyon.org \
--cc=speakup@linux-speakup.org \
--cc=w.d.hubbs@gmail.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 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).