Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp444418iog; Mon, 13 Jun 2022 06:07:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk/eYhatURljNyPaX1jSUXFtsxdHLcdV0R1tHRpr7Md94xB8kdBNrl6FvQB19oOlilxu6x X-Received: by 2002:a63:6c44:0:b0:3fa:ec6b:33e7 with SMTP id h65-20020a636c44000000b003faec6b33e7mr50768644pgc.435.1655125276732; Mon, 13 Jun 2022 06:01:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655125276; cv=none; d=google.com; s=arc-20160816; b=IBh6EeEk4gVsnxflT4OMX/AJ2DSz6JL2rB2TcP0ekvjS7pHFBx2nv8LIel7ySIqryO /eTkSVPfRysn9x7kuOyt7ELTQf/DYHqHUEIuPhYZsi/C3xcPYpEr0IILDLZUPtrvebQr ItZaiHTxab+Fw54mM1BuGnZ7PNRytLwnhRAmVV0pFrrHZk+ISYn3Ftjhu66ZxRBjniyi eD5FpOsAzY3TmhtxFboYvyBIh6j7/yQdBzoL1rNIgZGGa45VCy4flm3pUwYFr1UNFfOV iz+N1jae/N7OBn3KpZkSktgHTxjuP0klndlinwrlppX/jznyDFuoReMjGKKG12z5u35R hqjw== 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=GLS7OzHfZakKPjvrLALwGwxig/dCSGxH5MqBjMJZG/g=; b=XFXxNDjhfArTLrJZjRYew6uOeSt37Fhr4BmkRsLbQMU56WRqtBd+6k2559VoUwc/gG UGWcqSwCTvwlxrK6e0e+8BluPfOthlSMaiV/SBntl9dBafAJFWygS2SXdsxwKIV14yLo Ro0YljoMGbxw5UGvuyouVI5ZHb4Tp5tqgOA6zTr0TRf4JZ7QrTMCPfXi5JdGQTmceU7u +Cym7lK9U9ANymMVwY/7hGjZs9mP8adkcKC8ZYADoImSyP2ttSY2elh0yUP1QcvJA7ZE bUuntmzI8oxKW0s5QTaL2NrfUompVrVW9y/JhIGMYUuDHsjuBaswj5FThTMzfz5+2jBE iieg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gMO3ne67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c22-20020a170902849600b00154319ca2ddsi9069381plo.397.2022.06.13.06.00.59; Mon, 13 Jun 2022 06:01:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=gMO3ne67; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242039AbiFMKR7 (ORCPT + 99 others); Mon, 13 Jun 2022 06:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57734 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241683AbiFMKRc (ORCPT ); Mon, 13 Jun 2022 06:17:32 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88EAC1FCED; Mon, 13 Jun 2022 03:15:39 -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 ams.source.kernel.org (Postfix) with ESMTPS id 0B855B80E92; Mon, 13 Jun 2022 10:15:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76300C34114; Mon, 13 Jun 2022 10:15:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655115332; bh=9fM207ThNnSdzxF2rwXN/zW9jb0LrWT0dcV66EEyAQs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gMO3ne67dtM+co9vdgi1kzjYaReMj4EMdfiN4pAoBikkmmO+vmg6GwLpnN2BSSDrJ uMpAHignzsb4Nv7N2rSVNf6WjuOsYItVd+mbFcnQ6tcEB4E+IbcBOlLDbEyJT4OpYa Sijg8WOEOv5VU6wqHObmL+7K0opGjrL0G6X2mBk0= 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 4.9 038/167] x86/delay: Fix the wrong asm constraint in delay_loop() Date: Mon, 13 Jun 2022 12:08:32 +0200 Message-Id: <20220613094849.810646269@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094840.720778945@linuxfoundation.org> References: <20220613094840.720778945@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 71a3759a2d4e..60cc4f222cbf 100644 --- a/arch/x86/lib/delay.c +++ b/arch/x86/lib/delay.c @@ -42,8 +42,8 @@ static void delay_loop(unsigned long loops) " jnz 2b \n" "3: dec %0 \n" - : /* we don't need output */ - :"a" (loops) + : "+a" (loops) + : ); } -- 2.35.1