From patchwork Wed Aug 29 14:49:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10580439 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 36E4F14BD for ; Wed, 29 Aug 2018 14:49:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2632F2B40A for ; Wed, 29 Aug 2018 14:49:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 180942B419; Wed, 29 Aug 2018 14:49:45 +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 ACDDA2B40A for ; Wed, 29 Aug 2018 14:49:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728054AbeH2SrA (ORCPT ); Wed, 29 Aug 2018 14:47:00 -0400 Received: from userp2120.oracle.com ([156.151.31.85]:35022 "EHLO userp2120.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727537AbeH2SrA (ORCPT ); Wed, 29 Aug 2018 14:47:00 -0400 Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7TEn3hk192149; Wed, 29 Aug 2018 14:49:34 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=NMHEfqDmjuwClUZV3BHremTsRyiC5dTFIHgb6+3Yk3c=; b=K8j6PjU6exG9u2jkG7fyUaG4NJjMFd0IJfoVISSWi2HufH63fD7rFjLi92bqHEpE5XJd 6tAs0gJ6S+CPVkFjJitOdQ/A8aUZjVDdR7QeJRM9YYquzGkUZVUDRLAKLKUCpdcWSgv9 G/2jqShCtE2TlsgD2/JBmVFMuMSVMRjoRjF2nW8rlqW9hJyzh3hMs78pxIO9Eix2+F9h Qlt8FJp+4gz2mqhdQuDZmzBFj+6Lybn/ufqQgF4LUQbHVyWGjuSw9nd3+1LlT3WGLs3d zgFo+0x2eXWqhlFcEk+X49QdFIIftnGfa6KasDoiemk24SU77cKVH65j0lhsOtajNIKt Zg== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2120.oracle.com with ESMTP id 2m2yrqa5h6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Aug 2018 14:49:34 +0000 Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7TEnWHI019903 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 29 Aug 2018 14:49:32 GMT Received: from abhmp0003.oracle.com (abhmp0003.oracle.com [141.146.116.9]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7TEnVqc000531; Wed, 29 Aug 2018 14:49:31 GMT Received: from kili.mountain (/197.232.248.111) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Wed, 29 Aug 2018 07:49:31 -0700 Date: Wed, 29 Aug 2018 17:49:23 +0300 From: Dan Carpenter To: Xue Liu Cc: Alexander Aring , Stefan Schmidt , "David S. Miller" , linux-wpan@vger.kernel.org, netdev@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: [PATCH] ieee802154: mcr20a: read out of bounds in mcr20a_set_channel() Message-ID: <20180829144923.6p2omsbe2s343wea@kili.mountain> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170113 (1.7.2) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=9000 signatures=668708 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=645 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808290157 Sender: linux-wpan-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wpan@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The "channel" variable can be any u8 value. We need to make sure we don't read outside of the PLL_INT[] or PLL_FRAC[] arrays. Fixes: 8c6ad9cc5157 ("ieee802154: Add NXP MCR20A IEEE 802.15.4 transceiver driver") Signed-off-by: Dan Carpenter --- This patch is obviously harmless, but it's from static analysis. I'm pretty sure this is required, but I can't swear. diff --git a/drivers/net/ieee802154/mcr20a.c b/drivers/net/ieee802154/mcr20a.c index e428277781ac..4f41d1d3588e 100644 --- a/drivers/net/ieee802154/mcr20a.c +++ b/drivers/net/ieee802154/mcr20a.c @@ -512,6 +512,9 @@ mcr20a_set_channel(struct ieee802154_hw *hw, u8 page, u8 channel) dev_dbg(printdev(lp), "%s\n", __func__); + if (channel < 11 || channel - 11 >= ARRAY_SIZE(PLL_INT)) + return -EINVAL; + /* freqency = ((PLL_INT+64) + (PLL_FRAC/65536)) * 32 MHz */ ret = regmap_write(lp->regmap_dar, DAR_PLL_INT0, PLL_INT[channel - 11]); if (ret)