From patchwork Mon Mar 25 09:06:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10868437 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0B3C715AC for ; Mon, 25 Mar 2019 09:07:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id EB5BB28D90 for ; Mon, 25 Mar 2019 09:07:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DE87D29201; Mon, 25 Mar 2019 09:07:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 876F828D90 for ; Mon, 25 Mar 2019 09:07:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730056AbfCYJGz (ORCPT ); Mon, 25 Mar 2019 05:06:55 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:37266 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726234AbfCYJGz (ORCPT ); Mon, 25 Mar 2019 05:06:55 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x2P93ooJ174359; Mon, 25 Mar 2019 09:06:40 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2018-07-02; bh=tcUOz38CHAyh1zhyScSlBPE5IT3rCmUdRz4pftL3T4Y=; b=yJXaErzKwgEQrpwOBNmAzVaB7t/zPsmn0+ZpKsf5eqQgsXesrjJKRMA1EgTivVgBi3wA mihGsxOihgtdnJVvvtlelJ1hOp7Hc/jFWVttm1k1Y+qooCORKmaTqYCKhFwVEVvvr035 kFsJwocKHT765YkR/aoTYJyTLAKGEXOcEWiw48pFMvSV+qfpoLVwP+xvXHxvLyXNOiVV vasnflfDZ3cmieGS7OdQIp/Yd5H2xokrnq9gAVDL3gBxZeQr19lh6DBEzZuBhM2qiSzU LEpkS1+Rs71bLaYJ+ntYYg1Ugpm51QNT4SxNprYcIUHffMwpftkAlLt7H3if4fMs6r9S 0Q== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2re6g0truy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Mar 2019 09:06:40 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id x2P96e4w023330 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 25 Mar 2019 09:06:40 GMT Received: from abhmp0001.oracle.com (abhmp0001.oracle.com [141.146.116.7]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id x2P96b5h007419; Mon, 25 Mar 2019 09:06:37 GMT Received: from kadam (/197.157.34.176) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 25 Mar 2019 02:06:36 -0700 Date: Mon, 25 Mar 2019 12:06:26 +0300 From: Dan Carpenter To: Mauro Carvalho Chehab Cc: Hans Verkuil , Sakari Ailus , Paul Kocialkowski , Tomasz Figa , Philipp Zabel , Keiichi Watanabe , Smitha T Murthy , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] media: v4l2-ctrl: potential shift wrapping bugs Message-ID: <20190325090626.GC16023@kadam> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: Mutt/1.9.4 (2018-02-28) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9205 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1810050000 definitions=main-1903250069 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This code generates a static checker warning: drivers/media/v4l2-core/v4l2-ctrls.c:2921 v4l2_querymenu() warn: should '(1 << i)' be a 64 bit type? The problem is that "ctrl->menu_skip_mask" is a u64 and we're only testing the lower 32 bits. Signed-off-by: Dan Carpenter Reviewed-by: Sakari Ailus --- drivers/media/v4l2-core/v4l2-ctrls.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/v4l2-core/v4l2-ctrls.c b/drivers/media/v4l2-core/v4l2-ctrls.c index b79d3bbd8350..cee78485df02 100644 --- a/drivers/media/v4l2-core/v4l2-ctrls.c +++ b/drivers/media/v4l2-core/v4l2-ctrls.c @@ -1599,7 +1599,7 @@ 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 & (1 << ptr.p_s32[idx])) + if (ctrl->menu_skip_mask & (1ULL << ptr.p_s32[idx])) return -EINVAL; if (ctrl->type == V4L2_CTRL_TYPE_MENU && ctrl->qmenu[ptr.p_s32[idx]][0] == '\0') @@ -2918,7 +2918,7 @@ int v4l2_querymenu(struct v4l2_ctrl_handler *hdl, struct v4l2_querymenu *qm) return -EINVAL; /* Use mask to see if this menu item should be skipped */ - if (ctrl->menu_skip_mask & (1 << i)) + if (ctrl->menu_skip_mask & (1ULL << i)) return -EINVAL; /* Empty menu items should also be skipped */ if (ctrl->type == V4L2_CTRL_TYPE_MENU) {