From: Al Viro <viro@ZenIV.linux.org.uk>
To: Daniel Rosenberg <drosen@google.com>
Cc: Jiri Kosina <jikos@kernel.org>,
Benjamin Tissoires <benjamin.tissoires@redhat.com>,
linux-input@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@android.com, stable@vger.kernel.org
Subject: Re: [PATCH] HID: debug: check length before copy_to_user()
Date: Thu, 5 Jul 2018 01:47:01 +0100 [thread overview]
Message-ID: <20180705004700.GB30522@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20180702235937.111619-1-drosen@google.com>
On Mon, Jul 02, 2018 at 04:59:37PM -0700, Daniel Rosenberg wrote:
> If our length is greater than the size of the buffer, we
> overflow the buffer
Hmm...
How about this:
buf = list->hid_debug_buf;
if (list->tail < list->head) {
ret = simple_read_from_buffer(buffer, count, &list->head,
buf, HID_DEBUG_BUFSIZE);
if (ret < 0)
break;
if (list->head != buf + HID_DEBUG_BUFSIZE)
break;
list->head = 0;
}
n = simple_read_from_buffer(buffer + ret, count - ret, &list->head,
buf, list->tail);
if (n >= 0)
ret += n;
if (list->head == buf + HID_DEBUG_BUFSIZE)
list->head = 0;
instead?
prev parent reply other threads:[~2018-07-05 0:47 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-02 23:59 [PATCH] HID: debug: check length before copy_to_user() Daniel Rosenberg
2018-07-03 7:50 ` Benjamin Tissoires
2018-07-03 9:55 ` Jiri Kosina
2018-07-05 0:47 ` Al Viro [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=20180705004700.GB30522@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=benjamin.tissoires@redhat.com \
--cc=drosen@google.com \
--cc=jikos@kernel.org \
--cc=kernel-team@android.com \
--cc=linux-input@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.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