Received: by 2002:a05:6a10:af89:0:0:0:0 with SMTP id iu9csp3622063pxb; Mon, 24 Jan 2022 13:43:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJwWYm2dtb6XThOyk3irnSbHz/pvFLp1WUlUAfgWQJkS1XCUWVtSJ0hi6gUilQN8jY9e8JW/ X-Received: by 2002:a63:8448:: with SMTP id k69mr13187434pgd.565.1643060618174; Mon, 24 Jan 2022 13:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1643060618; cv=none; d=google.com; s=arc-20160816; b=pDWKNuleVuP8xiGpMLABK5eegJ8uDNRfjS3gkk5XzLl3nujfH3s5WQBeAE6Xi6/b/g sT6n+Y0aHXe6miONk9vNX8eDxPuzxy4R69W4W1OSVs2jKA6ck711VhFXaSshwWGxcQY6 I9vkC399aY+eD6A3E4+M1OCB768AodT2mB7ru0JiTpHO9Dv1/jgpWG8ZX50oMTltxy5Z YhnnB9mp7n0BNkbsETo9Lu7TEID1xD8TB9YiinSjKeyIZkQBSMfUeNxuixAPRrLBNUEH rNzdDSIC5FLHL8lCW8XNmI6zt7LMJPbMSn1W1m8EuetpHPNJCA4EHJ0Jc+QCXFR5LmIa 53/Q== 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=HWyqj9cDjLERTFA8W1aeE/MwcWijnQw85WI8+Rt4mEw=; b=zN3HqfyNd9x8JGUtGK+srx7x+OInym9oo/ZmDm8eIEj8sdHsf/EU/Kjov6DWIBXHwp CIlg84Arkc0eM4Z87yiahyUl4islUmMVHb43sXso91lZAekoLAcft92CHVPKi5aLtr8N ec1phLGqv6AjCFDttQowejBUZbKZ8K8PZ8t6pvkMisSkNyBkGjVHZ2lWhQk8pBeW8uil MHSpe4BO/6NuT3b+LlFpMWHRX5XIC4XDTyfwLW5tjl0G+5gmr1HoO8HFkR1PAqBrk6Mz /yreQuCMy38HSskLIwKt6313acsXxjeec6vXjhpfLJXAbkFDqlnHkPtIMmV5mzUUTQXb 9HZg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=MHpjA5ew; 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 k9si17156135pfc.320.2022.01.24.13.43.21; Mon, 24 Jan 2022 13:43:38 -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=MHpjA5ew; 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 S1451712AbiAXVXY (ORCPT + 99 others); Mon, 24 Jan 2022 16:23:24 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:51834 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1442964AbiAXUzy (ORCPT ); Mon, 24 Jan 2022 15:55:54 -0500 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 40A65B810BD; Mon, 24 Jan 2022 20:55:53 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6108BC340E5; Mon, 24 Jan 2022 20:55:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643057752; bh=R3SYvAKMvIzdD7gfCpbP1XBCEPkDA2vnynlCBsHNGkE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MHpjA5ews7okIAve8to9MCojCYt/ol8yi96bYH/VYyLI+XFHFS+UL5oGsfjI8W2fG DO/O1mKpfGC0gYr10qhOLUht+g81iBmY6S1cuSuyoSyXv8T4MCVe3HXvPpunwzE6An XbqLLSUhU8HD/vuAnpkPVco4y5zgeNQfeOvDdpxQ= 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 5.16 0050/1039] media: dib0700: fix undefined behavior in tuner shutdown Date: Mon, 24 Jan 2022 19:30:39 +0100 Message-Id: <20220124184126.820724440@linuxfoundation.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220124184125.121143506@linuxfoundation.org> References: <20220124184125.121143506@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 @@ -618,8 +618,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);