From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.6 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 38B54C433DF for ; Mon, 22 Jun 2020 17:27:42 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E80AC2073E for ; Mon, 22 Jun 2020 17:27:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="Sj/LDxGl" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org E80AC2073E Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 740D76B002A; Mon, 22 Jun 2020 13:27:41 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F0366B002B; Mon, 22 Jun 2020 13:27:41 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5DF0E6B002C; Mon, 22 Jun 2020 13:27:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0237.hostedemail.com [216.40.44.237]) by kanga.kvack.org (Postfix) with ESMTP id 41D086B002A for ; Mon, 22 Jun 2020 13:27:41 -0400 (EDT) Received: from smtpin19.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id 352BD181AD000 for ; Mon, 22 Jun 2020 17:27:40 +0000 (UTC) X-FDA: 76957529880.19.crack65_2e0115526e34 Received: from filter.hostedemail.com (10.5.16.251.rfc1918.com [10.5.16.251]) by smtpin19.hostedemail.com (Postfix) with ESMTP id 082C21ACC38 for ; Mon, 22 Jun 2020 17:27:39 +0000 (UTC) X-HE-Tag: crack65_2e0115526e34 X-Filterd-Recvd-Size: 5339 Received: from mail-pl1-f193.google.com (mail-pl1-f193.google.com [209.85.214.193]) by imf24.hostedemail.com (Postfix) with ESMTP for ; Mon, 22 Jun 2020 17:27:39 +0000 (UTC) Received: by mail-pl1-f193.google.com with SMTP id y17so7837726plb.8 for ; Mon, 22 Jun 2020 10:27:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=+qKZonIXzYkaE7j6NEmUZDll/lqh82KFC5lIzFFAexA=; b=Sj/LDxGlqLLpaYA2HKS0ir72xSJDRvaawqW+y795XoJdbq1kchLvUQjgrJjOWfC+JH gMsIKbShjnjcr2+KurZsh+8EWYtYNU6dksMeefHdh4+cSoDABbcpnRo4yMlqaxI1JeEd 5qoKcloOnFj249PSJkejK7fhAoJHjyymcZD75f7CrBTO9t5sVpKl4/w+l4aq3WNsnfUb TRIDN1c/Dh1iY2rXYeGbxfUZ5LId9P8gQ9pTJRcf4rlFnODdx/9TAPxwlPJJIL5rw7gS qkWxI0tT2V94QPHexmwPKfAygvTNhIxMLj1Lstg8dOiTztKRbwGZVv2oVu9k5+oOpdUQ n93w== 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=+qKZonIXzYkaE7j6NEmUZDll/lqh82KFC5lIzFFAexA=; b=YP26chVlyuCOjcU4BAV9aS9JG6IlAc9krwaMkY+wzoBk2OWqwWAy3OWDAbtcHhashL 2CqTSbqj5X+20yba7quBT4LGXxuT5HYuDpYvmsfQ1lURSz9YDfI/NpghyPGHflO63MNc YsgMKFEh7eV0Gago8ldaKCIVt66Ms5uEn871tBnskm0lByRzDDMNLPtsTrsFiepoaHsC IHDSSni+813cMjRuUAgtK9SjJR1nDvR03BQsUwmJXCjvNRngh3NZhfubqZs3c4Sn45FM 72Uz1PDi6U0d8wru8pa5shd+ywePkz82fxz8BK7CX5UkcGKrVGHf40HbJr0hyjzH1S1Z k3+A== X-Gm-Message-State: AOAM531MBtskfy/N/0fltwqZ+oeTbnfA5Uxkz4xSLuntOj7SpAYLaeLk tmGCAhED55gxT1jIYxOh3WPX1nhqOr+4HZ7rDXSgTA== X-Google-Smtp-Source: ABdhPJwAJxd3TbD1t00Y40e3G8EKfLPlkBmqQvCE355+9C0tlqa2OCw7GjEjFlFvPeiUto0aRyH3uyXx9jYG3D/uAag= X-Received: by 2002:a17:902:b698:: with SMTP id c24mr20096772pls.223.1592846858031; Mon, 22 Jun 2020 10:27:38 -0700 (PDT) MIME-Version: 1.0 References: <20200620033007.1444705-1-keescook@chromium.org> <20200620033007.1444705-17-keescook@chromium.org> In-Reply-To: <20200620033007.1444705-17-keescook@chromium.org> From: Nick Desaulniers Date: Mon, 22 Jun 2020 10:27:26 -0700 Message-ID: Subject: Re: [PATCH v2 13/16] mm/debug_vm_pgtable: Remove uninitialized_var() usage To: Kees Cook Cc: LKML , Linus Torvalds , Miguel Ojeda , Alexander Potapenko , Joe Perches , Andy Whitcroft , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , drbd-dev@lists.linbit.com, linux-block@vger.kernel.org, b43-dev@lists.infradead.org, Network Development , Linux Doc Mailing List , linux-wireless , linux-ide@vger.kernel.org, linux-clk@vger.kernel.org, linux-spi@vger.kernel.org, Linux Memory Management List , clang-built-linux Content-Type: text/plain; charset="UTF-8" X-Rspamd-Queue-Id: 082C21ACC38 X-Spamd-Result: default: False [0.00 / 100.00] X-Rspamd-Server: rspam01 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Fri, Jun 19, 2020 at 8:30 PM Kees Cook wrote: > > Using uninitialized_var() is dangerous as it papers over real bugs[1] > (or can in the future), and suppresses unrelated compiler warnings (e.g. > "unused variable"). If the compiler thinks it is uninitialized, either > simply initialize the variable or make compiler changes. As a precursor > to removing[2] this[3] macro[4], just initialize this variable to NULL. > > [1] https://lore.kernel.org/lkml/20200603174714.192027-1-glider@google.com/ > [2] https://lore.kernel.org/lkml/CA+55aFw+Vbj0i=1TGqCR5vQkCzWJ0QxK6CernOU6eedsudAixw@mail.gmail.com/ > [3] https://lore.kernel.org/lkml/CA+55aFwgbgqhbp1fkxvRKEpzyR5J8n1vKT1VZdz9knmPuXhOeg@mail.gmail.com/ > [4] https://lore.kernel.org/lkml/CA+55aFz2500WfbKXAx8s67wrm9=yVJu65TpLgN_ybYNv0VEOKA@mail.gmail.com/ > > Fixes: 399145f9eb6c ("mm/debug: add tests validating architecture page table helpers") > Signed-off-by: Kees Cook > --- > mm/debug_vm_pgtable.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/mm/debug_vm_pgtable.c b/mm/debug_vm_pgtable.c > index e45623016aea..83c9e88a052a 100644 > --- a/mm/debug_vm_pgtable.c > +++ b/mm/debug_vm_pgtable.c > @@ -307,7 +307,7 @@ static int __init debug_vm_pgtable(void) > phys_addr_t paddr; > unsigned long vaddr, pte_aligned, pmd_aligned; > unsigned long pud_aligned, p4d_aligned, pgd_aligned; > - spinlock_t *uninitialized_var(ptl); > + spinlock_t *ptl = NULL; It looks like the address of ptl is passed to pte_alloc_map_lock. It looks like pte_offset_map_lock unconditionally assigns through that pointer before reading. So this could be left uninitialized, but initializing it doesn't hurt. Reviewed-by: Nick Desaulniers > > pr_info("Validating architecture page table helpers\n"); > prot = vm_get_page_prot(VMFLAGS); > -- -- Thanks, ~Nick Desaulniers