Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3574627pxb; Mon, 24 Jan 2022 12:34:35 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvfnYK0eDU2eaY4qMGu7zg6vHCk9aAIR+acciLsL1tP/mEitSMr5qrloV5avn7H/4k6m2c X-Received: by 2002:a63:8a44:: with SMTP id y65mr12793549pgd.456.1643056475498; Mon, 24 Jan 2022 12:34:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643056475; cv=none; d=google.com; s=arc-20160816; b=AQOfDdz0u45REWCdsmx28r2n1syeOiMwcAZ9w7cYGY8KToEk5xOZt2E3+IaJ9FMbfO VleeneMn9UYEz1Oeym74k7hA0omFPqB7w46jrTAhBFhFtAbDTS9Gl2Nem5DiFI+Yb9JL +1NzeSGx85Q45Wltuatywltnqy+AfWQ28Taxep1VAg1Zg/qlxgSG+ssJHYdrr71NQALG 8SUxV4zktaABSlh0BK9mFMdHCUR9CjlePKFF2dYfMHFt6xIkqVQPk2GcfmrxZTCcVfPQ pNnD+Ts+N00I9cjmBC4Z133vDEJ+oPLVAnh1OAZctVDHOFlTDSbj3S5V1vnvLrsRCyUi 9OWA== 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=0/WP6yAuVrny+ccSqAkbZAEXbXYosgIjGA35sjmGvS0=; b=siArppQWlTZOG/JTgDpe+poVxtzkXMBe+fmUULsR9Pwt+k0eRlo6rX5lRi0/4pTiKp eixxL29G6fZVSKz6H6x7INCNBjoGOGEIlv4zP/Lqw6CaPjBOkBLO/Lw0HBkXGXLa4IFB FAmmjkzK4pWKHxUonMRZsrau+NGswwIxVTp4CXi1qegC2nVopOTJDYLLO/x8Kt6sxwY/ mkYj/xT8rF9HDZRpCm+eAoiKm93zHixF9HohGqUngavhPkem4sftsekwq2zklyo+gUWN OTuuHTNE+7qoFKPSM0j5I8YgMhsXTNTImTaerCQERRXwDpkuRiTwPeZzng2X4l1WWJMG y8KQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=d61HW+iv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z9si15736920pgu.353.2022.01.24.12.34.10; Mon, 24 Jan 2022 12:34:35 -0800 (PST) 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=@linuxfoundation.org header.s=korg header.b=d61HW+iv; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1344436AbiAXToH (ORCPT + 99 others); Mon, 24 Jan 2022 14:44:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352886AbiAXTbN (ORCPT ); Mon, 24 Jan 2022 14:31:13 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC50FC028C2C; Mon, 24 Jan 2022 11:14:12 -0800 (PST) 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 8BADB612F3; Mon, 24 Jan 2022 19:14:12 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4A1C6C340E5; Mon, 24 Jan 2022 19:14:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643051652; bh=2oP2LDwVaJ0zFvAODpVplv81tT3l5LF8ATWXhfox+4U=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d61HW+ive5VZEYoKLB96VbKVmfejX6JBAU0jTw30+rdXEqCjp5NLHJumRZBDfDLIX cWsdeQwvaM56fiRzxXyjqy97eQb5YaYrzLpaADjNkaj/9YLrzO+McA/1ZY0iC3xIW+ UIcfE6T1m1Va/X+C493Kd3QBT8wF9OY1Uy5j8du4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Michael Kuron , Mauro Carvalho Chehab Subject: [PATCH 4.19 036/239] media: dib0700: fix undefined behavior in tuner shutdown Date: Mon, 24 Jan 2022 19:41:14 +0100 Message-Id: <20220124183944.289239575@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124183943.102762895@linuxfoundation.org> References: <20220124183943.102762895@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Michael Kuron commit f7b77ebe6d2f49c7747b2d619586d1aa33f9ea91 upstream. This fixes a problem where closing the tuner would leave it in a state where it would not tune to any channel when reopened. This problem was discovered as part of https://github.com/hselasky/webcamd/issues/16. Since adap->id is 0 or 1, this bit-shift overflows, which is undefined behavior. The driver still worked in practice as the overflow would in most environments result in 0, which rendered the line a no-op. When running the driver as part of webcamd however, the overflow could lead to 0xff due to optimizations by the compiler, which would, in the end, improperly shut down the tuner. The bug is a regression introduced in the commit referenced below. The present patch causes identical behavior to before that commit for adap->id equal to 0 or 1. The driver does not contain support for dib0700 devices with more adapters, assuming such even exist. Tests have been performed with the Xbox One Digital TV Tuner on amd64. Not all dib0700 devices are expected to be affected by the regression; this code path is only taken by those with incorrect endpoint numbers. Link: https://lore.kernel.org/linux-media/1d2fc36d94ced6f67c7cc21dcc469d5e5bdd8201.1632689033.git.mchehab+huawei@kernel.org Cc: stable@vger.kernel.org Fixes: 7757ddda6f4f ("[media] DiB0700: add function to change I2C-speed") Signed-off-by: Michael Kuron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/usb/dvb-usb/dib0700_core.c | 2 -- 1 file changed, 2 deletions(-) --- a/drivers/media/usb/dvb-usb/dib0700_core.c +++ b/drivers/media/usb/dvb-usb/dib0700_core.c @@ -619,8 +619,6 @@ int dib0700_streaming_ctrl(struct dvb_us deb_info("the endpoint number (%i) is not correct, use the adapter id instead", adap->fe_adap[0].stream.props.endpoint); if (onoff) st->channel_state |= 1 << (adap->id); - else - st->channel_state |= 1 << ~(adap->id); } else { if (onoff) st->channel_state |= 1 << (adap->fe_adap[0].stream.props.endpoint-2);