From patchwork Thu Mar 1 15:27:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasha Levin X-Patchwork-Id: 130268 Delivered-To: patch@linaro.org Received: by 10.80.172.228 with SMTP id x91csp2951550edc; Thu, 1 Mar 2018 07:37:47 -0800 (PST) X-Google-Smtp-Source: AG47ELt0GUI6NyODJ9U5itDsSdzLxdPQZODQC+eqHEHYqPgB69pP9c6fqwKN47178HB7X/UldnG0 X-Received: by 10.101.66.76 with SMTP id d12mr1870299pgq.234.1519918666980; Thu, 01 Mar 2018 07:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519918666; cv=none; d=google.com; s=arc-20160816; b=IsfWBy4bmZgaRgXvUpum9xrMRkIvWyOIO4ZRLUlbBV9ihuWSj/yJ8KhF4Q7B78qfD9 h1xo1E50EqUEBJ+9XHoAa7Ujsx9P7eHtjp1wpAJay7y8z8m1y0vZRkefrWY8VNsAM6iz Jj/9dubrrvqoNBPdBhBqnkx7C02+w6saMIienCE2lcY3V83Aedhy0QPrevNq6s2/2SVv gRxPRM/JbgOrE83QSB8xTEtZdod+73nlFu5RUmWKlz1E6IizqHK2emNu+kZzikC8/PiJ LAWYQTORpgnJn6HM710N5RbFByr8aljnqeDaAPkvV42a2kgg67Gu5hDaY0A9le8ThRtD hUNg== 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=ybPppmjsjtcI78iptgaYnt5AJVWgDJGM1PNiMxrnTkQ=; b=cOpyIrNNuhTWWtejeWQrXJj0oybIhW/epmoRAjfyKdjpXxGn3/CqZWpLv8TWu1v8Mv cCKQUgdpolvRvlb0WuwKFvaAoL3+qMD4zdQ2zuOZSFWYtH9nAGTpBOKZ1JNNflHZZfDL WdNLVmSE5pf6bRue4dqRXFr7wtJwpxh7eJcDVJlCKfxMcRSpSL3wX5TzVOsrN7r8eZ/p 878I9lan483N25WrqVbkIeCx76etmALfsxirDO3cBwUQNPU8aLDXnK1j9kUbYpZPAhqc 8Q+AiJEC3O2ddYRrP0YbjJ0POd9QPChb0QwkiwHqRC3rPgFhNu0hneGiffYZluCu1Eq9 KptA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=SjwSL4lf; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 g10-v6si2863008plk.730.2018.03.01.07.37.46; Thu, 01 Mar 2018 07:37:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of stable-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=SjwSL4lf; spf=pass (google.com: best guess record for domain of stable-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=stable-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 S1032512AbeCAPhn (ORCPT + 10 others); Thu, 1 Mar 2018 10:37:43 -0500 Received: from mail-by2nam03on0132.outbound.protection.outlook.com ([104.47.42.132]:24496 "EHLO NAM03-BY2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1032515AbeCAPhj (ORCPT ); Thu, 1 Mar 2018 10:37:39 -0500 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=ybPppmjsjtcI78iptgaYnt5AJVWgDJGM1PNiMxrnTkQ=; b=SjwSL4lfAJ7GDxuGPOJGQHTxFd689OpU+rSjsygAqgnTm/UO302r3fNTBy8Ga/do74pvNknHxBiRyz1QVTMjjeKO9k0mZHTvg+l1cbsNIVup9YEBW8hM/7C8iQRDfuyscRnLLnwA84BjvnD15O186LdhqnYebRfwSKDek6y/xWI= Received: from DM5PR2101MB1032.namprd21.prod.outlook.com (52.132.128.13) by DM5PR2101MB1014.namprd21.prod.outlook.com (52.132.133.36) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.3; Thu, 1 Mar 2018 15:37:37 +0000 Received: from DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446]) by DM5PR2101MB1032.namprd21.prod.outlook.com ([fe80::8063:c68a:b210:7446%2]) with mapi id 15.20.0567.006; Thu, 1 Mar 2018 15:37:37 +0000 From: Sasha Levin To: "stable@vger.kernel.org" , "stable-commits@vger.kernel.org" CC: Arnd Bergmann , Ladi Prosek , "Michael S . Tsirkin" , Sasha Levin Subject: [added to the 4.1 stable tree] virtio_balloon: prevent uninitialized variable use Thread-Topic: [added to the 4.1 stable tree] virtio_balloon: prevent uninitialized variable use Thread-Index: AQHTsXHAjPhawKiiy0ue5AtBKk5E2Q== Date: Thu, 1 Mar 2018 15:27:04 +0000 Message-ID: <20180301152116.1486-427-alexander.levin@microsoft.com> References: <20180301152116.1486-1-alexander.levin@microsoft.com> In-Reply-To: <20180301152116.1486-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; DM5PR2101MB1014; 7:JGslME8JGgonNtTYjGWYIyjLWxn041Almcqbgaf3cCsqCBynqLV37z5O45G+GDOYRDZXUN7VZ/4lZqcCRUO2WKyNoTzfwUN8xkfNKQg6mro931Qb8sHj523lGxfSewkgY1G66tqVA2VRL7BQwMQTqRPgG2dJM4tnKwBZ5gBTY49xTKsfDcdqCeLch3LpUP/+MBqQoNyej1SlMGgCCZ2Oe2108jVjgr18JgLyKYcPUXLpDaJGMn2tNGdKtEFIXG+a x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 1a62b047-76a5-4b64-4a9d-08d57f8a5c36 x-microsoft-antispam: UriScan:; BCL:0; PCL:0; RULEID:(7020095)(4652020)(4534165)(4627221)(201703031133081)(201702281549075)(48565401081)(5600026)(4604075)(3008032)(2017052603307)(7193020); SRVR:DM5PR2101MB1014; x-ms-traffictypediagnostic: DM5PR2101MB1014: x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(20558992708506)(89211679590171)(211171220733660); x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(3231220)(944501228)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(20161123560045)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:DM5PR2101MB1014; BCL:0; PCL:0; RULEID:; SRVR:DM5PR2101MB1014; x-forefront-prvs: 05986C03E0 x-forefront-antispam-report: SFV:NSPM; SFS:(10019020)(366004)(39380400002)(346002)(39860400002)(376002)(396003)(199004)(189003)(53936002)(2906002)(3280700002)(6436002)(6486002)(3846002)(6512007)(2900100001)(6116002)(2950100002)(107886003)(6666003)(72206003)(5660300001)(36756003)(10090500001)(3660700001)(14454004)(7736002)(305945005)(97736004)(1076002)(22452003)(26005)(6506007)(105586002)(86362001)(575784001)(59450400001)(478600001)(68736007)(102836004)(4326008)(6346003)(54906003)(110136005)(81156014)(81166006)(86612001)(8936002)(186003)(10290500003)(8676002)(76176011)(316002)(2501003)(66066001)(25786009)(5250100002)(106356001)(99286004)(22906009); DIR:OUT; SFP:1102; SCL:1; SRVR:DM5PR2101MB1014; H:DM5PR2101MB1032.namprd21.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-message-info: vhJ9s2UdjVt4I882RFzywIEV67EnNRKh7a1GUMaGzipoTvih9nnvK+ouoJ/uZDhthimmy9B81phg1/E2nVFbVUDmOl2raNxRRlkH12SjcLa9hg7u8BZbRBQDILiPG87TSuFcIGce0/+c7zwS9B2TTtcAzA1vDL6fbL2E0f9xNf0= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a62b047-76a5-4b64-4a9d-08d57f8a5c36 X-MS-Exchange-CrossTenant-originalarrivaltime: 01 Mar 2018 15:27:04.2659 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR2101MB1014 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Arnd Bergmann This patch has been added to the 4.1 stable tree. If you have any objections, please let us know. -- 2.14.1 =============== [ Upstream commit f0bb2d50dfcc519f06f901aac88502be6ff1df2c ] The latest gcc-7.0.1 snapshot reports a new warning: virtio/virtio_balloon.c: In function 'update_balloon_stats': virtio/virtio_balloon.c:258:26: error: 'events[2]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:260:26: error: 'events[3]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:261:56: error: 'events[18]' is used uninitialized in this function [-Werror=uninitialized] virtio/virtio_balloon.c:262:56: error: 'events[17]' is used uninitialized in this function [-Werror=uninitialized] This seems absolutely right, so we should add an extra check to prevent copying uninitialized stack data into the statistics. >From all I can tell, this has been broken since the statistics code was originally added in 2.6.34. Fixes: 9564e138b1f6 ("virtio: Add memory statistics reporting to the balloon driver (V4)") Signed-off-by: Arnd Bergmann Signed-off-by: Ladi Prosek Signed-off-by: Michael S. Tsirkin Signed-off-by: Sasha Levin --- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/virtio/virtio_balloon.c b/drivers/virtio/virtio_balloon.c index 01d15dca940e..7cf26768ea0b 100644 --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -239,12 +239,14 @@ static void update_balloon_stats(struct virtio_balloon *vb) all_vm_events(events); si_meminfo(&i); +#ifdef CONFIG_VM_EVENT_COUNTERS update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_IN, pages_to_bytes(events[PSWPIN])); update_stat(vb, idx++, VIRTIO_BALLOON_S_SWAP_OUT, pages_to_bytes(events[PSWPOUT])); update_stat(vb, idx++, VIRTIO_BALLOON_S_MAJFLT, events[PGMAJFAULT]); update_stat(vb, idx++, VIRTIO_BALLOON_S_MINFLT, events[PGFAULT]); +#endif update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMFREE, pages_to_bytes(i.freeram)); update_stat(vb, idx++, VIRTIO_BALLOON_S_MEMTOT,