Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp4199954pxy; Mon, 26 Apr 2021 22:06:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxtd2+eol+gePaO2ezIbyCuNcawxLt3CMw9jbCQ1fN53qRx5CFe8kSd/oiNwRl9N1hH/of6 X-Received: by 2002:a05:6a00:1aca:b029:25a:b810:94c7 with SMTP id f10-20020a056a001acab029025ab81094c7mr21073146pfv.15.1619499981993; Mon, 26 Apr 2021 22:06:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619499981; cv=none; d=google.com; s=arc-20160816; b=JOTtOr3gWgZ6LjP+z0d8knyALEWOHrKDf/l0U0XX8yqy1Vh6sloXAohajXfxUTJ5qm otbpCcZKsJtljCY4g1mahV1gAumnUY2sbUcskIxloLxDRBU8lartqijK7vw6UCWlQGFm JF8JD3vIFitAswl84WYbYVlUsc7ulYbxsHO5j0xfCOkd41KQqJ6AxdlYhqrBkOjENdd5 utiQ2qXEZMXWcu0w4cFrKtO4A3BtiLX2l5HCVDnVMvBWOk/+/imNhKPo9uvN16co3KzV qtM/xNgzdsdHWoqm94OuXyzPwbt6zp0wyKzKqUSZ0XVob7BS2lcrpil522B51CWBHFND tSkg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=kE1ykJP/3UFmDwWSld/lzNKQB3MHvuNkE+kKqo0NSk4=; b=YYi0PGsatjvKdq6Q8dw4CK4LHb5ZrHutPIx9Fk8m2F7uzorlFzyepE1gN4Tok3a3kn BWNL7w6C7esJHNOlJwQ/Q7yCh9Gx0Dee6ns1G6z+h8u834WRDyzzAa4iJLN4gQPgSdpD BKn8osuBcTGCfAj40gAmnPkOCeS1cMXM2uSzj9iZLWNbukRqM8vW/fk52Dm3yLTP2DZ0 eynFMDrv3doxhNpbzHMsoCuIcBqUPSeQD/dWb05rjGwUXqmPrPvDD2CmKArawZXZ/7JJ YhUrlsnjZwPYno4b+1I6mipGRQbNeSJ56NXdIp2+puUw01DVdOL1f3L6M+8MCu2jl0Ah 0GYQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h14si22093666pgn.82.2021.04.26.22.06.06; Mon, 26 Apr 2021 22:06:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229816AbhD0FF7 (ORCPT + 99 others); Tue, 27 Apr 2021 01:05:59 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:40189 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbhD0FF6 (ORCPT ); Tue, 27 Apr 2021 01:05:58 -0400 Received: from localhost (mailhub3.si.c-s.fr [192.168.12.233]) by localhost (Postfix) with ESMTP id 4FTqT63mM3z4gf; Tue, 27 Apr 2021 07:05:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id e4PMjbRIQiGt; Tue, 27 Apr 2021 07:05:14 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 4FTqT62gmzz4jM; Tue, 27 Apr 2021 07:05:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 125F38B77C; Tue, 27 Apr 2021 07:05:14 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id je4m3tj14JOn; Tue, 27 Apr 2021 07:05:14 +0200 (CEST) Received: from [192.168.4.90] (unknown [192.168.4.90]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 9BD808B777; Tue, 27 Apr 2021 07:05:12 +0200 (CEST) Subject: Re: [PATCH] powerpc: Avoid clang uninitialized warning in __get_user_size_allowed To: Nathan Chancellor , Michael Ellerman Cc: Nick Desaulniers , linux-kernel@vger.kernel.org, clang-built-linux@googlegroups.com, Paul Mackerras , linuxppc-dev@lists.ozlabs.org References: <20210426203518.981550-1-nathan@kernel.org> From: Christophe Leroy Message-ID: <32a0f305-031b-e4da-345d-0f03b2b42189@csgroup.eu> Date: Tue, 27 Apr 2021 07:05:12 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210426203518.981550-1-nathan@kernel.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 26/04/2021 à 22:35, Nathan Chancellor a écrit : > Commit 9975f852ce1b ("powerpc/uaccess: Remove calls to __get_user_bad() > and __put_user_bad()") switch to BUILD_BUG() in the default case, which > leaves x uninitialized. This will not be an issue because the build will > be broken in that case but clang does static analysis before it realizes > the default case will be done so it warns about x being uninitialized > (trimmed for brevity): > > In file included from mm/mprotect.c:13: > In file included from ./include/linux/hugetlb.h:28: > In file included from ./include/linux/mempolicy.h:16: > ./include/linux/pagemap.h:772:16: warning: variable '__gu_val' is used > uninitialized whenever switch default is taken [-Wsometimes-uninitialized] > if (unlikely(__get_user(c, uaddr) != 0)) > ^~~~~~~~~~~~~~~~~~~~ > ./arch/powerpc/include/asm/uaccess.h:266:2: note: expanded from macro '__get_user' > __get_user_size_allowed(__gu_val, __gu_addr, __gu_size, __gu_err); \ > ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > ./arch/powerpc/include/asm/uaccess.h:235:2: note: expanded from macro > '__get_user_size_allowed' > default: BUILD_BUG(); \ > ^~~~~~~ > > Commit 5cd29b1fd3e8 ("powerpc/uaccess: Use asm goto for get_user when > compiler supports it") added an initialization for x because of the same > reason. Do the same thing here so there is no warning across all > versions of clang. Ah yes, I tested with Clang 11 which has CONFIG_CC_HAS_ASM_GOTO_OUTPUT, that's the reason why I hit that warning only in the CONFIG_CC_HAS_ASM_GOTO_OUTPUT branch. But regardless, is that normal that Clang warns that on a never taken branch ? That's puzzling. > > Link: https://github.com/ClangBuiltLinux/linux/issues/1359 > Signed-off-by: Nathan Chancellor Acked-by: Christophe Leroy > --- > arch/powerpc/include/asm/uaccess.h | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h > index a4e791bcd3fe..a09e4240c5b1 100644 > --- a/arch/powerpc/include/asm/uaccess.h > +++ b/arch/powerpc/include/asm/uaccess.h > @@ -232,7 +232,7 @@ do { \ > case 2: __get_user_asm(x, (u16 __user *)ptr, retval, "lhz"); break; \ > case 4: __get_user_asm(x, (u32 __user *)ptr, retval, "lwz"); break; \ > case 8: __get_user_asm2(x, (u64 __user *)ptr, retval); break; \ > - default: BUILD_BUG(); \ > + default: x = 0; BUILD_BUG(); \ > } \ > } while (0) > > > base-commit: ee6b25fa7c037e42cc5f3b5c024b2a779edab6dd >