Linux s390 Architecture development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Heiko Carstens" <hca@linux.ibm.com>
Cc: linux-s390@vger.kernel.org,
	"Alexander Gordeev" <agordeev@linux.ibm.com>,
	"Heiko Carstens" <hca@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, 06 Aug 2026 13:09:16 +0000	[thread overview]
Message-ID: <20260806130917.3DD841F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260806130050.2057443-2-hca@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] The patch uses `__context_unsafe` to silence a valid static analysis warning about a cross-thread mutex unlock in `do_pe_handler_work`, hiding a severe locking API violation.
--

--- Patch [1]: [PATCH 1/2] s390/dasd: Add __context_unsafe() attribute to various functions ---
commit 0764dc821ba7e47d621de5b2696256130f3eee09
Author: Heiko Carstens <hca@linux.ibm.com>

s390/dasd: Add __context_unsafe() attribute to various functions

This patch disables context analysis for various functions to avoid compile
time warnings using clang caused by conditional locking. The __context_unsafe()
attribute is used to provide a short comment on why it is disabled.

> diff --git a/drivers/s390/block/dasd_eckd.c b/drivers/s390/block/dasd_eckd.c
> index 74fe73b5738ab..e908e2f29919e 100644
> --- a/drivers/s390/block/dasd_eckd.c
> +++ b/drivers/s390/block/dasd_eckd.c
[ ... ]
> @@ -1432,6 +1432,7 @@ static void dasd_eckd_path_available_action(struct dasd_device *device,
>  }
>  
>  static void do_pe_handler_work(struct work_struct *work)
> +__context_unsafe(/* Conditional locking */)
>  {
>  	struct pe_handler_work_data *data;
>  	struct dasd_device *device;

[ ... ]

> @@ -1465,6 +1466,7 @@ static void do_pe_handler_work(struct work_struct *work)
>  
>  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?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260806130050.2057443-1-hca@linux.ibm.com?part=1

  reply	other threads:[~2026-08-06 13:09 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 [this message]
2026-08-06 14:06     ` Heiko Carstens
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=20260806130917.3DD841F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=linux-s390@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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