netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <kuba@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: davem@davemloft.net, edumazet@google.com, pabeni@redhat.com,
	thevlad@fb.com, thepacketgeek@gmail.com, riel@surriel.com,
	horms@kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org, paulmck@kernel.org,
	davej@codemonkey.org.uk
Subject: Re: [PATCH net-next v2 5/5] net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal
Date: Wed, 7 Aug 2024 06:54:24 -0700	[thread overview]
Message-ID: <20240807065424.74dad331@kernel.org> (raw)
In-Reply-To: <20240807091657.4191542-6-leitao@debian.org>

On Wed,  7 Aug 2024 02:16:51 -0700 Breno Leitao wrote:
> Current issue:
> - The `target_list_lock` spinlock is held while iterating over
>   target_list() entries.
> - Mid-loop, the lock is released to call __netpoll_cleanup(), then
>   reacquired.
> - This practice compromises the protection provided by
>   `target_list_lock`.
> 
> Reason for current design:
> 1. __netpoll_cleanup() may sleep, incompatible with holding a spinlock.
> 2. target_list_lock must be a spinlock because write_msg() cannot sleep.
>    (See commit b5427c27173e ("[NET] netconsole: Support multiple logging
>     targets"))
> 
> Defer the cleanup of the netpoll structure to outside the
> target_list_lock() protected area. Create another list
> (target_cleanup_list) to hold the entries that need to be cleaned up,
> and clean them using a mutex (target_cleanup_list_lock).

Haven't looked closely but in the configs CI uses this breaks the build:

drivers/net/netconsole.c:251:13: error: ‘netconsole_process_cleanups’ defined but not used [-Werror=unused-function]
  251 | static void netconsole_process_cleanups(void)
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~
-- 
pw-bot: cr

  reply	other threads:[~2024-08-07 13:54 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-07  9:16 [PATCH net-next v2 0/5] net: netconsole: Fix netconsole unsafe locking Breno Leitao
2024-08-07  9:16 ` [PATCH net-next v2 1/5] net: netpoll: extract core of netpoll_cleanup Breno Leitao
2024-08-07  9:16 ` [PATCH net-next v2 2/5] net: netconsole: Correct mismatched return types Breno Leitao
2024-08-07  9:16 ` [PATCH net-next v2 3/5] net: netconsole: Standardize variable naming Breno Leitao
2024-08-07  9:16 ` [PATCH net-next v2 4/5] net: netconsole: Unify Function Return Paths Breno Leitao
2024-08-07  9:16 ` [PATCH net-next v2 5/5] net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal Breno Leitao
2024-08-07 13:54   ` Jakub Kicinski [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-08-08 12:25 [PATCH net-next v2 0/5] net: netconsole: Fix netconsole unsafe locking Breno Leitao
2024-08-08 12:25 ` [PATCH net-next v2 5/5] net: netconsole: Defer netpoll cleanup to avoid lock release during list traversal 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=20240807065424.74dad331@kernel.org \
    --to=kuba@kernel.org \
    --cc=davej@codemonkey.org.uk \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulmck@kernel.org \
    --cc=riel@surriel.com \
    --cc=thepacketgeek@gmail.com \
    --cc=thevlad@fb.com \
    /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;
as well as URLs for NNTP newsgroup(s).