Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1977467pxb; Fri, 5 Mar 2021 04:36:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJw1PatYusfI6FT8u1b1iBeF3RIFbQlJ2xakBmfrwdyaj9MLQnv1Z3cjZpNpNyZzbl0LeXyX X-Received: by 2002:a17:906:2bce:: with SMTP id n14mr1944709ejg.171.1614947811863; Fri, 05 Mar 2021 04:36:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614947811; cv=none; d=google.com; s=arc-20160816; b=mctZEn6xO+EAL4pDGa4s6jfbt+LmBuuzyi3gvzxSi4P03Bqk9zdhFs224KjJUGlXMs ka+qZqUJS2G+MQULQ4d0Z2nFeQVSFWV78WamthwUBQQ15wtNvBvjRsvlVwWCgZCGI/t8 3D3xZJYAf6JdfVKPYcjX9RDRdOnEqohn7w5VvVkdjlwLoyVINyTLpYUsPrQW5gZ8DXHp U07c9LBBvI9WNAR/5h4ORUFQWm8XdWQq0B04PRm8bda7jde/PWlOItssW2sKwmPxw9ZK UYres4Hp8EXn+18tYl5SeBdrhZnZawulFVo5gywphLj65Rp/5940XWyQxUQ/O75D+7af Ap7g== 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=gkfQxcY3l089PpMI7KtjouvW5FbvBjdv7DFiNrDOYho=; b=VPjwMBp90+tc69gZUKjqK6OdVDvHW3oZWzNcwmdAANRpRlMMb/EXnaAE/vVezlAnJ2 VY2b4UD+lKpyASeLEektLSUaCyFGfXinCVgYb3WCXQ6gDW0dLcd3nMXbAZfQs/fEjLOO 0syc+ihJfqvXeWxGeI++kpjd1ms49Q7oFJizcS8jDrTXAy3/5OnXWDwYFZxeRCCAxvrg FfG2+xanSkLbFZoZdJ6PUdPfGt4DSg3AFt70SEeNSxk+FviLhW3B93ha+dHTyHtxsC90 wltQAY5OpPmjbvqcTizEmJsH9ylowAQ14a5nN+tAEt5NVRL+u+IGllAqeiDz8rGZ90aD 7CgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=INEHNyba; 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 a9si1321957ejk.421.2021.03.05.04.36.28; Fri, 05 Mar 2021 04:36:51 -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=INEHNyba; 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 S230124AbhCEMdd (ORCPT + 99 others); Fri, 5 Mar 2021 07:33:33 -0500 Received: from mail.kernel.org ([198.145.29.99]:43846 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232335AbhCEMdE (ORCPT ); Fri, 5 Mar 2021 07:33:04 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id B6AB165004; Fri, 5 Mar 2021 12:33:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614947584; bh=ablFBy7xMba6LJHreOVH8kLvnWZtiyhCCccDIhHFmsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=INEHNybatBIhukEcWGEpJB6U2cvEUH/JGPRv12bBOjs0LovepK9LjbVwF39lZT/yI kQ/E333eA+U4/wcW+2oAu1UQbnQF5V0Puw4X8DJP8DA7wbuZCxnLnaG2tAeYiQQAU3 oVFnN43T87bG3nir20sru7ScOPuauPWjlSv5gu5Y= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hans Verkuil , syzbot+42d8c7c3d3e594b34346@syzkaller.appspotmail.com, Mauro Carvalho Chehab Subject: [PATCH 5.4 11/72] media: v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Date: Fri, 5 Mar 2021 13:21:13 +0100 Message-Id: <20210305120857.890447247@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210305120857.341630346@linuxfoundation.org> References: <20210305120857.341630346@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: Hans Verkuil commit 048c96e28674f15c0403deba2104ffba64544a06 upstream. If a menu has more than 64 items, then don't check menu_skip_mask for items 65 and up. Signed-off-by: Hans Verkuil Reported-by: syzbot+42d8c7c3d3e594b34346@syzkaller.appspotmail.com Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Greg Kroah-Hartman --- drivers/media/v4l2-core/v4l2-ctrls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1795,7 +1795,8 @@ static int std_validate(const struct v4l case V4L2_CTRL_TYPE_INTEGER_MENU: if (ptr.p_s32[idx] < ctrl->minimum || ptr.p_s32[idx] > ctrl->maximum) return -ERANGE; - if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) + if (ptr.p_s32[idx] < BITS_PER_LONG_LONG && + (ctrl->menu_skip_mask & BIT_ULL(ptr.p_s32[idx]))) return -EINVAL; if (ctrl->type == V4L2_CTRL_TYPE_MENU && ctrl->qmenu[ptr.p_s32[idx]][0] == '\0')