Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2576079pxb; Mon, 19 Apr 2021 08:46:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz1LSplNQXTI0GWUSNpQWyZx8XuLBgY18xK92tsC1mNcCPs6djLpJ/J1yw07j9tFoKetaHN X-Received: by 2002:a17:907:3f8e:: with SMTP id hr14mr22613721ejc.258.1618847200466; Mon, 19 Apr 2021 08:46:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618847200; cv=none; d=google.com; s=arc-20160816; b=YKF4vv/u9pJK7EkK2CaYumOegSco6qomhJaCMF7Qrg+8q4kod8URirzFPY6uxjtwhN euI4fmyQjthcc+7zpaAxYWoxur0vrvacUVFDyZDcn8ZjnXs7SbHhdGsVFAHs+3XELZIa A+JEBmV8uQwPxCFryOy9Xk4qRGymsfTvrrTCc76NHHo5dbABmilt7hM6NM+ViXwKjKDf dDUKlLwJ7ojNqNKOQW1/3FC/eQTlYGf28X3g7ehnn5ECdrLXD8N0Y80rJ0SNZ7hEPnjm uwB834ksX2EHIohCMzwqdscj+sP7DIGeXHFkUOHFNxn8NdZFQ/O61wq5fGTdhh1t0Hxo nZZg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=sDzVx0nBxE00V5F5iF2O9Xa3xWOBERb4maBRnzkdOGE=; b=kQKFdXUMVb7x9hMVX+qttXCy8miXRpMp5nNb1cgu9yGzynOO2bT/dwuxTUmaCTDPot EU2cLwfX82J9cgjZw4PKzD9+mHNtLTzsH1zIzr6Hd+n1ZgqpZWbyELcmFc7sxjRnsuoJ dNCRulHbAnNyDPI4rFWd0Xetjz4muTm1DqrMyZTrYiM5YJZkl5b9Le0lOqYRLKhm4Eby koZZo+1LTKnr1AB1QyWsHme7O+c9Z+w1+UQFfQJV9jxtGCNipLGn6Y7TG4CGIObfmlg1 NdZ7Zf0W9nlp+hB9ec3LbIhTPVbRAw5ncBvYKfynp1LgXcaik3aXsFhc2FfZ6/QHzU3r wd7Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Qg/EOPOI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a42si15466256edf.438.2021.04.19.08.46.17; Mon, 19 Apr 2021 08:46:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="Qg/EOPOI"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242404AbhDSN2D (ORCPT + 99 others); Mon, 19 Apr 2021 09:28:03 -0400 Received: from mail.kernel.org ([198.145.29.99]:56310 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241330AbhDSNU0 (ORCPT ); Mon, 19 Apr 2021 09:20:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id C3072613CE; Mon, 19 Apr 2021 13:16:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618838179; bh=uTn/P7ShC6ybQpeMSlQSWl7Llh9H4+W/oEmmZDnLqy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Qg/EOPOIDgJjEjXs6WEKn3USFxJKLXLEpQCrbo+zxQ7Nv0pfKLFO/dwUWIQhvtJHA 0VzMqg+NnphQYlRVG7mNfeSqkuNIv7ZFDlHuq3jDWvjZOrEDW68rsXcMWUxX4B0Q/t JoAtFxpXJHPlPNm/EDjwwLAOxp4TmzAQR+wUgkrs= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hristo Venev , "David S. Miller" Subject: [PATCH 5.10 070/103] net: sit: Unregister catch-all devices Date: Mon, 19 Apr 2021 15:06:21 +0200 Message-Id: <20210419130530.225054740@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210419130527.791982064@linuxfoundation.org> References: <20210419130527.791982064@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hristo Venev commit 610f8c0fc8d46e0933955ce13af3d64484a4630a upstream. A sit interface created without a local or a remote address is linked into the `sit_net::tunnels_wc` list of its original namespace. When deleting a network namespace, delete the devices that have been moved. The following script triggers a null pointer dereference if devices linked in a deleted `sit_net` remain: for i in `seq 1 30`; do ip netns add ns-test ip netns exec ns-test ip link add dev veth0 type veth peer veth1 ip netns exec ns-test ip link add dev sit$i type sit dev veth0 ip netns exec ns-test ip link set dev sit$i netns $$ ip netns del ns-test done for i in `seq 1 30`; do ip link del dev sit$i done Fixes: 5e6700b3bf98f ("sit: add support of x-netns") Signed-off-by: Hristo Venev Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- net/ipv6/sit.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/net/ipv6/sit.c +++ b/net/ipv6/sit.c @@ -1867,9 +1867,9 @@ static void __net_exit sit_destroy_tunne if (dev->rtnl_link_ops == &sit_link_ops) unregister_netdevice_queue(dev, head); - for (prio = 1; prio < 4; prio++) { + for (prio = 0; prio < 4; prio++) { int h; - for (h = 0; h < IP6_SIT_HASH_SIZE; h++) { + for (h = 0; h < (prio ? IP6_SIT_HASH_SIZE : 1); h++) { struct ip_tunnel *t; t = rtnl_dereference(sitn->tunnels[prio][h]);