Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp130468ybm; Tue, 26 May 2020 12:32:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyWm5zcWUxfkQcCALCJvC3cHDLdZH5fjxAQ7JfBm84be4aXwNOf6VpOuoxMv7tgH7nP630a X-Received: by 2002:a05:6402:a48:: with SMTP id bt8mr22428658edb.197.1590521521329; Tue, 26 May 2020 12:32:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590521521; cv=none; d=google.com; s=arc-20160816; b=RMfeSmxiv+RU1EMgWW8DBhOYLQ02lhG1qU0O8nR7SkN8Ba1Oj4O9KDxtHKdjYJ6Nhk V5Oy+m1RFnuyfSt/3GTYphx1bPTTxeRsk0ulcL8KkXCbageIA+DwDLfX3qF/u9hyY6M1 jnxeyYinQGN1RgHAFRP4WS39vos6whRbi+IHkw+2JdMdnNBOW71GQFPDAuYQjXfwZPA5 eim/wwQfl4nYL5se6ybZBIKZhMEZoXQSw2J84PSHzrsB9QE689yKuer0gelc34X+3HBY 8hrKc8R8fauWQFT+OxwwTAwQoAwdRH5RweSVLeWrIfu0VQfLg1fYfafjQqOBm0YfLUVg caag== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4GOHHgZkkaEZGsxrejDX4tHiOBIDKhf4wzvuqsk/UYA=; b=O1GbBzpHVUuumjysYO4M1gb8i67HdFTq0elbRSnHPI21Br0QgndhXLeKzzlS1JWy6q ldAGPFi1nEkbb9axirPgSZadtqmvakO/Ri5y536hmWUH9pSMD53w0eRjcJqElVTrCghh W1zChChOCBh7OPGGL142IXTqaOISNWO+gO61lxJsOhh2Hez3/G0Ezoa/NNZvy0F9TxgE 2QZwJgSN3zbb6atNGyvCAVwtGktgn1HwAc49Rkdl8FXwCOdPICTJ+e2mmqig3aZYPGlL 2z0XaJQoUnRqWXnKMsgKhyXFJr8rUHHiVz2GY4ZHXUEv+2YhJI+uJcNkfIglXRipE4RO EhEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=pX9EnXe0; 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 z7si383813ejf.749.2020.05.26.12.31.36; Tue, 26 May 2020 12:32:01 -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; dkim=pass header.i=@kernel.org header.s=default header.b=pX9EnXe0; 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 S2392496AbgEZT1t (ORCPT + 99 others); Tue, 26 May 2020 15:27:49 -0400 Received: from mail.kernel.org ([198.145.29.99]:59308 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2391288AbgEZTDx (ORCPT ); Tue, 26 May 2020 15:03:53 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4AE0D20849; Tue, 26 May 2020 19:03:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519832; bh=o6xEWP3l3NxJIyh56Zls/j+EDwwS16Hn5+vt1XvPQsE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pX9EnXe0AU+26DftWl1+iXW0wmAZ8sUa65Z1WZe3SNkiKE8rL1QEMZz1g7uGJyaKK WpY1gemp1Hapetu8VqVNVZZtp8LukXxMrVijIIJVnfWHzdJ00F8zQW0jjxS519dCab u/TmhGE5XgN4oE6aj2CU3ks+H2K4NBPpfa+PsSG0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Stephen Rothwell , Thomas Gleixner , Sasha Levin Subject: [PATCH 4.19 34/81] ARM: futex: Address build warning Date: Tue, 26 May 2020 20:53:09 +0200 Message-Id: <20200526183931.170337844@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183923.108515292@linuxfoundation.org> References: <20200526183923.108515292@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Thomas Gleixner [ Upstream commit 8101b5a1531f3390b3a69fa7934c70a8fd6566ad ] Stephen reported the following build warning on a ARM multi_v7_defconfig build with GCC 9.2.1: kernel/futex.c: In function 'do_futex': kernel/futex.c:1676:17: warning: 'oldval' may be used uninitialized in this function [-Wmaybe-uninitialized] 1676 | return oldval == cmparg; | ~~~~~~~^~~~~~~~~ kernel/futex.c:1652:6: note: 'oldval' was declared here 1652 | int oldval, ret; | ^~~~~~ introduced by commit a08971e9488d ("futex: arch_futex_atomic_op_inuser() calling conventions change"). While that change should not make any difference it confuses GCC which fails to work out that oldval is not referenced when the return value is not zero. GCC fails to properly analyze arch_futex_atomic_op_inuser(). It's not the early return, the issue is with the assembly macros. GCC fails to detect that those either set 'ret' to 0 and set oldval or set 'ret' to -EFAULT which makes oldval uninteresting. The store to the callsite supplied oldval pointer is conditional on ret == 0. The straight forward way to solve this is to make the store unconditional. Aside of addressing the build warning this makes sense anyway because it removes the conditional from the fastpath. In the error case the stored value is uninteresting and the extra store does not matter at all. Reported-by: Stephen Rothwell Signed-off-by: Thomas Gleixner Link: https://lkml.kernel.org/r/87pncao2ph.fsf@nanos.tec.linutronix.de Signed-off-by: Sasha Levin --- arch/arm/include/asm/futex.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/arch/arm/include/asm/futex.h b/arch/arm/include/asm/futex.h index ffebe7b7a5b7..91ca80035fc4 100644 --- a/arch/arm/include/asm/futex.h +++ b/arch/arm/include/asm/futex.h @@ -163,8 +163,13 @@ arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) preempt_enable(); #endif - if (!ret) - *oval = oldval; + /* + * Store unconditionally. If ret != 0 the extra store is the least + * of the worries but GCC cannot figure out that __futex_atomic_op() + * is either setting ret to -EFAULT or storing the old value in + * oldval which results in a uninitialized warning at the call site. + */ + *oval = oldval; return ret; } -- 2.25.1