Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1019193rwi; Wed, 19 Oct 2022 05:55:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5UPt87cnWf2prvTFbgUFWIDST3fvBYH9nWmT38RieYzUmNkIRHdN8nScNrt41dwLksCO2S X-Received: by 2002:a05:6402:2402:b0:45c:a1ce:94d8 with SMTP id t2-20020a056402240200b0045ca1ce94d8mr7195904eda.50.1666184123210; Wed, 19 Oct 2022 05:55:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666184123; cv=none; d=google.com; s=arc-20160816; b=RQWnGKVzTW+eeZhsoD0KE7mKN+kT04NByVRdF9twXk+rCTUSyLkOXhB32LJ3DXa9hX Q7WrlkdkbhH5DdDwB67TpS/4e5S7CwgH+KlV4w/drZ9D8c0CIefsOVVLUPR/slu+9NUI qEFXJP5XypUHG8PV2aMlELIcjkvF2hhzrRcRMO70DH4g61Z43ry+BBR+Tv0pqNoduFrP 8Op/kFBS4fMZiGlCMSjEDa/npDfepFNG68BFEsRguB/sV5fMYgXNmKp44b9EEXbWcVRX W7TTxq/iZ4PVpWTqSNyCjpZoZvU6PX9IG+har3fIC6EKwGS8l7fymT3mLYyu+SEamyFZ H0xQ== 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=9NV/ihc0Uh1gmyJpr61Y3yKDSmVXX5AfKL+sPrj3NMw=; b=tvEHuQWPIuW9Nq3vsXE1b4aw0kY5846+jpzHcDP1amkxlfUHKaZQ/8MDsEqFz+1HL1 X/ZL5TMzBkwdm2OoDwprE8JY14PJ1eND0ARLDL8l216o8/UDmrQ87iam8ACAlVCU8+QJ Z+MAS1BJMD2SgJRmBgZKrz2Y6hraIeGX82gBwP30sAY0zFHMah2ir5iRbc1dhYLx5l0C b7cTraT6K6CUiwmgDTn5EE5XqBCrpWml5JF73l5Bl7238ydTAzH705JnERGknhQEF83h HXgvkJMUoj7ozAbhT1k/geLFEfPZs3pV19klSSvCBkIMIjHuU3Liusd1QTNAWJQuZD0x Aegg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=o2fbsTdA; 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 fj3-20020a1709069c8300b00730ed690a72si16561074ejc.630.2022.10.19.05.54.56; Wed, 19 Oct 2022 05:55:23 -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=o2fbsTdA; 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 S232936AbiJSMTT (ORCPT + 99 others); Wed, 19 Oct 2022 08:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36788 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230212AbiJSMSJ (ORCPT ); Wed, 19 Oct 2022 08:18:09 -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 BC0241C39FD; Wed, 19 Oct 2022 04:53:43 -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 1426DB82302; Wed, 19 Oct 2022 08:45:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 644D2C433D6; Wed, 19 Oct 2022 08:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666169139; bh=BMhRM4nqWbjmRpKYBjSHNb+WOA6zO/H96SN3tqK7YGs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o2fbsTdAZk++D9xaC03zryvlU8OXNJq8uB04IWie8HT/hLHhwXonxmVYmkr7WjC0R GRy31cxABzwqu1XpBfA9y9NAqb0FHRv1/0H6FpvDxAJJia2Zn8CBoWs546pxOFIkSU 4Kfh2zJ8ZrQ8So3w0b/tMzNnUoUsU/FD1eFlx2Zg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nicolas Dufresne , Dmitry Osipenko , Hans Verkuil , Mauro Carvalho Chehab Subject: [PATCH 6.0 171/862] media: cedrus: Fix endless loop in cedrus_h265_skip_bits() Date: Wed, 19 Oct 2022 10:24:18 +0200 Message-Id: <20221019083257.513939871@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.4 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 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: Dmitry Osipenko commit 91db7a3fc7fe670cf1770a398a43bb4a1f776bf1 upstream. The busy status bit may never de-assert if number of programmed skip bits is incorrect, resulting in a kernel hang because the bit is polled endlessly in the code. Fix it by adding timeout for the bit-polling. This problem is reproducible by setting the data_bit_offset field of the HEVC slice params to a wrong value by userspace. Cc: stable@vger.kernel.org Fixes: 7678c5462680 (media: cedrus: Fix decoding for some HEVC videos) Reported-by: Nicolas Dufresne Signed-off-by: Dmitry Osipenko Signed-off-by: Nicolas Dufresne Signed-off-by: Hans Verkuil Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/staging/media/sunxi/cedrus/cedrus_h265.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) --- a/drivers/staging/media/sunxi/cedrus/cedrus_h265.c +++ b/drivers/staging/media/sunxi/cedrus/cedrus_h265.c @@ -234,8 +234,9 @@ static void cedrus_h265_skip_bits(struct cedrus_write(dev, VE_DEC_H265_TRIGGER, VE_DEC_H265_TRIGGER_FLUSH_BITS | VE_DEC_H265_TRIGGER_TYPE_N_BITS(tmp)); - while (cedrus_read(dev, VE_DEC_H265_STATUS) & VE_DEC_H265_STATUS_VLD_BUSY) - udelay(1); + + if (cedrus_wait_for(dev, VE_DEC_H265_STATUS, VE_DEC_H265_STATUS_VLD_BUSY)) + dev_err_ratelimited(dev->dev, "timed out waiting to skip bits\n"); count += tmp; }