From: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
To: Ashutosh Dixit <ashutosh.dixit@intel.com>,
Sudeep Dutt <sudeep.dutt@intel.com>
Cc: Caz Yokoyama <Caz.Yokoyama@intel.com>,
Dasaratharaman Chandramouli
<dasaratharaman.chandramouli@intel.com>,
Nikhil Rao <nikhil.rao@intel.com>,
Harshavardhan R Kharche <harshavardhan.r.kharche@intel.com>,
Peter P Waskiewicz Jr <peter.p.waskiewicz.jr@intel.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Intel MIC host driver: possible signed underflow (undefined behavior) in userspace API
Date: Fri, 10 Jan 2014 05:56:25 +0000 (UTC) [thread overview]
Message-ID: <1593870977.5807.1389333385962.JavaMail.zimbra@efficios.com> (raw)
In-Reply-To: <1151498255.5788.1389332631491.JavaMail.zimbra@efficios.com>
Hi,
Looking at this commit:
commit f69bcbf3b4c4b333dcd7a48eaf868bf0c88edab5
Author: Ashutosh Dixit <ashutosh.dixit@intel.com>
Date: Thu Sep 5 16:42:18 2013 -0700
Intel MIC Host Driver Changes for Virtio Devices.
Especially at:
+struct mic_copy_desc {
+#ifdef __KERNEL__
+ struct iovec __user *iov;
+#else
+ struct iovec *iov;
+#endif
+ int iovcnt;
+ __u8 vr_idx;
+ __u8 update_used;
+ __u32 out_len;
+};
Seeing iovcnt being declared as a signed integer seems strange. The
first question would be: why is it signed rather than unsigned ?
Then, looking further into
drivers/misc/mic/host/mic_virtio.c:_mic_virtio_copy()
We can see that the while() loop iterates until the local variable
iovcnt reaches the value 0 (and iovcnt is also a signed integer). If
user-space passes e.g. INT_MIN as iovcnt field, this loop then appears
to depend on an undefined behavior (signed underflow) to complete.
Wouldn't it be better to use an unsigned integers both in the
userspace API and for the local variable ?
Thanks,
Mathieu
--
Mathieu Desnoyers
EfficiOS Inc.
http://www.efficios.com
next parent reply other threads:[~2014-01-10 5:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1151498255.5788.1389332631491.JavaMail.zimbra@efficios.com>
2014-01-10 5:56 ` Mathieu Desnoyers [this message]
2014-01-10 14:21 ` Intel MIC host driver: possible signed underflow (undefined behavior) in userspace API Greg Kroah-Hartman
2014-01-10 18:22 ` Sudeep Dutt
2014-01-10 20:43 ` 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=1593870977.5807.1389333385962.JavaMail.zimbra@efficios.com \
--to=mathieu.desnoyers@efficios.com \
--cc=Caz.Yokoyama@intel.com \
--cc=ashutosh.dixit@intel.com \
--cc=dasaratharaman.chandramouli@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=harshavardhan.r.kharche@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nikhil.rao@intel.com \
--cc=peter.p.waskiewicz.jr@intel.com \
--cc=sudeep.dutt@intel.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