From: Tomas Winkler <tomas.winkler@intel.com>
To: gregkh@linuxfoundation.org
Cc: arnd@arndb.de, linux-kernel@vger.kernel.org,
Alexander Usyskin <alexander.usyskin@intel.com>,
Tomas Winkler <tomas.winkler@intel.com>
Subject: [char-misc-next 06/11] mei: fix potential read outside of array bounds
Date: Mon, 17 Feb 2014 15:13:22 +0200 [thread overview]
Message-ID: <1392642807-8878-7-git-send-email-tomas.winkler@intel.com> (raw)
In-Reply-To: <1392642807-8878-1-git-send-email-tomas.winkler@intel.com>
From: Alexander Usyskin <alexander.usyskin@intel.com>
Drop not-very-useful check and with this
fix read on index that can be after array end.
Cleanup search function as byproduct.
Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
Signed-off-by: Tomas Winkler <tomas.winkler@intel.com>
---
drivers/misc/mei/client.c | 23 ++++++++++-------------
1 file changed, 10 insertions(+), 13 deletions(-)
diff --git a/drivers/misc/mei/client.c b/drivers/misc/mei/client.c
index 6639bc3..488edd0 100644
--- a/drivers/misc/mei/client.c
+++ b/drivers/misc/mei/client.c
@@ -29,20 +29,21 @@
* mei_me_cl_by_uuid - locate index of me client
*
* @dev: mei device
+ *
+ * Locking: called under "dev->device_lock" lock
+ *
* returns me client index or -ENOENT if not found
*/
int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
{
- int i, res = -ENOENT;
+ int i;
for (i = 0; i < dev->me_clients_num; ++i)
if (uuid_le_cmp(*uuid,
- dev->me_clients[i].props.protocol_name) == 0) {
- res = i;
- break;
- }
+ dev->me_clients[i].props.protocol_name) == 0)
+ return i;
- return res;
+ return -ENOENT;
}
@@ -60,16 +61,12 @@ int mei_me_cl_by_uuid(const struct mei_device *dev, const uuid_le *uuid)
int mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
{
int i;
+
for (i = 0; i < dev->me_clients_num; i++)
if (dev->me_clients[i].client_id == client_id)
- break;
- if (WARN_ON(dev->me_clients[i].client_id != client_id))
- return -ENOENT;
+ return i;
- if (i == dev->me_clients_num)
- return -ENOENT;
-
- return i;
+ return -ENOENT;
}
--
1.8.5.3
next prev parent reply other threads:[~2014-02-17 13:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-17 13:13 [char-misc-next 00/11] mei fixes and cleanups Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 01/11 RESEND] mei: add mei_hbuf_acquire wrapper Tomas Winkler
2014-02-18 18:03 ` Greg KH
2014-02-19 9:58 ` Winkler, Tomas
2014-02-19 14:35 ` Greg KH
2014-02-19 14:34 ` Winkler, Tomas
2014-02-17 13:13 ` [char-misc-next 02/11 RESEND] mei: revamp writing slot counting Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 03/11] mei: Remove all bus devices from the mei_dev list when stopping the MEI Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 04/11] mei: hbm: revamp client connect and disconnection status Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 05/11] mei: wd and amthif use mei_cl_ api for dis/connection Tomas Winkler
2014-02-17 13:13 ` Tomas Winkler [this message]
2014-02-17 13:13 ` [char-misc-next 07/11] mei: use helper function to find me client by id Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 08/11] mei: make return values consistent across the driver Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 09/11] mei: don't of list_for_each_entry_safe when not deleting Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 10/11] mei: wd: simplify wd_send command Tomas Winkler
2014-02-17 13:13 ` [char-misc-next 11/11] mei: wd: fix stop completion failure Tomas Winkler
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=1392642807-8878-7-git-send-email-tomas.winkler@intel.com \
--to=tomas.winkler@intel.com \
--cc=alexander.usyskin@intel.com \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@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
all inboxes | Powered by JetHome®