Received: by 10.213.65.68 with SMTP id h4csp1796923imn; Thu, 29 Mar 2018 11:11:50 -0700 (PDT) X-Google-Smtp-Source: AIpwx4/E+7zH84/d49d+zzX42OSj35DMQWcgPL6YO1DgMwVVfvxkj0ghXpqat1wdQudlx6lggk9s X-Received: by 2002:a17:902:2be4:: with SMTP id l91-v6mr9658927plb.102.1522347110570; Thu, 29 Mar 2018 11:11:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1522347110; cv=none; d=google.com; s=arc-20160816; b=WhwxW/GH3Jjk8Wsfj1mY8UYq6MHwiFKubx5kXqYEnE3MMw6PyWDJSA8nYOykim3HkM wetFEbDj9zP4tFo5sdgCIGsXPv6OidO9QTh6OZuEPis2bC1w/JI+ejAPdj+HvJiirVb1 d3kg86aXPdIDHEHXOkXGHSKrGiTC/VsQwb2lmL+kZo/8/WXhCxaGr5La/hUrlmnZ8oY7 kLfQMO7j8HhPhnQ4Z/LrxUAqwtVLp3ivjJX/g+UKEzF5iWd7XiDC1SCcefvP2yR7sy+S TC60FWGa40XXJdZKN4p6N6Ncof2Dy8nfliVogUnESoFE2gXDmwKvou0315DXW9oMNvsI cfzQ== 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=2P/xCYN6wF28rs+vopHIGf5Cw1vd+JPcOveDbiGUNlM=; b=HBtu+h8FNJOtW1w3XwaVGgVFrSXB2WvYWpuuIwCatbWZ6P9qNv0anzLxOUhMaD8Nfk zss6QzStmcex8xa67thRnX2g2RQTuGWGERny2X7lQKUGBFYV4pQxMs1lOs+8pP5K/XRm wJ9XoH1hrLzfU7KEvqOR8KzqDYdLkWBNzB4WvNpN5S1dMTjJcXCmOZBSjS4HdsgTqHnK jvYY/zerpvSxIZ/KQfwlRP88Tn3DhoKxjxyX+UtiFJlFibb79Qd9plnbKbAzFuuz9Xzr C7lL2diZ8MBLtikzXiywUUNwpZn+dD55WSGMGpjwEKnb/t92PCIOX4DCx+M0UFTz7DU3 2wwQ== 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 d128si4790141pfc.83.2018.03.29.11.11.36; Thu, 29 Mar 2018 11:11:50 -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 S1754286AbeC2SIX (ORCPT + 99 others); Thu, 29 Mar 2018 14:08:23 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:60602 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754251AbeC2SIW (ORCPT ); Thu, 29 Mar 2018 14:08:22 -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 91864B00; Thu, 29 Mar 2018 18:08:21 +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.4 18/20] ieee802154: 6lowpan: fix possible NULL deref in lowpan_device_event() Date: Thu, 29 Mar 2018 20:00:54 +0200 Message-Id: <20180329175742.805429429@linuxfoundation.org> X-Mailer: git-send-email 2.16.3 In-Reply-To: <20180329175741.886181131@linuxfoundation.org> References: <20180329175741.886181131@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.4-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) goto out; 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: break;