Netdev List
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Breno Leitao <leitao@debian.org>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Simon Horman <horms@kernel.org>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Cc: netdev@vger.kernel.org, asantostc@gmail.com, gustavold@gmail.com,
	linux-kernel@vger.kernel.org, kernel-team@meta.com
Subject: Re: [PATCH net-next v2 0/8] netconsole: stop charging netpoll users for netconsole-only data
Date: Thu, 9 Jul 2026 12:20:24 +0200	[thread overview]
Message-ID: <1bfad1f6-6947-47a4-9dc0-72b4c16fc395@redhat.com> (raw)
In-Reply-To: <akuUkNgyjVOTHMuz@gmail.com>

On 7/6/26 1:55 PM, Breno Leitao wrote:
> On Thu, Jul 02, 2026 at 05:19:44AM -0700, Breno Leitao wrote:
>> This work continue to untangle netconsole and netpoll, improving
>> memory usage for netpoll users that are not netconsole.
> 
> Quick follow up on the sashiko findings. most of them are assuming that
> netconsole_write is called locklelly, which is not the case, except
> on panic (CON_NBCON_ATOMIC_UNSAFE). 
> 
> 
> There are in order as they appear in
> https://sashiko.dev/#/patchset/20260702-netconsole_move_more-v2-0-1ebedd921dcb%40debian.org
> 
> Tl;DR: There are two pre-existing issue that I will get fixed, but
> I don't think they are blockers for this series (IMO).
> 
> Details of the findings and analyzes:
> 
> 1) This isn't a bug introduced by this patch, but is it safe to modify
>    target_list using standard list primitives while netconsole_write()
>    iterates over it locklessly?
> 
> netconsole_write() is never called without the lock, unless on
> emergency, which is known to be unsafe (CON_NBCON_ATOMIC_UNSAFE).
> 
> Sashiko doesn't undersatnd that nbcon .device_lock
> (netconsole_device_lock), is called before netconsole_write
> 
> 2) This is a pre-existing issue, but I noticed a potential race
>    condition between netdevice events and configfs rmdir that skips
>    cleanup. If netconsole_netdev_event() processes NETDEV_RELEASE or
>    NETDEV_JOIN, it sets nt->state = STATE_DISABLED and moves the target
>    to target_cleanup_list:
> 
> This is a pre-existing issue, and I am happy to fix in here or as
> a follow-up
> 
> 
> 3) This isn't a bug introduced by this patch, but I found a potential
>    lockless iteration race in netconsole_write() in this file.
> 
> Again, netconsole_write() is not called locklelssly. 
> 
> 
> 4) This is a pre-existing issue, but does lockless iteration of
>    target_list in netconsole_write() race with non-RCU list
>    modifications?
> 
> Same as above.
> 
> 5) This is a pre-existing issue, but is there a race condition between
>    interface disablement and configfs removal that skips cleanup?
> 
> This is a pre-existing issue, and I am happy to fix in here or as
> a follow-up.
> 
> 6) This is a pre-existing issue, but does skb_dequeue() acquire
>    a spinlock_t in NMI contexts?
> 
> netconsole is not used on NMI contexts, unless on emergency
> (CON_NBCON_ATOMIC_UNSAFE).
> 
> 7) When netconsole_write() is called as an atomic console callback, it
>    iterates target_list locklessly. Concurrently, if a privileged user
>    removes the target via configfs:
> 
> netconsole_write() is only called on atomic context on emergencies.
> There is no conflict with configfs.
> 
> 8) This isn't a bug introduced by this patch, but could the lockless
>    iteration of target_list in netconsole_write() race with list
>    removal? In drivers/net/netconsole.c:netconsole_write():
> 
> Same as above, netconsole_write() are not called locklessly except on
> ops.
I think you forgot the following comment, which is BTW the only not
clearly marked as a pre-existing one.

Still looks like a pre-existing problem to me.

---
> @@ -335,17 +340,15 @@ static void refill_skbs_work_handler(struct work_struct *work)
>  static void netconsole_skb_pool_init(struct netconsole_target *nt)
>  {
> -	skb_queue_head_init(&nt->np.skb_pool);
> -	INIT_WORK(&nt->np.refill_wq, refill_skbs_work_handler);
> -	refill_skbs(&nt->np);
> +	skb_queue_head_init(&nt->skb_pool);
> +	INIT_WORK(&nt->refill_wq, refill_skbs_work_handler);
> +	refill_skbs(nt);
>  }
Can this race with target teardown?
If a network device linked to a deactivated target is unregistered, it queues
the target on target_cleanup_list and schedules
netconsole_process_cleanups_core(), which executes netconsole_skb_pool_flush()
under rtnl_lock.
---


  parent reply	other threads:[~2026-07-09 10:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 12:19 [PATCH net-next v2 0/8] netconsole: stop charging netpoll users for netconsole-only data Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 1/8] netpoll: export refill_skbs(), refill_skbs_work_handler(), skb_pool_flush() Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 2/8] netconsole: take over skb pool lifecycle from netpoll Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 3/8] netconsole: move refill_skbs_work_handler() " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 4/8] netconsole: move refill_skbs() and skb-pool sizing macros " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 5/8] netconsole: move skb_pool_flush() " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 6/8] netconsole: move skb_pool / refill_wq from struct netpoll to netconsole_target Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 7/8] netconsole: move local_port / remote_port " Breno Leitao
2026-07-02 12:19 ` [PATCH net-next v2 8/8] netconsole: move remote_mac " Breno Leitao
2026-07-06 11:55 ` [PATCH net-next v2 0/8] netconsole: stop charging netpoll users for netconsole-only data Breno Leitao
2026-07-09 10:19   ` Simon Horman
2026-07-09 10:27     ` Paolo Abeni
2026-07-09 16:38       ` Breno Leitao
2026-07-09 10:20   ` Paolo Abeni [this message]
2026-07-10  9:46     ` Breno Leitao
2026-07-10 11:01       ` Breno Leitao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1bfad1f6-6947-47a4-9dc0-72b4c16fc395@redhat.com \
    --to=pabeni@redhat.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=asantostc@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gustavold@gmail.com \
    --cc=horms@kernel.org \
    --cc=kernel-team@meta.com \
    --cc=kuba@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox