Merge "msm: ipa: Fix to validate the buffer size"
This commit is contained in:
commit
d6d1fb066f
1 changed files with 17 additions and 4 deletions
|
@ -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
|
* 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
|
* it under the terms of the GNU General Public License version 2 and
|
||||||
|
@ -735,8 +735,14 @@ ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
|
||||||
IPADBG("msg=%pK\n", msg);
|
IPADBG("msg=%pK\n", msg);
|
||||||
locked = 0;
|
locked = 0;
|
||||||
mutex_unlock(&ipa_ctx->msg_lock);
|
mutex_unlock(&ipa_ctx->msg_lock);
|
||||||
|
if (count < sizeof(struct ipa_msg_meta)) {
|
||||||
|
kfree(msg);
|
||||||
|
msg = NULL;
|
||||||
|
ret = -EFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
if (copy_to_user(buf, &msg->meta,
|
if (copy_to_user(buf, &msg->meta,
|
||||||
sizeof(struct ipa_msg_meta))) {
|
sizeof(struct ipa_msg_meta))) {
|
||||||
kfree(msg);
|
kfree(msg);
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
|
@ -745,8 +751,15 @@ ssize_t ipa_read(struct file *filp, char __user *buf, size_t count,
|
||||||
buf += sizeof(struct ipa_msg_meta);
|
buf += sizeof(struct ipa_msg_meta);
|
||||||
count -= sizeof(struct ipa_msg_meta);
|
count -= sizeof(struct ipa_msg_meta);
|
||||||
if (msg->buff) {
|
if (msg->buff) {
|
||||||
if (copy_to_user(buf, msg->buff,
|
if (count >= msg->meta.msg_len) {
|
||||||
msg->meta.msg_len)) {
|
if (copy_to_user(buf, msg->buff,
|
||||||
|
msg->meta.msg_len)) {
|
||||||
|
kfree(msg);
|
||||||
|
msg = NULL;
|
||||||
|
ret = -EFAULT;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
kfree(msg);
|
kfree(msg);
|
||||||
msg = NULL;
|
msg = NULL;
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
|
|
Loading…
Add table
Reference in a new issue