From patchwork Thu Nov 29 22:38:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 10705467 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 450EA13AD for ; Thu, 29 Nov 2018 22:38:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 260332F74D for ; Thu, 29 Nov 2018 22:38:50 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 150722F75E; Thu, 29 Nov 2018 22:38:50 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 8A5AB2F751 for ; Thu, 29 Nov 2018 22:38:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726406AbeK3Jpw (ORCPT ); Fri, 30 Nov 2018 04:45:52 -0500 Received: from mail-io1-f67.google.com ([209.85.166.67]:35739 "EHLO mail-io1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeK3Jpv (ORCPT ); Fri, 30 Nov 2018 04:45:51 -0500 Received: by mail-io1-f67.google.com with SMTP id u19so2983246ioc.2 for ; Thu, 29 Nov 2018 14:38:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mojatatu-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=TbhNgtyQ8+9RLyIyVzgqN8PScTyoohCQ50PG+G2H7vY=; b=B4QyYlyGfXBIGoZ5gGEwMusbzGM5Kp+8VMTcnSlOnZZwZQoRzkRMkBVFtOPxCKGs2r 299bJHXJG1EsXwSq8MKrSUH0OOCBKVz+73OJn7xkUcbYWoapx/YccR1n+pFN7HRnw8u6 xoBiMVWDq47YRk4jK1dGg+Nt8a0IxjZZXokAOFfg+c5AgdKZUH6qgda8IKpkTOatjFO7 yc6Dm9kpCnMSmXkmDW81OoJWva61AhZ8sRu5FdLknk4BQ9V6eyo+v/qAj2wU7Ba0D0S7 pmDLyLi8kjz/Yk+cXdABYGeq9+QWELe4E+/oDHr5pwj7TWhBn2tI09RyaTqDMLOjnOVX 4/wA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=TbhNgtyQ8+9RLyIyVzgqN8PScTyoohCQ50PG+G2H7vY=; b=h32x0fGidsEx+j6HMjAtQ1Jg8UewTUYV9lcEY0vc0l7Mn9WgXp2SvfVGtqllbO2kxl vwEXs9eppsydh7p93wCYrjiHv+KJ6R/2AHqBrACDN56gOOWhi0Fh9sx+omUnskLKBUDt ElH/NvX6q0Dv2L595vRV6PilMxdxz4H9mrCpxa/JTSy8jkNKgCDV5kT6GW3ytsEcAMj/ /aikZzk7F8pHekrSK+gBWaVofVOAjtzP9kt1AJ/WJCZMxhV1OMEhiPJUzbMEyveGsAY5 91fQg9Bl5Yn6PQEKFr0AoSMMN3iS/v1doKoYwikz7LqHO2a6ZRuRIyRAYRHSMlWeO9qG pr6A== X-Gm-Message-State: AA+aEWbac8z3WuGVQB7ht4bYMTRVMUfeYUBpEhmT1RY+ae1TuubFBDjM CpKyu1ev9WMlhATZkwDi7HRyUzB93oU= X-Google-Smtp-Source: AFSGD/VuXklkJYi+Z052vqb9t+uWWpIvHNdpsNDKjnNPyWSqS4PACUMOB3k3YaievYbt2vuVSGcBQg== X-Received: by 2002:a6b:3b47:: with SMTP id i68mr2797049ioa.133.1543531127426; Thu, 29 Nov 2018 14:38:47 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id 134sm2177193itl.25.2018.11.29.14.38.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:38:46 -0800 (PST) From: Alexander Aring To: stefan@datenfreihafen.org Cc: linux-wpan@vger.kernel.org, Alexander Aring Subject: [PATCH wpan] ieee802154: hwsim: fix off-by-one in parse nested Date: Thu, 29 Nov 2018 17:38:37 -0500 Message-Id: <20181129223837.6719-1-aring@mojatatu.com> X-Mailer: git-send-email 2.11.0 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 This patch fixes a off-by-one mistake in nla_parse_nested() functions of mac802154_hwsim driver. I had to enabled stack protector so I was able to reproduce it. Reference: https://github.com/linux-wpan/wpan-tools/issues/17 Signed-off-by: Alexander Aring --- drivers/net/ieee802154/mac802154_hwsim.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index bf70ab892e69..fbcbf55ce744 100644 --- a/drivers/net/ieee802154/mac802154_hwsim.c +++ b/drivers/net/ieee802154/mac802154_hwsim.c @@ -500,7 +500,7 @@ static int hwsim_del_edge_nl(struct sk_buff *msg, struct genl_info *info) !info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE]) return -EINVAL; - if (nla_parse_nested(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX + 1, + if (nla_parse_nested(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL)) return -EINVAL; @@ -543,6 +543,7 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) struct hwsim_edge_info *einfo; struct hwsim_phy *phy_v0; struct hwsim_edge *e; + u32 v0, v1; u8 lqi; @@ -550,7 +551,7 @@ static int hwsim_set_edge_lqi(struct sk_buff *msg, struct genl_info *info) !info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE]) return -EINVAL; - if (nla_parse_nested(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX + 1, + if (nla_parse_nested(edge_attrs, MAC802154_HWSIM_EDGE_ATTR_MAX, info->attrs[MAC802154_HWSIM_ATTR_RADIO_EDGE], hwsim_edge_policy, NULL)) return -EINVAL;