From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796040347; b=Goqi3aEkh12dLZBQeI19hlr7vIyJx1ZcehnbPTnZohlr77jIl6/OQk9eOSYIxQeYWWcp rM4MZmWUfgbjlf4oXy4SIbLEXQjj3iX0qSkmrfGxuueT9iJxu1rIU9OiiJMG5HPb/UrtI pr/6fbHwxkv13uC7Lu1EClNJoQVpt6qAq9p+GXnWjrrxkSe5a4BY/aPqyOxvzE5Yunpmk a0Osznl0Nl+ZJkq9HzWgqf22xDKBb4J5THdhjXC2vXyL3WYJ0K4f9tu310IdbcZj1lfd3 R8C0IgIJ77eysDX1463VTRWqp15yn+xJmLGDQly1FPFoxEDRE5yUC/VMoDQbvn8EODg== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796040347; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Gm-Gg:X-Received:X-Received:Received:Message-ID: Date:MIME-Version:User-Agent:Subject:To:Cc:References: Content-Language:From:In-Reply-To:Content-Type: Content-Transfer-Encoding; bh=WP168u1CkfLLF12lSnuoEhpEkE7y78xGCoLJxcuhonQ=; b=Vkj1CKChvdxw1u1sDDtu3z9H9E01T7MnRjxtvuG//9mJj0tw6dNqnHQdKn5VdICOzLpS uBCQ2DYoVsM5Oidi6+0wEIDxz6alFzAUZREq+Dxxf6p3hns0E2oCgP70Sc2z2zOpEZJN0 5K+JCZoNrhgAE4wiSB127H8RwHhHGn3atllOuyQrWITo56GjeJCekFUa1iPuGI+TI2FO0 H8nI9Gbm0/z6iFFfZIIKSgPh+0IOk07HSTUkHmHTzXUJmzrFjDBGNle7L4OZmJRz+a6Iv +25iAJrdZFvZTL1SdywvqD2m7ohJtiGdiUMWR9eBaAjrauPorCr6e80Ay4G7W3C1cRQ== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MFNDE9Vb; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=AU3XH5e8; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7BDB5606A31C for ; Mon, 30 Nov 2026 12:05:46 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 7BDB5606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=MFNDE9Vb; dkim=pass (2048-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=AU3XH5e8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796040345; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WP168u1CkfLLF12lSnuoEhpEkE7y78xGCoLJxcuhonQ=; b=MFNDE9VbRcE7GO/trzJJrcSpsV9JUbccvg0l4EPFESG9LdDV6FLKs+Ie1oQ7EVNIhVeere 06a3XLZGAPkJEkMKRD7I4Clgey0kdpmCSo+TQflOfkv89rXRhiyVfF3t2Y8LwK6dE3QrUt akv1ZxHe2l3opd2F58SzIBLDviw3iKI= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-493-6ZoAS8r-OsiqiQMY-5ITEw-1; Mon, 30 Nov 2026 12:05:43 +0000 X-MC-Unique: 6ZoAS8r-OsiqiQMY-5ITEw-1 X-Mimecast-MFC-AGG-ID: 6ZoAS8r-OsiqiQMY-5ITEw_1796040342 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-4aa0500c979so6355466f8f.2 for ; Mon, 30 Nov 2026 04:05:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796040342; x=1796645142; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=WP168u1CkfLLF12lSnuoEhpEkE7y78xGCoLJxcuhonQ=; b=AU3XH5e8CUu+g0bNxsOLevjT83B0J1RxZRiBGFl8SaWbCd0Hguud+GTGhQhbTb6/7D SFmi4fETIL6WNa87NE8k2x7jTx9ENAF6phVWgPeGNYMunIP4P3o7Aau8aTfcBZesbCU5 Rku+qwObHuKuBkJa7EF/KuuXoq84n5BW1NOfujyavV6QS6iTmcmPzCEJlbahmRHbsXCO tc4coItt59br3gbhnXpp9Vvkz9vmFbyEdX1OVCNOQUXsBkCWzCfsGTXERxIKhSfabKX0 +9sHvrekmV/THvSZueEnv7LyQpqxf21cKNjZ9hxB6457dPumxhBl5z9xcHutLP5Fm0ik IHQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796040342; x=1796645142; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WP168u1CkfLLF12lSnuoEhpEkE7y78xGCoLJxcuhonQ=; b=0/gb8FIUN7veNEIy4rBsvIVl0y7ooQgDtYO0Ex79YqbGEcQZKAuzH/u2DLMRH7RmbV pxId+k8ijgipyXxNqSRrWQnJekX4miuQtt+8QRyluaatU1nXuPe+QzguyYwn9aaDFwEN Wa/Ltus/QweRsmpotmUypb7yBNkkB4plv+3/glWpTMT9Dzr4gt1pMKYc/Sx01v9Ad3AF HvTzyY1qmb1I9E62M5Yt/E+jwXF1nM2K3MROQHL2S95I3Qs2LNXKQAJWcybN9MUkZFUW GAdfE7SxZXsJLQdjz6soNJwwPI0n2bKOBB9HFVu03Ja4NtNxBAlt5P8BGEUAEkA8z09E VPzw== X-Gm-Message-State: APuU4Z97kjliXBw0e19ct5qLMQBxcSxS2lDOe3pcICyvH0C98SHnlIJK NnwsvN2xuHXx2jYy/uve2VqYMPD9m2vrXYmO03iS3nOgVQFzE8nbsMcs5m/s5ar3pkeYJqfddlU 3Is0Mmcu5b/mpjN4m3r4b6oY/Hzvzi6iiFrW/oHnSer2dpF4+iIBtyJ+Vvg== X-Gm-Gg: AZFdTZeYpobPLAkw5Tx7v5Y6VH+KTXXiJjmnJcm3hhqiK+1lutr6CUjdnIeWd4+gzzA 5MHtFFJ62hGdu/aO6ANAUwwZijbR2J6DOvXyqWGxbIZE2l+CcIcKV6RLudMQorFaIF3nSUN5N0q WK97dMKqNJIwImzYc7QcGieUyDu/9smHG8ut3gVWwGuCYPccUohOrrfj+aVH9R02jiyevc/JiC6 p6UJk5smk9wt2i0aQ1Et7yT2MQt4qAALW/SiRHKDUT1vqcC40oR3p89hcyzOey0YWnx7mbRkjjp 2PBeWpOaIZn6AlqSNn7hX+/dhsKUkpz/iTRufXzKavzxIFbjCj3YnB2124Bt0aP2DwYaOz4LORy /KUahD4D3xoZgM4uYETl1J7luqnWAGgxMdYt0GDUh3bh2LjMFGbVHVBpBdzQ0ltezTfetuh+NHB 8flYDedhdxD6i0ZF7tTBPZCnCMzyy+DmnBmTT8C/e6rgcG X-Received: by 2002:a5d:64c9:0:b0:491:92e5:b5c2 with SMTP id ffacd0b85a97d-4abb1baaaa5mr67006553f8f.15.1796040341789; Mon, 30 Nov 2026 04:05:41 -0800 (PST) X-Received: by 2002:a5d:64c9:0:b0:491:92e5:b5c2 with SMTP id ffacd0b85a97d-4abb1baaaa5mr67006477f8f.15.1796040341194; Mon, 30 Nov 2026 04:05:41 -0800 (PST) Received: from [192.168.88.30] (ip231-128-192-82.pool-bba.aruba.it. [82.192.128.231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6baa3882sm63018009f8f.49.2026.11.30.04.05.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2026 04:05:40 -0800 (PST) Message-ID: Date: Mon, 30 Nov 2026 13:05:39 +0100 X-Mailing-List: netdev@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH net] net: dsa: do not run queued FDB events after the port left the bridge To: Julius Bairaktaris , Andrew Lunn , Vladimir Oltean Cc: netdev@vger.kernel.org, "David S . Miller" , Eric Dumazet , Jakub Kicinski , Willem de Bruijn , Simon Horman , =?UTF-8?Q?Alvin_=C5=A0ipraga?= References: <20261121185821.1471559-1-julius@bairaktaris.de> Content-Language: en-US From: Paolo Abeni In-Reply-To: <20261121185821.1471559-1-julius@bairaktaris.de> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 11/21/26 19:58, Julius Bairaktaris wrote: > FDB events reach DSA from the atomic switchdev notifier and are handled > from dsa_owq. The work builds the dsa_db from dp->bridge, which > dsa_port_bridge_destroy() clears and frees when the port leaves the > bridge or fails to join it. > > When switchdev_bridge_port_offload() fails in the FDB replay of > dsa_port_bridge_join(), because dsa_user_fdb_event() could not allocate > its work item, the entries replayed before the failure are still > queued. The rollback clears dp->bridge, and the queued work dereferences > it: > > KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007] > Workqueue: dsa_ordered dsa_user_switchdev_event_work > RIP: 0010:dsa_port_bridge_host_fdb_add+0x141/0x5c0 > > A bridge leave has the same problem for an event that the notifier > queues after dsa_port_pre_bridge_leave() flushed the workqueue: nothing > orders the dp->bridge check in dsa_user_fdb_event() against the clear, > and on a switch unbind the work can also run after dsa_user_destroy() > freed the port's net_device. The notifier and the taggers read > dp->bridge->dev and ->num without locks while the bridge is freed. > > Clear dp->bridge, wait for those readers with synchronize_net(), flush > the workqueue, and only then free the bridge. The work reads dp->bridge > once and drops the event when the port has left; the FDB helpers take > the bridge from it. The join rollback destroys the bridge before it > tells the switches that the port left, as dsa_port_bridge_leave() does, > so a dropped event programs nothing after that. > dsa_port_bridge_dev_get() and dsa_port_bridge_num_get() read the pointer > once, and dsa_port_bridge_create() publishes it with > smp_store_release(), so a reader that sees it also sees its fields. It's totally unclear to me in-flight notifications can't acquire a reference to the bridge. /P