From 8b9af07cd707b04d267142801da8090ef22fc2ee Mon Sep 17 00:00:00 2001 From: Huan Tang Date: Thu, 6 Jul 2017 16:00:57 +0800 Subject: MSDC: Denali Secruity Volnerability [Detail] Stack overflow & Null Pointer [Solution] 1.Limited the param 'count' for 'copy_from_user' 2.Check Pointer Change-Id: I81a91a64494b5f088c131f2d1ebc11fcf4b21939 Signed-off-by: Huan Tang CR-Id: ALPS03361487 Feature: Others Backported to 3.10 and a few code style ocds Signed-off-by: Mister Oyster --- drivers/misc/mediatek/mmc-host/mt6735/dbg.c | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/drivers/misc/mediatek/mmc-host/mt6735/dbg.c b/drivers/misc/mediatek/mmc-host/mt6735/dbg.c index 74e4c29cf..f1e9fe417 100644 --- a/drivers/misc/mediatek/mmc-host/mt6735/dbg.c +++ b/drivers/misc/mediatek/mmc-host/mt6735/dbg.c @@ -600,7 +600,7 @@ static int sd_multi_rw_compare_slave(int host_num, int read, uint address) mmc_wait_for_req(host_ctl->mmc, &msdc_mrq); /* compare */ if (read) { - for(forIndex=0;forIndexmmc, &msdc_mrq); /* compare */ if (read && !g_ett_tune){ - for(forIndex=0;forIndex 255) + count = 255; + ret = copy_from_user(cmd_buf, buf, count); if (ret < 0)return -1; @@ -3193,10 +3198,11 @@ static ssize_t msdc_debug_proc_write_DVT(struct file *file, const char __user* b host = mtk_msdc_host[i_msdc_id]; - pr_err("[****SD_Debug****] Start Online Tuning DVT test \n"); - mt_msdc_online_tuning_test(host, 0, 0, 0); - pr_err("[****SD_Debug****] Finish Online Tuning DVT test \n"); - + if (host) { + pr_err("[****SD_Debug****] Start Online Tuning DVT test \n"); + mt_msdc_online_tuning_test(host, 0, 0, 0); + pr_err("[****SD_Debug****] Finish Online Tuning DVT test \n"); + } return count; } #endif // ONLINE_TUNING_DVTTEST @@ -3380,6 +3386,11 @@ static ssize_t msdc_voltage_proc_write(struct file *file, const char __user* buf { int ret; + if (count == 0) + return -1; + if (count > 255) + count = 255; + ret = copy_from_user(cmd_buf, buf, count); if (ret < 0)return -1; -- cgit v1.2.3