From: Dominik Brodowski <linux@dominikbrodowski.net>
To: Jia-Ju Bai <baijiaju1990@gmail.com>
Cc: miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp()
Date: Wed, 18 Dec 2019 18:28:13 +0100 [thread overview]
Message-ID: <20191218172813.GA338501@light.dominikbrodowski.net> (raw)
In-Reply-To: <20191218140552.12249-1-baijiaju1990@gmail.com>
On Wed, Dec 18, 2019 at 10:05:52PM +0800, Jia-Ju Bai wrote:
> The driver may sleep while holding a spinlock.
> The function call path (from bottom to top) in Linux 4.19 is:
>
> drivers/pcmcia/pcmcia_resource.c, 312:
> mutex_lock in pcmcia_fixup_vpp
> drivers/mtd/maps/pcmciamtd.c, 309:
> pcmcia_fixup_vpp in pcmciamtd_set_vpp
> drivers/mtd/maps/pcmciamtd.c, 306:
> _raw_spin_lock_irqsave in pcmciamtd_set_vpp
>
> drivers/pcmcia/pcmcia_resource.c, 312:
> mutex_lock in pcmcia_fixup_vpp
> drivers/mtd/maps/pcmciamtd.c, 312:
> pcmcia_fixup_vpp in pcmciamtd_set_vpp
> drivers/mtd/maps/pcmciamtd.c, 306:
> _raw_spin_lock_irqsave in pcmciamtd_set_vp
>
> mutex_lock() may sleep at runtime.
Thanks for noticing this issue.
> To fix these bugs, pcmcia_fixup_vpp() is called without holding the
> spinlock.
I don't think that this is the right approach here -- we lose the protection
against races in calls to pcmcia_fixup_vpp(). Instead, we should change the
spinlock to a mutex, which seems to be sufficient here. Could you prepare
such a patch, please?
Thanks,
Dominik
next prev parent reply other threads:[~2019-12-18 17:28 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-18 14:05 [PATCH] mtd: maps: pcmciamtd: fix possible sleep-in-atomic-context bugs in pcmciamtd_set_vpp() Jia-Ju Bai
2019-12-18 17:28 ` Dominik Brodowski [this message]
2019-12-19 2:32 ` Jia-Ju Bai
-- strict thread matches above, loose matches on Subject: below --
2019-12-18 13:41 Jia-Ju Bai
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=20191218172813.GA338501@light.dominikbrodowski.net \
--to=linux@dominikbrodowski.net \
--cc=baijiaju1990@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=vigneshr@ti.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).