aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
diff options
context:
space:
mode:
authorJohannes Berg <johannes.berg@intel.com>2017-04-19 03:58:50 -0400
committerLuca Coelho <luciano.coelho@intel.com>2017-06-22 17:13:00 -0400
commit40e86a3619a1e84ad73c716c943f65fc38eb1e28 (patch)
tree9aac2e91f4cd3c325bddf31db5fb01ec011fb384 /drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
parenta9c50726ce3279646e2e22314b0917455a3c5e86 (diff)
iwlwifi: mvm: use scnprintf() instead of snprintf()
It's safer to use scnprintf() here because the buffer might be too short for the full format strings. In most cases this isn't true because of external limits on the values. In one case, this fixes a stack data leak. Signed-off-by: Johannes Berg <johannes.berg@intel.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c22
1 files changed, 12 insertions, 10 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
index 5d475b4850ae..a7ac281e5cde 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/debugfs-vif.c
@@ -7,7 +7,7 @@
7 * 7 *
8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 8 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 9 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
10 * Copyright(c) 2016 Intel Deutschland GmbH 10 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
11 * 11 *
12 * This program is free software; you can redistribute it and/or modify 12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of version 2 of the GNU General Public License as 13 * it under the terms of version 2 of the GNU General Public License as
@@ -34,7 +34,7 @@
34 * 34 *
35 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. 35 * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved.
36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH 36 * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH
37 * Copyright(c) 2016 Intel Deutschland GmbH 37 * Copyright(c) 2016 - 2017 Intel Deutschland GmbH
38 * All rights reserved. 38 * All rights reserved.
39 * 39 *
40 * Redistribution and use in source and binary forms, with or without 40 * Redistribution and use in source and binary forms, with or without
@@ -1304,11 +1304,11 @@ static ssize_t iwl_dbgfs_low_latency_read(struct file *file,
1304 char buf[30] = {}; 1304 char buf[30] = {};
1305 int len; 1305 int len;
1306 1306
1307 len = snprintf(buf, sizeof(buf) - 1, 1307 len = scnprintf(buf, sizeof(buf) - 1,
1308 "traffic=%d\ndbgfs=%d\nvcmd=%d\n", 1308 "traffic=%d\ndbgfs=%d\nvcmd=%d\n",
1309 mvmvif->low_latency_traffic, 1309 mvmvif->low_latency_traffic,
1310 mvmvif->low_latency_dbgfs, 1310 mvmvif->low_latency_dbgfs,
1311 mvmvif->low_latency_vcmd); 1311 mvmvif->low_latency_vcmd);
1312 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1312 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1313} 1313}
1314 1314
@@ -1385,10 +1385,12 @@ static ssize_t iwl_dbgfs_rx_phyinfo_read(struct file *file,
1385 struct ieee80211_vif *vif = file->private_data; 1385 struct ieee80211_vif *vif = file->private_data;
1386 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 1386 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
1387 char buf[8]; 1387 char buf[8];
1388 int len;
1388 1389
1389 snprintf(buf, sizeof(buf), "0x%04x\n", mvmvif->mvm->dbgfs_rx_phyinfo); 1390 len = scnprintf(buf, sizeof(buf), "0x%04x\n",
1391 mvmvif->mvm->dbgfs_rx_phyinfo);
1390 1392
1391 return simple_read_from_buffer(user_buf, count, ppos, buf, sizeof(buf)); 1393 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1392} 1394}
1393 1395
1394static void iwl_dbgfs_quota_check(void *data, u8 *mac, 1396static void iwl_dbgfs_quota_check(void *data, u8 *mac,
@@ -1439,7 +1441,7 @@ static ssize_t iwl_dbgfs_quota_min_read(struct file *file,
1439 char buf[10]; 1441 char buf[10];
1440 int len; 1442 int len;
1441 1443
1442 len = snprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min); 1444 len = scnprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min);
1443 1445
1444 return simple_read_from_buffer(user_buf, count, ppos, buf, len); 1446 return simple_read_from_buffer(user_buf, count, ppos, buf, len);
1445} 1447}