Received: by 10.223.185.116 with SMTP id b49csp1136764wrg; Fri, 23 Feb 2018 12:34:58 -0800 (PST) X-Google-Smtp-Source: AH8x224e0r3xHdmfbypxwyBsiPD+YDOt8BzuAQyrUtRUxk/6fWzX+njPMLV9T4eUnL+BGFmONS7z X-Received: by 10.98.155.93 with SMTP id r90mr2953835pfd.132.1519418098731; Fri, 23 Feb 2018 12:34:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418098; cv=none; d=google.com; s=arc-20160816; b=f4fLZeYBjk13wXAtV+zzzxzK1ufU6tbKP7yRCcNm/zqk70gJkeLrtmA/l0wcuU4hwn pxnrODJdiWcX5+0aryMqq98D9sUbCnWNaMAf4QdmMw+2x+MWdJ0ce6ce4MPayOZy9Ktv yDVHPy/85nBXsGdSuB1KJR5YZgAltIunBK50sx08L5ky6Wk/WA5ggHAJD4ZWqYsTnRKe U0nHG1lK+6aAk2HEw3SMiO40Tj4Cm4++mq0XxYqvq/5mDG2oMJrb4Zgl0Lz9uTL2GPla e++MYHQ2UUllKZ80tBLKE237gbZEIXObGm1D2De9ZsboqR19oUi7pINEPqqxwhTy+zLG KVOA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=N8lZ3/HyiyzpHfRB6dWQwESiCi0jWkhOmeamYDw40VU=; b=MX+Btat8FbNG9SvSQS9Oy4saCZmJK5ecorTCJue4sVK1BrTLa8RExkGOBDT+/l8W9t QADj6EWMa16qz1c7g9dwL3YNfUdlfa5sq6m2XxgwK3SXLbGK5DE6+zSBvcKqaK+QO/HE 1267QzxYMVGM3sI3jslsCIrrPe6fGr6PVoHHRfQcFG7Wxx9cHWnhHaIzihZRdyKq0Tcd OO06CXOhmzwkYIqiRtDv1o84TR0p0OzHZl/GysmQ7doKYo9ICRMf1jo788Gd5O3YYGKi tO5YnLb8Cru4eP4fs/8R9cXpPVH0A8FHsKUr04AVf241n5s16F3NqBKCIOz4DelyDEta rdXQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k14si1925850pgp.812.2018.02.23.12.34.44; Fri, 23 Feb 2018 12:34:58 -0800 (PST) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753854AbeBWSfe (ORCPT + 99 others); Fri, 23 Feb 2018 13:35:34 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:37322 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753838AbeBWSfc (ORCPT ); Fri, 23 Feb 2018 13:35:32 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 4CD9F12A9; Fri, 23 Feb 2018 18:35:31 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Ladi Prosek , "Michael S. Tsirkin" Subject: [PATCH 4.4 062/193] virtio_balloon: prevent uninitialized variable use Date: Fri, 23 Feb 2018 19:24:55 +0100 Message-Id: <20180223170335.670790147@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit f0bb2d50dfcc519f06f901aac88502be6ff1df2c upstream. 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: Greg Kroah-Hartman --- drivers/virtio/virtio_balloon.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/virtio/virtio_balloon.c +++ b/drivers/virtio/virtio_balloon.c @@ -239,12 +239,14 @@ static void update_balloon_stats(struct 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,