From patchwork Thu Nov 29 22:41:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Aring X-Patchwork-Id: 10705469 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 870C0109C for ; Thu, 29 Nov 2018 22:42:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 772EE2FA84 for ; Thu, 29 Nov 2018 22:42:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6BF0A2FB63; Thu, 29 Nov 2018 22:42:03 +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 03A482FA84 for ; Thu, 29 Nov 2018 22:42:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726955AbeK3JtF (ORCPT ); Fri, 30 Nov 2018 04:49:05 -0500 Received: from mail-it1-f173.google.com ([209.85.166.173]:56319 "EHLO mail-it1-f173.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726393AbeK3JtF (ORCPT ); Fri, 30 Nov 2018 04:49:05 -0500 Received: by mail-it1-f173.google.com with SMTP id o19so6306533itg.5 for ; Thu, 29 Nov 2018 14:42:01 -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=N9Z2k2cpjaC3Areq7sgUuHjMqBdwx//R/12jpIpKehk=; b=KM4O2D86uufflEMNcbQ1ZKXBFbfo7DzwQFiIUfl8AczZeVpXhZZO/ki3c1gkIFu7Jc gyJADao3WN5kJYa0mFhkf7i4dvHQx5I0MVeiqHVjoM9Gc+H0qU4yt7ngDl41TQycRAvn 3uXprxV5wtF01xxoazuQHrSMJqZmRtyNhcSqFnnCF7kKVAp8VJNsvXmIt/AiEtq9Q3LR UsUeAuUBmhzNDZGBh3SNHNDPWOias9USaA+6p+kiVU7D9hYPYa2Xl2FcnkUZQLapJUCe WsDlfgxd+KgacdfUKtnbaOVx0Hr8GdjQK4vAPfc11FizpeaY6QZLyLvwZJHbHKPQ/Acn MKsw== 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=N9Z2k2cpjaC3Areq7sgUuHjMqBdwx//R/12jpIpKehk=; b=MWv674ZloDbgFLTV/qAz3Um4FXWn+9MZd7fa5rfaysstCl34rTbudGLyAhJpmpRNE3 6YuvfWH+BHq9RfvCUpswBYR/DAFtxXIuXroOD1c+peRRnbwV8fj8/2E2uIrYmQggEraq r+pfUHEew23Fs8tJZAiHS4mqbtLxiOVLwFonP4abCuvQhGoe39IBLyLbuUZ78bYEaZTL OIlwr5rtFLwjD69mU+QVPLr3dEaTaV7zlUxs4y7bHpb7/UHhLU51U5WkbfszV4NumgjV GcW3f3p/XUwYz3IprIAaup8Jk6GAcpCes53dp3E+mkchHWeHzug/LAwQwcbhz+EFZcI9 aQmg== X-Gm-Message-State: AA+aEWaWVDwcgkNH5NHEztg1zkznENwrtPOXevvgzu5uaMvdAffcfjQK /tzFILhyoAIbZnjMJHwd9Kazyg== X-Google-Smtp-Source: AFSGD/V8qn4YOG5/iQBF+S9Nn+fP0Chx05DAG5G8sJ/7ZRiUSAYcATnTAZTHrr0mOLycsIqFK47i6A== X-Received: by 2002:a02:89dd:: with SMTP id e29mr3203871jak.21.1543531320803; Thu, 29 Nov 2018 14:42:00 -0800 (PST) Received: from x220t.lan ([64.26.149.125]) by smtp.gmail.com with ESMTPSA id x99sm1620942ita.23.2018.11.29.14.42.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 14:42:00 -0800 (PST) From: Alexander Aring To: stefan@datenfreihafen.org Cc: linux-wpan@vger.kernel.org, Alexander Aring Subject: [PATCHv2 wpan] ieee802154: hwsim: fix off-by-one in parse nested Date: Thu, 29 Nov 2018 17:41:54 -0500 Message-Id: <20181129224154.7525-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 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ieee802154/mac802154_hwsim.c b/drivers/net/ieee802154/mac802154_hwsim.c index bf70ab892e69..624bff4d3636 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; @@ -550,7 +550,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;