Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2614714ybi; Mon, 17 Jun 2019 07:45:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkkzXvjNddrO4vqlphwX6NFbBwaTalaFXYJO2aZDdurkvWfZp0x58vx9dIhCA1HZu0kPh5 X-Received: by 2002:a63:5a4b:: with SMTP id k11mr21983691pgm.143.1560782729764; Mon, 17 Jun 2019 07:45:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560782729; cv=none; d=google.com; s=arc-20160816; b=rsaZK8uGmTxTOQrwhX1Gbw/B6MVbRW9q6WPNujYTfy4SqIv1+Eu4yF7K7vTbZI9jF/ 9b2cEOKKuAe85IMrSHII/heNkdObtkyU9KL57+cPI7YcPykr1VOobgoKHWlm7wj7ZWMu qV9htHpAta+/+JmiPpBUBua2QnY+YTd7fYSVuTQo+bQVqIYhwdHMgky7qoXqL1pB0Gph P37vT7R6rW/+vLBAPhei3PUzoi/16138EmMxPS2K5vrcB7qVb83rhSDQWP86MgIJgH6p juu2c+fIEuplHKywlyYpihTX4m1/iDHRITjI87zFUxNHgOqDzr1eKCKNPNoto13etnXM cwuA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version; bh=1ZuDMi3lli8OO05kFY206yEp9wlXM0BbyA8+D2np9Sw=; b=zfT6xvs4TGKy1ZEYXDnMmGjmRC8R0YCy/Wp4BSSWsxawTZ+haq+lV1YCHNTjqUKIw6 tyk2sE5jWJI+oKgBe50x2Ig0nuykHv8D4N9sZeUv/tq3xnPhyRi2XvEmci0/mceV1Slq MtOH2KjA9Yx1Cd+PxyyZpU6+S/y8olkaVWnwHEYN4HkVI80mDsQ6Uk0hvBTdBdMTXuKv UM/EJ9CaUdF1ccybQqHgItPP6WZKQ9Z1WbemPp06v8eNgl/JkDLly8Ywo4IQK+dzqjC9 txXHQw7WRxRjFHv0mTWMvzDuQyL4jlnDIMTjHRMmCjyFfCCfJccZ94uj4pxfSYRVHzhF SKgQ== 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 p16si11144297pgd.370.2019.06.17.07.45.14; Mon, 17 Jun 2019 07:45:29 -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; 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 S1728365AbfFQOpH (ORCPT + 99 others); Mon, 17 Jun 2019 10:45:07 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:45203 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726151AbfFQOpH (ORCPT ); Mon, 17 Jun 2019 10:45:07 -0400 Received: by mail-qt1-f194.google.com with SMTP id j19so10943325qtr.12 for ; Mon, 17 Jun 2019 07:45:06 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1ZuDMi3lli8OO05kFY206yEp9wlXM0BbyA8+D2np9Sw=; b=c2dDsSljvRvu1LWNQzX3FwHsKsagO9LB70uV9oWbWjk0RwNErgVgyELx0v2BZO07on ugbJtGMfuP/BKFgr67KuLhrvOtY4Dl+UfnV3UKDh7T8VHb5zMCyYdP981O2XhqHnL8Qr FCOJlVP0qUuuyTFc8tU5tqUFNNnb3NcpVndHgLcrlSbH/wZSTeDlJqyK7HEWwIfaY0Gt rmzAM47YiHN22q8ybluwLG4a8XSGvs/jT0qZkxQlsoBHIu6b7wRhE8kjvlRWFdSmuaNV JskjecPSSWgQlbzUss2bQ2/3MyfeRqpEvWJ99njuDW3Bhh2QJsztlS8S5Dz43jUb4Nbz IQUQ== X-Gm-Message-State: APjAAAWgnQ9xQjHzMH9m3DO4/ZqESJ59Hbjl5LROwP/yL8+H84drYyN1 TfnQKI2mPBHjBIn5mbKQo518LZdVlN7TDk7arWo= X-Received: by 2002:ac8:3485:: with SMTP id w5mr17348190qtb.142.1560782706039; Mon, 17 Jun 2019 07:45:06 -0700 (PDT) MIME-Version: 1.0 References: <20190617121427.77565-1-arnd@arndb.de> <20190617141244.5x22nrylw7hodafp@pc636> In-Reply-To: <20190617141244.5x22nrylw7hodafp@pc636> From: Arnd Bergmann Date: Mon, 17 Jun 2019 16:44:49 +0200 Message-ID: Subject: Re: [BUG]: mm/vmalloc: uninitialized variable access in pcpu_get_vm_areas To: Uladzislau Rezki Cc: Roman Gushchin , Michal Hocko , Matthew Wilcox , Thomas Garnier , Oleksiy Avramchenko , Steven Rostedt , Joel Fernandes , Thomas Gleixner , Ingo Molnar , Tejun Heo , Andrew Morton , Linus Torvalds , Stephen Rothwell , Roman Penyaev , Rick Edgecombe , Andrey Ryabinin , Mike Rapoport , Linux-MM , Linux Kernel Mailing List 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 On Mon, Jun 17, 2019 at 4:12 PM Uladzislau Rezki wrote: > > On Mon, Jun 17, 2019 at 02:14:11PM +0200, Arnd Bergmann wrote: > > gcc points out some obviously broken code in linux-next > > > > mm/vmalloc.c: In function 'pcpu_get_vm_areas': > > mm/vmalloc.c:991:4: error: 'lva' may be used uninitialized in this function [-Werror=maybe-uninitialized] > > insert_vmap_area_augment(lva, &va->rb_node, > > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > &free_vmap_area_root, &free_vmap_area_list); > > ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > mm/vmalloc.c:916:20: note: 'lva' was declared here > > struct vmap_area *lva; > > ^~~ > > > > Remove the obviously broken code. This is almost certainly > > not the correct solution, but it's what I have applied locally > > to get a clean build again. > > > > Please fix this properly. > > > > > Please do not apply this. It will just break everything. As I wrote in my description, this was purely meant as a bug report, not a patch to be applied. > As Roman pointed we can just set lva = NULL; in the beginning to make GCC happy. > For some reason GCC decides that it can be used uninitialized, but that > is not true. I got confused by the similarly named FL_FIT_TYPE/NE_FIT_TYPE constants and misread this as only getting run in the case where it is not initialized, but you are right that it always is initialized here. I see now that the actual cause of the warning is the 'while' loop in augment_tree_propagate_from(). gcc is unable to keep track of the state of the 'lva' variable beyond that and prints a bogus warning. Arnd