Linux s390 Architecture development
 help / color / mirror / Atom feed
From: Heiko Carstens <hca@linux.ibm.com>
To: Jens Axboe <axboe@kernel.dk>, Stefan Haberland <sth@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>
Subject: Re: [PATCH 1/2] s390/dasd: Add __context_unsafe() attribute to various functions
Date: Thu, 6 Aug 2026 16:06:20 +0200	[thread overview]
Message-ID: <20260806140620.15764D1b-hca@linux.ibm.com> (raw)
In-Reply-To: <20260806130917.3DD841F000E9@smtp.kernel.org>

On Thu, Aug 06, 2026 at 01:09:16PM +0000, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
...
> >  static int dasd_eckd_pe_handler(struct dasd_device *device,
> >  				__u8 tbvpm, __u8 fcsecpm)
> > +__context_unsafe(/* Conditional locking */)
> >  {
> >  	struct pe_handler_work_data *data;
> 
> [Severity: High]
> This is a pre-existing issue, but does silencing this warning hide a
> legitimate cross-thread mutex unlock?
> 
> When kzalloc fails in dasd_eckd_pe_handler(), it calls mutex_trylock(),
> establishing the current interrupted task as the lock owner:
> 
> dasd_eckd_pe_handler() {
>     ...
>     data = kzalloc_obj(*data, GFP_ATOMIC | GFP_DMA);
>     if (!data) {
>         if (mutex_trylock(&dasd_pe_handler_mutex)) {
>             data = pe_handler_worker;
>             data->isglobal = 1;
>     ...
>     schedule_work(&data->worker);
> }
> 
> The lock is then released from a different task (the workqueue worker thread)
> in do_pe_handler_work():
> 
> do_pe_handler_work() {
>     ...
>     if (data->isglobal)
>         mutex_unlock(&dasd_pe_handler_mutex);
>     ...
> }
> 
> Unlocking a struct mutex from a task other than the one that acquired it
> strictly violates mutex semantics, which could cause debug warnings or
> panics.
> 
> Additionally, mutex_trylock() in atomic context (inferred from GFP_ATOMIC
> usage) violates lockdep wait-context rules and PREEMPT_RT requirements.
> 
> Could this code be restructured to avoid the cross-thread unlock rather than
> silencing the warning?

This looks indeed like a valid finding. Looking at the code it looks to me
like there is no need for a mutex at all. Instead a simple integer which
indicates if the global pe_handler_work_data is used should be
sufficient. Exclusive access would then be tried to get with xchg().

Jens, Stefan, should this be addressed before or after this small series?
I would prefer after this series, since in the meantime I dislike those
"pre-existing" bugs, which pile up :)

  reply	other threads:[~2026-08-06 14:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-06 13:00 [PATCH 0/2] s390/block: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-06 13:00 ` [PATCH 1/2] s390/dasd: Add __context_unsafe() attribute to various functions Heiko Carstens
2026-08-06 13:09   ` sashiko-bot
2026-08-06 14:06     ` Heiko Carstens [this message]
2026-08-06 14:09       ` Stefan Haberland
2026-08-06 16:34   ` Bart Van Assche
2026-08-06 18:09     ` Heiko Carstens
2026-08-06 13:00 ` [PATCH 2/2] s390/block: Enable CONTEXT_ANALYSIS Heiko Carstens
2026-08-06 13:02   ` sashiko-bot
2026-08-06 16:34   ` Bart Van Assche
2026-08-06 13:09 ` [PATCH 0/2] " Stefan Haberland
2026-08-06 14:14 ` Jens Axboe

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=20260806140620.15764D1b-hca@linux.ibm.com \
    --to=hca@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=axboe@kernel.dk \
    --cc=gor@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sth@linux.ibm.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