summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2019-02-18 23:49:11 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2019-02-18 23:49:11 -0800
commit738661eb869c2873cfd595c5e68f5c0f554167e2 (patch)
tree634c982ac31841c01e2e7996d8d7e21882ed1550
parente55e5ccea92b49a6a149897850cb8e5a6e687024 (diff)
parentf9a9be747652f0696cf1e066b7fda89046083a44 (diff)
Merge "msm: ipa3: Fix to validate the buffer size"
-rw-r--r--drivers/platform/msm/ipa/ipa_v3/ipa_intf.c19
1 files changed, 16 insertions, 3 deletions
diff --git a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
index 456cf6c9fd60..579689c76f2e 100644
--- a/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
+++ b/drivers/platform/msm/ipa/ipa_v3/ipa_intf.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013-2018, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2013-2019, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
@@ -742,6 +742,12 @@ ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
if (msg) {
locked = 0;
mutex_unlock(&ipa3_ctx->msg_lock);
+ if (count < sizeof(struct ipa_msg_meta)) {
+ kfree(msg);
+ msg = NULL;
+ ret = -EFAULT;
+ break;
+ }
if (copy_to_user(buf, &msg->meta,
sizeof(struct ipa_msg_meta))) {
ret = -EFAULT;
@@ -752,8 +758,15 @@ ssize_t ipa3_read(struct file *filp, char __user *buf, size_t count,
buf += sizeof(struct ipa_msg_meta);
count -= sizeof(struct ipa_msg_meta);
if (msg->buff) {
- if (copy_to_user(buf, msg->buff,
- msg->meta.msg_len)) {
+ if (count >= msg->meta.msg_len) {
+ if (copy_to_user(buf, msg->buff,
+ msg->meta.msg_len)) {
+ ret = -EFAULT;
+ kfree(msg);
+ msg = NULL;
+ break;
+ }
+ } else {
ret = -EFAULT;
kfree(msg);
msg = NULL;