Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp420775pxb; Wed, 24 Feb 2021 05:57:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxFuykXy01JVppBYGwBLtsKCiUIwOtNLInt18le2o2Witc1Oi+sWfhYx5TstL8NnxAPiQu1 X-Received: by 2002:a17:906:3883:: with SMTP id q3mr30877475ejd.160.1614175050669; Wed, 24 Feb 2021 05:57:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614175050; cv=none; d=google.com; s=arc-20160816; b=zYgaUXvSfqMMyHlhjgvWRDvWhh/MQlcT3gaxth358MIGhVoxeuSuJjJCO1y2Bve1bT rVnSPQzAXRPMleMoecwQAB8C5fUvW3tk2zCHyyYp6ML8E2tJma+tI5Gml+ef18Ybk//m zglSWRMXNo7rmYW1g04kE07hpxTEz4BAcDeklR9/2YVWBXhrUxmyAK8pexdiNi/cJxPv n5pm1qnB+s2Gb8ElzVHoQ+GFlETVKUmQnGYMH2SVmnu8vxN3K7mT+j9yFjArsk6LW7qg g43aXbdUNCX5qAqCt8j6LToY0N7UYEGuQefw2KufjIqftNEhbvEUkQglA0hGb9W70k/q fPQw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bFEj2+iIsiM1zDwZscudhnFRAA46sb/GbVSfz1nYa6A=; b=ELxeTftDxhR2JTA+CO0MmeN/op1fxc1MXAfzK1o8ruc01G4/2x4jSMi0xYghiNSbx6 Ehb7AuWMtI34W2WEel2hdIkKY0Fh56PSiQ5ONfaHcsUJ7r2BNJ14l16YAkHCAxaoOAxr g5RBz4YM6HyRaCIQP0LIIoMdGCHd9RbUlxMNoi5l+nKvYpMFgD5/lP84cJFQYBOXkXlp zlHG4+oHTkUROFSjEIFvnHN/YWyDSM2cSJZZBTCZ4qSBp8ybzwKHvPNrfVAgbvFYLg0B t0U6QB14H8tUuch74OWrLB467ZGfbEvX1sHiDW7RpAYybx096N+EzO34Wc0092oGlfVv hs6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=L5z3LqBZ; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t29si1240603edt.211.2021.02.24.05.56.57; Wed, 24 Feb 2021 05:57:30 -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=@kernel.org header.s=k20201202 header.b=L5z3LqBZ; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234085AbhBXNyQ (ORCPT + 99 others); Wed, 24 Feb 2021 08:54:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:58712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235748AbhBXNGK (ORCPT ); Wed, 24 Feb 2021 08:06:10 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 70E4964F85; Wed, 24 Feb 2021 12:54:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1614171249; bh=iIpVXjmK1khzdV4orjjLpnJt1dLWGDzggua7qfkLS6o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L5z3LqBZQ/n73Tzf9vHQ1VcZfxKDDIQBol/ObFm5TI/EcOaJ/jQ1zaxFNnTjFLsUr 7FYCHf2IWodjonjluimc7vqGhdznk6AEOjinJEsRL62ByVhpb0qhh3RiZneZ377s2c d1N5MN+62wpWwgg0LAML6hFkU1hJSGYg0nHTDMxg4arznNTmNl0o7HIlRPMGhin8lk m0k6D4WBO1p51UIx0FnfEv2ZsHLym87N0DPvGlYPuEKcms2vItSDTryivXSmqy6PY3 w9I3wzR1JG8e6Fx9y2WqDZi7NGDMnzoKylYo9c+bXq3k+LXBTqDFbsENtajDqKJwer CRRdhAZ2K33QA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Hans Verkuil , syzbot+42d8c7c3d3e594b34346@syzkaller.appspotmail.com, Mauro Carvalho Chehab , Sasha Levin , linux-media@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 21/40] media: v4l2-ctrls.c: fix shift-out-of-bounds in std_validate Date: Wed, 24 Feb 2021 07:53:21 -0500 Message-Id: <20210224125340.483162-21-sashal@kernel.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20210224125340.483162-1-sashal@kernel.org> References: <20210224125340.483162-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans Verkuil [ Upstream commit 048c96e28674f15c0403deba2104ffba64544a06 ] 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: Sasha Levin --- drivers/media/v4l2-core/v4l2-ctrls.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index cd84dbbf6a890..3fe99519fedfb 100644 --- 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 v4l2_ctrl *ctrl, u32 idx, 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') -- 2.27.0