Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp507370pxx; Wed, 28 Oct 2020 09:54:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwr/9afrsQvpuQIPcWiymq/znRKwQTx5tNrJchQBPNIxNIiXjQ2O308sdkjfOwTHOx8OgWZ X-Received: by 2002:a50:d555:: with SMTP id f21mr8875492edj.334.1603904055259; Wed, 28 Oct 2020 09:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1603904055; cv=none; d=google.com; s=arc-20160816; b=s7dKlRyMEcJ60yONqcifZR3YDkOrc1kYrYa/wrs0gke03bPcmRZsJlovUv9E9tc+tE sNiqSjvOVK2hnQAy1VjIoaNmkDVEKPSQ6lxZA71t7tiMA6XFT0x6zUt7sFPmmYegexQc LqwJueUHOfYDzeyeDHDivPE4GAedHmOSrEnXzvpqhBK8N5To7htdt0MD52yB7OHuCfJY ERPcRT4iH/nqFcQsX83195OnJhbhcIYi8DsWURs+AAREhj2xfhjLvQmykSy4TtAIb8IC bjB7xM6j//2gaVDWdrXPfEy8Z+1HTLjLCfhbFTY/kblkBltYOZJifmQPoLbYXs19pKhz nmrA== 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=KwkzXqGuGj4o6B0ZacUTRp06IuSKoZKR9RbhmyhNlGA=; b=pDtnSIEgZX1+qYYIFRLLkXO0oVP5ZaaA+70sPOcW+EzgN+LMhX6GPfvXv37zH/S/f9 /SeHzvnzLnt5mDogZRMo9qpVHgoxBlOzYNXXidDlnRtffe0bOxwQNC1x9uSTrSwT7ymZ ksMnw6ZZ94a69Dd3Jc6aqPoLcpC2898qMKoPURhae/MXaN5cpLeOFuzWbmVFCQ9y+93X xg0CKolplyhOgl3CZ9UCeUJbI4g5sMyIzBUHbblCIcylmrt4sQG8oBBJuBc8p5lXONs8 T7qIjNx3VYDpmdOo5wNYJ9XgEdrDAl9I5+RI8U91qMi1htkKSA6INy93jRjN/1m7Z+Xr N09g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QY7N6yXc; 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=fail (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 j13si1208edj.549.2020.10.28.09.53.52; Wed, 28 Oct 2020 09:54:15 -0700 (PDT) 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=@kernel.org header.s=default header.b=QY7N6yXc; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1818839AbgJ0RYF (ORCPT + 99 others); Tue, 27 Oct 2020 13:24:05 -0400 Received: from mail.kernel.org ([198.145.29.99]:54726 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752297AbgJ0OyU (ORCPT ); Tue, 27 Oct 2020 10:54:20 -0400 Received: from localhost (83-86-74-64.cable.dynamic.v4.ziggo.nl [83.86.74.64]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E72B20679; Tue, 27 Oct 2020 14:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1603810459; bh=DfuOybiE0/kryS5zQ+oUbHWyBHHnPpeSbI96AM6mWTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QY7N6yXcFIStOc+mimchDILXTK1dtUWWf56UBJNRkt96lok07YMqnnXFbsjvzzZlT 44nu7svfWSDxjBZn7XZcvS6xZo+2oihU7VTvdH5+ud3dBnCge5g85zhGP4RbkQ/DCh 9QoggF+llSBcxMTeQeGr2SZwC8FNbP1KsSz7qc90= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Bart Van Assche , Laurent Pinchart , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.8 116/633] media: uvcvideo: Silence shift-out-of-bounds warning Date: Tue, 27 Oct 2020 14:47:39 +0100 Message-Id: <20201027135528.139979505@linuxfoundation.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201027135522.655719020@linuxfoundation.org> References: <20201027135522.655719020@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: Laurent Pinchart [ Upstream commit 171994e498a0426cbe17f874c5c6af3c0af45200 ] UBSAN reports a shift-out-of-bounds warning in uvc_get_le_value(). The report is correct, but the issue should be harmless as the computed value isn't used when the shift is negative. This may however cause incorrect behaviour if a negative shift could generate adverse side effects (such as a trap on some architectures for instance). Regardless of whether that may happen or not, silence the warning as a full WARN backtrace isn't nice. Reported-by: Bart Van Assche Fixes: c0efd232929c ("V4L/DVB (8145a): USB Video Class driver") Signed-off-by: Laurent Pinchart Reviewed-by: Bart Van Assche Tested-by: Bart Van Assche Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/usb/uvc/uvc_ctrl.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/media/usb/uvc/uvc_ctrl.c b/drivers/media/usb/uvc/uvc_ctrl.c index e399b9fad7574..a30a8a731eda8 100644 --- a/drivers/media/usb/uvc/uvc_ctrl.c +++ b/drivers/media/usb/uvc/uvc_ctrl.c @@ -773,12 +773,16 @@ static s32 uvc_get_le_value(struct uvc_control_mapping *mapping, offset &= 7; mask = ((1LL << bits) - 1) << offset; - for (; bits > 0; data++) { + while (1) { u8 byte = *data & mask; value |= offset > 0 ? (byte >> offset) : (byte << (-offset)); bits -= 8 - (offset > 0 ? offset : 0); + if (bits <= 0) + break; + offset -= 8; mask = (1 << bits) - 1; + data++; } /* Sign-extend the value if needed. */ -- 2.25.1