Received: by 10.213.65.68 with SMTP id h4csp2115674imn; Sun, 8 Apr 2018 20:06:23 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/7fJ7myvvOGQc35Us/e0zeY93vUNkgbyBP/14bSh5De9sq7FDE+7C/ortqR1vh7EPbqsh2 X-Received: by 2002:a17:902:76cb:: with SMTP id j11-v6mr35131209plt.117.1523243183073; Sun, 08 Apr 2018 20:06:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523243183; cv=none; d=google.com; s=arc-20160816; b=i7Zoc8wo8EK/oUyQazmq6/D0yVo8zt4ST3Hftl+UMZDa/nRNm/vRUsz+iCWMTVXxgn QlULtjxhZuX9pw5/hZDZXjBw0MuPzT++DWzjA7manHhAo0PnX15I3hP+4z2C1Y6lyGvj kJ28r5d5RoBFgyEFnXYpARHTpm/BeTEcVUg4D/Fc0U6AWdfmrqWZI/AXZGjp5FWNV1TJ D3J1X2usoYfbhbt9V7rdlr/tto0+4ukHLMtC22grnWrL3n+dwFYbXeI+izMG8NFQz3jH R/JDXF8Xt6LAUf/j/Egr3yc28TxfSnZ3x6QtODoy2EDSEFcnyLD0go6N3h2wetL4nOT7 bjYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=1rH3Wc0pSiYgTHt0x/HXx8FgTDUouPd/LnQiICTau0w=; b=DmDKpEw2oFsojBrzyOrBECRHjuVm+5X45nJhSL5/2dkMiAvjRZ5xiTy9TX8pnlBvGA PPbSIGnBSk1LGm++sU+FClo8MK/AwcoUj5Eb/7RZv+aeYhzxALLyFuQihcnYIDLLoBWv kWYyznZ2PpvwxWa7gas4+x9NRKjqxVuZCdOL5FFHBJGUh+OqQM/akYBSCbk8rgCRCaSe OolB037a6FG+sGiOjmfgTCwX338YIM5b7gN7cGqIQDQDEovlBFLQ4uZMlckL5nUK+mMu xNfmxS7ItzcV/kQxqsi4Et99fcb9zF4hE5okhlxzxYK4iuaY26zoPN5dG7S1Ovs8TwYU kD5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nXRllAY4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u12si1552638pgr.128.2018.04.08.20.05.46; Sun, 08 Apr 2018 20:06:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=nXRllAY4; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756086AbeDIAa2 (ORCPT + 99 others); Sun, 8 Apr 2018 20:30:28 -0400 Received: from mail-sn1nam02on0125.outbound.protection.outlook.com ([104.47.36.125]:10314 "EHLO NAM02-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755787AbeDIAaX (ORCPT ); Sun, 8 Apr 2018 20:30:23 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1rH3Wc0pSiYgTHt0x/HXx8FgTDUouPd/LnQiICTau0w=; b=nXRllAY4sEF3RC0a0K8N6A4uNQd/7KV4sXw0/yYSZPg5On/2tcH3xBCPJunucHeJh21jhZliITTZi3nlCGlyVXyCqkpas2zSOS9fWuCQ+ywp5ef/IKcvmFTFbTICmha5aKEvk++tKJlOx93oNxixXUSec7DQjVv4tBgphWlVEKE= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.696.0; Mon, 9 Apr 2018 00:30:17 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8109:aef0:a777:7059%2]) with mapi id 15.20.0696.003; Mon, 9 Apr 2018 00:30:17 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "linux-kernel@vger.kernel.org" CC: Johannes Berg , Luca Coelho , Sasha Levin Subject: [PATCH AUTOSEL for 4.9 128/293] iwlwifi: mvm: use scnprintf() instead of snprintf() Thread-Topic: [PATCH AUTOSEL for 4.9 128/293] iwlwifi: mvm: use scnprintf() instead of snprintf() Thread-Index: AQHTz5khK5hisPfu3kWAON7W+yozxA== Date: Mon, 9 Apr 2018 00:24:32 +0000 Message-ID: <20180409002239.163177-128-alexander.levin@microsoft.com> References: <20180409002239.163177-1-alexander.levin@microsoft.com> In-Reply-To: <20180409002239.163177-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;DM5PR2101MB1032;7:gRtg4kSi0rH/Q28vBOw2KMk1mkjVp9i/B+NtkjzrcysFnJFBn9bsovgL0AiPnnOYYbYClp4HqSFa6TKz7Ac+GjBknr86/pbaFo5+5Tpq62v99bRadmU4Z5ishaNqXQDw2n351dVF19LScNQUcpX9qg7Ue5NFZRQxCz7VD/A4f6GK+pNNZ2PL/ECmAYUjiZcjhtiTG/yNNOTb5jLTvNDMfVov+ChWq2w5RmvUcvuBis9O0bfIGCukLETQ65q1GHOa;20:6n2T4v7JcCEc7coXJcugXBaNIdNFKqCUm8r0srK9aDdQsB/j5IydPB0Y9GgThxYS/CXHU0ili7v3HHpvFD0RkJ8VIxff9fPcj0sXNzKoe5MCe+gb3Y07d4XlAy5KrzIjRswRLaZW+/xpyGtImXis8pFxC7LxjL7bv70zXd5KZI8= x-ms-office365-filtering-ht: Tenant X-MS-Office365-Filtering-Correlation-Id: acb0b6d7-b1ad-43d1-08e7-08d59db111f7 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603328)(7193020);SRVR:DM5PR2101MB1032; x-ms-traffictypediagnostic: DM5PR2101MB1032: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(228905959029699); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040522)(2401047)(8121501046)(5005006)(3002001)(3231221)(944501327)(52105095)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123562045)(20161123558120)(6072148)(201708071742011);SRVR:DM5PR2101MB1032;BCL:0;PCL:0;RULEID:;SRVR:DM5PR2101MB1032; x-forefront-prvs: 0637FCE711 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(39380400002)(346002)(396003)(39860400002)(376002)(366004)(189003)(199004)(5660300001)(76176011)(99286004)(10090500001)(2900100001)(105586002)(305945005)(7736002)(107886003)(2501003)(5250100002)(14454004)(53936002)(4326008)(8936002)(68736007)(25786009)(86612001)(3846002)(66066001)(1076002)(486006)(316002)(72206003)(22452003)(106356001)(186003)(97736004)(6436002)(6116002)(476003)(2616005)(478600001)(6486002)(10290500003)(2906002)(110136005)(54906003)(6512007)(81156014)(81166006)(8676002)(36756003)(11346002)(3660700001)(446003)(6666003)(86362001)(26005)(102836004)(3280700002)(6506007)(59450400001)(22906009)(2004002)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:DM5PR2101MB1032;H:DM5PR2101MB1032.namprd21.prod.outlook.com;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: WuwftFS0lJqxkOfFzbQdvS45F+LT0aa6P35vgv//3Kl3sGZGMHXWws9eNCMwIRzr8OD/c8c1BTlaTwDekzyFMFPQCJYm1xHkZ4luobsRLSc64ladRzCJrRl01NC/JBl6YSmSg2a1VIUp/5OBoTPTHENZFHFQtC/R7dpmfLA0iYrxQ1YlDUVsWflJcNQb8XblRgQ7KuxIMAipKeZzh+qXRQUJJcH3Jp2I8MWUJwDZHlm0rqo3PSWkAgy7dygGgtvu8KcqzNWww7UrrDE8DTNgFypZc998rcEelhnrgbFn4WM/BB7ae8vJc/SgLxikcRvkoIks5GU0cmHBnW6Vg+c9pEy6GlWzZTTUcA8A4ruQDpDKOH+u/K1sksOGGz9y6L/dvbWIHYXz3jSTFaXb1pVe++m6EvyFna74aUYepHLU3RY= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: acb0b6d7-b1ad-43d1-08e7-08d59db111f7 X-MS-Exchange-CrossTenant-originalarrivaltime: 09 Apr 2018 00:24:32.8000 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1032 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 40e86a3619a1e84ad73c716c943f65fc38eb1e28 ] 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 Signed-off-by: Luca Coelho Signed-off-by: Sasha Levin --- .../net/wireless/intel/iwlwifi/mvm/debugfs-vif.c | 22 ++++++++++++------= ---- 1 file 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 f4d75ffe3d8a..41a105116d14 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 @@ * * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH - * Copyright(c) 2016 Intel Deutschland GmbH + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH * * This program is free software; you can redistribute it and/or modify * it under the terms of version 2 of the GNU General Public License as @@ -34,7 +34,7 @@ * * Copyright(c) 2012 - 2014 Intel Corporation. All rights reserved. * Copyright(c) 2013 - 2015 Intel Mobile Communications GmbH - * Copyright(c) 2016 Intel Deutschland GmbH + * Copyright(c) 2016 - 2017 Intel Deutschland GmbH * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -1304,11 +1304,11 @@ static ssize_t iwl_dbgfs_low_latency_read(struct fi= le *file, char buf[30] =3D {}; int len; =20 - len =3D snprintf(buf, sizeof(buf) - 1, - "traffic=3D%d\ndbgfs=3D%d\nvcmd=3D%d\n", - mvmvif->low_latency_traffic, - mvmvif->low_latency_dbgfs, - mvmvif->low_latency_vcmd); + len =3D scnprintf(buf, sizeof(buf) - 1, + "traffic=3D%d\ndbgfs=3D%d\nvcmd=3D%d\n", + mvmvif->low_latency_traffic, + mvmvif->low_latency_dbgfs, + mvmvif->low_latency_vcmd); return simple_read_from_buffer(user_buf, count, ppos, buf, len); } =20 @@ -1385,10 +1385,12 @@ static ssize_t iwl_dbgfs_rx_phyinfo_read(struct fil= e *file, struct ieee80211_vif *vif =3D file->private_data; struct iwl_mvm_vif *mvmvif =3D iwl_mvm_vif_from_mac80211(vif); char buf[8]; + int len; =20 - snprintf(buf, sizeof(buf), "0x%04x\n", mvmvif->mvm->dbgfs_rx_phyinfo); + len =3D scnprintf(buf, sizeof(buf), "0x%04x\n", + mvmvif->mvm->dbgfs_rx_phyinfo); =20 - return simple_read_from_buffer(user_buf, count, ppos, buf, sizeof(buf)); + return simple_read_from_buffer(user_buf, count, ppos, buf, len); } =20 static void iwl_dbgfs_quota_check(void *data, u8 *mac, @@ -1439,7 +1441,7 @@ static ssize_t iwl_dbgfs_quota_min_read(struct file *= file, char buf[10]; int len; =20 - len =3D snprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min); + len =3D scnprintf(buf, sizeof(buf), "%d\n", mvmvif->dbgfs_quota_min); =20 return simple_read_from_buffer(user_buf, count, ppos, buf, len); } --=20 2.15.1