Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2190867iof; Tue, 7 Jun 2022 22:41:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxk6jjDgmM/J/9eXrzhYvVo8td93pCR21+we+53hBNebik+IYMNRQ0gkwsDup6Y3i7HBboc X-Received: by 2002:a05:6a00:e8e:b0:518:287c:ce82 with SMTP id bo14-20020a056a000e8e00b00518287cce82mr32584468pfb.4.1654666902309; Tue, 07 Jun 2022 22:41:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654666902; cv=none; d=google.com; s=arc-20160816; b=LNFag2Ek+bx7DPWbaBHMR8K9L5sne3/7eeFcPm9rDgYHwWLojQQ+phf+rNWVHRqdZa NEcekRdPbjbfVRaGvp6HvHQ/RCNKRSXUDN34bORX/RgAVWpSoPAiBUkksPQimHxDDo0H 4vlYzrODQX8xFuGgX1LMpnGgT7/mY9i/LBY0brVImS2bf990ayfuH56AYtj9yqWUp62q hnc11S0075p91DzvUzkGVzOpW1IfOwZYgAdbrO6zzA9gBNL9oGL6aJgm4bVNurMjnzVl 4xRanpqrseIvcmwXwUPylWyVC+YKONiEUh5Nl3bLo/zkAkUQv7hUg0NHgAtOp2BjL6FQ FIPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ttELViscirRuOh328fz5boFMYI6bDNWRoi1wxHdmSiA=; b=SLxyZU1KazNh1LjSnshoEx42eDJSUuX8C5aPRU2ybAB6ZnvY8cp9bxRq7SNZdNEd5l dYxrmEvOFSUzaGqwu/5Iti+v8Flsuhrgb1kypiMoR2ve5o+XHG8zqXyEuUd2EODMGhWf b2n1tM9dvBq4tww49cg1AyDaAJeTS3Um30LzESgq+nJg9gtH8O5irDE75hZClCu2zCzc yeXKRWk49wUk2BfyGXYImBVwbWkLOjlSNxnbietzPYrZgJprsmIm7q5LWqatT8iPW9lw ese7MQs7vKkLJH4tn1e5gKZVaQHuhhapaDDRpYE6k4H4Jkns9aH76anzYP7uOxQCHIOR 1Wtg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cCC+02Zl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bc14-20020a656d8e000000b003fba60e01e1si30411476pgb.546.2022.06.07.22.41.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jun 2022 22:41:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=cCC+02Zl; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D35A4307225; Tue, 7 Jun 2022 22:07:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1383538AbiFGWfR (ORCPT + 99 others); Tue, 7 Jun 2022 18:35:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55246 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1380320AbiFGVVR (ORCPT ); Tue, 7 Jun 2022 17:21:17 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E2D57118027; Tue, 7 Jun 2022 11:59:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 83FB661787; Tue, 7 Jun 2022 18:59:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8C434C385A2; Tue, 7 Jun 2022 18:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654628390; bh=mPjFnB12v9QIjvkloTIVfkJB+ZjteATQWCqedBdGsPw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cCC+02Zl5jldYfKGqXndauODc0JNXbKAvYhttgzmoosfKePLIX6gS7Tz6asnBK4HB 2Xep4H2xdL9ZtCcsVCsRFdggr0wyzddrfZUDnTuhq3AsULUyakhJBfDAjsGXwDMtFU wOjAfknVruY1/sl97ApKjmxyErCISJF29erXbTJ0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ammar Faizi , Borislav Petkov , Sasha Levin Subject: [PATCH 5.18 285/879] x86/delay: Fix the wrong asm constraint in delay_loop() Date: Tue, 7 Jun 2022 18:56:43 +0200 Message-Id: <20220607165011.119924192@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607165002.659942637@linuxfoundation.org> References: <20220607165002.659942637@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ammar Faizi [ Upstream commit b86eb74098a92afd789da02699b4b0dd3f73b889 ] The asm constraint does not reflect the fact that the asm statement can modify the value of the local variable loops. Which it does. Specifying the wrong constraint may lead to undefined behavior, it may clobber random stuff (e.g. local variable, important temporary value in regs, etc.). This is especially dangerous when the compiler decides to inline the function and since it doesn't know that the value gets modified, it might decide to use it from a register directly without reloading it. Change the constraint to "+a" to denote that the first argument is an input and an output argument. [ bp: Fix typo, massage commit message. ] Fixes: e01b70ef3eb3 ("x86: fix bug in arch/i386/lib/delay.c file, delay_loop function") Signed-off-by: Ammar Faizi Signed-off-by: Borislav Petkov Link: https://lore.kernel.org/r/20220329104705.65256-2-ammarfaizi2@gnuweeb.org Signed-off-by: Sasha Levin --- arch/x86/lib/delay.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/x86/lib/delay.c b/arch/x86/lib/delay.c index 65d15df6212d..0e65d00e2339 100644 --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -54,8 +54,8 @@ static void delay_loop(u64 __loops) " jnz 2b \n" "3: dec %0 \n" - : /* we don't need output */ - :"a" (loops) + : "+a" (loops) + : ); } -- 2.35.1