From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f44.google.com (mail-wr1-f44.google.com [209.85.221.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C0466367F3B for ; Sun, 22 Mar 2026 23:08:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774220941; cv=none; b=YlLnsjVp2PB4BwcurAZyWpn6fOAcXp21NhCsAW+3+XsNPFd8ChUC3XE3GKf+F+LXLq1n4bp0CQxhG4QUjWSmUoyEljBCqsuQa85OKZWhyMY5gNTo8fV58e0m8sdp0KuG1L5E9ekOmxgvO1RdzBDPxnXNR2/HrlRcnhPxGI/RTeg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774220941; c=relaxed/simple; bh=ln1FsL8a/sjtX9+cnCkUgpaW92A41rQNplN1E9B+3HQ=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=NYKZjod294FI3rIdcmGHSe7owntxu/dPWnM423a7QLPd9oce/+nCtLlWWBAyGY0TO9shfsH3p2ai4oufQoLKeWKyZYviNGO3D1UONGfy16DCZKosgZ1oyU8uzdEYcGEudDatiKSXWhCQ8/F5gdOA0RMxHs92oyjrKlBjJoMMomw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.221.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wr1-f44.google.com with SMTP id ffacd0b85a97d-439b6d9c981so2457008f8f.1 for ; Sun, 22 Mar 2026 16:08:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774220938; x=1774825738; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:reply-to:user-agent:mime-version:date :message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mKjk90zLlJLtFb5uv6zbpADQTbtU71ATu76Om9DzCMA=; b=FPKIkg34ztu0mPQAtflYazK8BQY9kQ879OFNMtZrCeVWiuFyFUou2iVWNVtKjR6eQK tQQgdeJ8/8DYgSDTjYRhlbV7YbJCn8Q6b9gso3vVgodPj9W5ox9V5MPk78pcmulNnyfb 0+K0NbRzSaHDfU0/bHhRzjn78Q3UqN4az+mlyE80BwilVge56HVJ4NsKmKrkBWjH8+Qg HU5m+Sa1HDsx2fxn4bFNaRe5GmwSG7OoZFsDhcGSEyQKRG+VtFC7GUaor1CFGGs5fp4O 3Z0g9wvyaxDNzC0Q1ykMXJt7Z1cp0/oe52JvPfk3WwYPmbP9tNl5pr4b0RMAGu1+dEZB kyLw== X-Forwarded-Encrypted: i=1; AJvYcCVj8D7vZ16OeRzvOpmj8quslcArbHHBJtPzufP6HZvqWu22AfaFl4r4tmnpd+gbL/UkW9D/Nn6BRAwEs8g=@vger.kernel.org X-Gm-Message-State: AOJu0YzVLgVWXSWiQP5YwhZ0flXySBHKDMkgEu9uYHQgAuVCAuc30Qjv 7XxF2sFn2MFDVdZjuKaQplCOqNDnH9EJBOV8xitF7sSoJ+QzZwr9Bq8d X-Gm-Gg: ATEYQzzMVokwzaf+1jjN+EnK9JmjMOem5SYlOmmu5WEYl+gdpjJ4KC8eO1SGcF943Ob rg4NVdZcpVwWyzLTjdw2uJ4ex9kdnAZsiMoyM/zyZgNRUr3hLV4ZE45BxMpit33yY8pGYu/wpiD vfSxoxbqvzfs2Ccj9yikvh/V/zafkFcMGxz6jNyuL7kevHyrpELwdMXuJmGlTPbKLty7tpmFgSq 9cSXqQvjjc2PukK1jDrOusXsXSZlyGI4BU1kepGpkGKPuQnUEZKaNLeB9UAcR3t5NAlyIfiIEfu LrKSgYCsOS2FgvreoBS2UBaN7uWpHXNhe+n/6a7eNhs1y1wHv4HZBs9o6enN+niVyNRu/5xNUaW CbEnFosiZVqtIS92MG4c24MwmBnIXI/WOkGi8LR1Wuy2PUX8MTqaUnVxwXk838BIczMSFpvFHyD HUCapbLg/oxs2LbowxXXc= X-Received: by 2002:a05:6000:26d0:b0:43b:4312:2cbb with SMTP id ffacd0b85a97d-43b64272a9dmr17016793f8f.17.1774220937931; Sun, 22 Mar 2026 16:08:57 -0700 (PDT) Received: from [0.0.0.0] ([94.156.174.93]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-43b64703c27sm25191072f8f.18.2026.03.22.16.08.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Mar 2026 16:08:57 -0700 (PDT) Message-ID: Date: Mon, 23 Mar 2026 02:08:53 +0300 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Reply-To: alex.popov@linux.com Subject: Re: [PATCH] ethtool: don't touch the parent device of a net device being unregistered To: Andrew Lunn Cc: Jakub Kicinski , David Miller , Eric Dumazet , Paolo Abeni , Simon Horman , Maxime Chevallier , Michal Kubecek , Gal Pressman , Kory Maincent , Oleksij Rempel , Ido Schimmel , Heiner Kallweit , Greg KH , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, security@kernel.org, notify@kernel.org References: <20260322075917.254874-1-alex.popov@linux.com> <3c07c51a-421b-456f-9819-9021ddd7b22e@lunn.ch> Content-Language: en-US From: Alexander Popov In-Reply-To: <3c07c51a-421b-456f-9819-9021ddd7b22e@lunn.ch> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 3/22/26 17:39, Andrew Lunn wrote: > On Sun, Mar 22, 2026 at 10:59:15AM +0300, Alexander Popov wrote: >> The ethtool operations may be performed on a net device that is currently >> being unregistered. This is also described in the commit dde91ccfa25fd58f >> ("ethtool: do not perform operations on net devices being unregistered"). >> Moreover, such a device may have a parent that has already been freed. > > I don't know the device core too well, but can you explain in the > example stack trace you gave how the parent can already be free? I > would of expected devices are arranged in a tree, and free happens > from the leaves towards the root? In order to do a clean shutdown, you > might need to perform operations on the parent. > > I just want to make sure this is not a broken parent device which > should be fixed... Hello Andrew, let me describe the scenario that I see: - The netdev_run_todo() function handles the net devices in net_todo_list in a loop and moves each of them into the NETREG_UNREGISTERED state: netdev_lock(dev); WRITE_ONCE(dev->reg_state, NETREG_UNREGISTERED); netdev_unlock(dev); - Then netdev_run_todo() frees these net devices in another loop. On each iteration, it chooses a device for freeing: dev = netdev_wait_allrefs_any(&list); - At the same time, the ethnl_set_features() function calls ethnl_parse_header_dev_get() for the child net device. - If the race condition succeeds, ethnl_set_features() takes the reference to the child net device being unregistered. That makes netdev_run_todo() free the parent first. Best regards, Alexander