Received: by 10.213.65.68 with SMTP id h4csp1821822imn; Thu, 29 Mar 2018 11:40:09 -0700 (PDT) X-Google-Smtp-Source: AIpwx49kT0u7hM5o2D9PEMpY8zF5jxC/F/nUj9WvviYslV3UtaaO5p0aGVQGV584kX3D7L4bpaLL X-Received: by 10.101.98.90 with SMTP id q26mr6445981pgv.113.1522348809447; Thu, 29 Mar 2018 11:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522348809; cv=none; d=google.com; s=arc-20160816; b=sM0KIdzUpejDuAPEFjQvaQi/c6iZsgk7Kyo7nx8oOXKtg4lL9QsrL5g6O2z/hfHOBZ hMqpI1W+0A6VOKviyA9rRl8tmNeEkM2/95NmFK25LJCJ/n/oCc5xwbOfgMRogtus0Xdn 7u8CjYyiWhqKJr4crLz/cKKz/hkPzef+po1pr4rk5dkpBnUMh48dSXkx0FA+5JY6bUkd q1w5o4cwJ3jbrvdjhSe5k+HxfB3YFmuIYz7vrNicutOWNvH7mBgoh/PzGom1UqMwrdbd oEct+ijuVnTjxk5kHmuMH6esVRa/uZEqI1eIgFkGEvAbduJCt/tJPZ8fR4qrP51ZOK/e GzWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=RsS+ua/PD6UVtEVAm/0n4qeTIV29slW+4RnSwBEwz/w=; b=tTHvG7fq/VjX9K3d9s9QUUEVcW/9klQqMXJ4PiGGPO+cToYy5tSrJMTH+KQO3xSWpc hJmsdoxFxOF+z6O05476liiPMU6l3JFkrggwfNrrHerOTPTFB6wKCgdVRauDVkqxVjo7 MDheVOss7EDKuKspaPS/6eJTMhMCq+DOe0J96zA2mQjuEHFG2xFEQVMFtumVi7RWyO+F sy1qURiDpLT2b54zd8fHQ69GkW2JqguPQPwyFDAWzVw3ZLNdP2ggjR04qVeA5TRDGlv8 gtJ3mPl0wdLn6slhVOMJag1j17PYWEjwwOgERFRrjruNDZLQJetDMbxTk1ZkxZKJppoW N9Ng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2-v6si6301894plh.121.2018.03.29.11.39.55; Thu, 29 Mar 2018 11:40:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752730AbeC2Sio (ORCPT + 99 others); Thu, 29 Mar 2018 14:38:44 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:58218 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752613AbeC2SC0 (ORCPT ); Thu, 29 Mar 2018 14:02:26 -0400 Received: from localhost (LFbn-1-12247-202.w90-92.abo.wanadoo.fr [90.92.61.202]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 65B49C13; Thu, 29 Mar 2018 18:02:25 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Dumazet , Alexander Aring , Stefan Schmidt , syzbot , "David S. Miller" Subject: [PATCH 4.15 23/47] ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event() Date: Thu, 29 Mar 2018 20:00:04 +0200 Message-Id: <20180329175730.973977320@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175729.225211114@linuxfoundation.org> References: <20180329175729.225211114@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Dumazet [ Upstream commit ca0edb131bdf1e6beaeb2b8289fd6b374b74147d ] A tun device type can trivially be set to arbitrary value using TUNSETLINK ioctl(). Therefore, lowpan_device_event() must really check that ieee802154_ptr is not NULL. Fixes: 2c88b5283f60d ("ieee802154: 6lowpan: remove check on null") Signed-off-by: Eric Dumazet Cc: Alexander Aring Cc: Stefan Schmidt Reported-by: syzbot Acked-by: Stefan Schmidt Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ieee802154/6lowpan/core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) --- a/net/ieee802154/6lowpan/core.c +++ b/net/ieee802154/6lowpan/core.c @@ -206,9 +206,13 @@ static inline void lowpan_netlink_fini(v static int lowpan_device_event(struct notifier_block *unused, unsigned long event, void *ptr) { - struct net_device *wdev = netdev_notifier_info_to_dev(ptr); + struct net_device *ndev = netdev_notifier_info_to_dev(ptr); + struct wpan_dev *wpan_dev; - if (wdev->type != ARPHRD_IEEE802154) + if (ndev->type != ARPHRD_IEEE802154) + return NOTIFY_DONE; + wpan_dev = ndev->ieee802154_ptr; + if (!wpan_dev) return NOTIFY_DONE; switch (event) { @@ -217,8 +221,8 @@ static int lowpan_device_event(struct no * also delete possible lowpan interfaces which belongs * to the wpan interface. */ - if (wdev->ieee802154_ptr->lowpan_dev) - lowpan_dellink(wdev->ieee802154_ptr->lowpan_dev, NULL); + if (wpan_dev->lowpan_dev) + lowpan_dellink(wpan_dev->lowpan_dev, NULL); break; default: return NOTIFY_DONE;