lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Zv8LAaeuJQkvscWF@slm.duckdns.org>
Date: Thu, 3 Oct 2024 11:22:09 -1000
From: Tejun Heo <tj@...nel.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Dan Carpenter <dan.carpenter@...aro.org>,
	Waiman Long <longman@...hat.com>, Yu Kuai <yukuai3@...wei.com>,
	Josef Bacik <josef@...icpanda.com>, cgroups@...r.kernel.org,
	linux-block@...r.kernel.org, linux-kernel@...r.kernel.org,
	kernel-janitors@...r.kernel.org, Christoph Hellwig <hch@....de>
Subject: Re: [PATCH v2] blk_iocost: remove some duplicate irq disable/enables

Hello,

On Thu, Oct 03, 2024 at 08:38:48AM -0600, Jens Axboe wrote:
...
> >>>   3144          spin_lock(&iocg->ioc->lock);
> >>>
> >>> But why is this not spin_lock_irq()?  I haven't analyzed this so maybe it's
> >>> fine.
> >>
> >> That's a bug.
> >>
> > 
> > I could obviously write this patch but I feel stupid writing the
> > commit message. My level of understanding is Monkey See Monkey do.
> > Could you take care of this?
> 
> Sure - or let's add Tejun who knows this code better. Ah he's already
> added. Tejun?

Yeah, that should be spin_lock_irq() for consistency but at the same time it
doesn't look like anything is actually grabbing that lock (or blkcg->lock
nesting outside of it) from an IRQ context, so no actual deadlock scenario
exists and lockdep doesn't trigger.

> > So somewhere we're taking a lock in the IRQ handler and this can lead
> > to a deadlock? I thought this would have been caught by lockdep?
> 
> It's nested inside blkcg->lock which is IRQ safe, that is enough. But
> doing a quick scan of the file, the usage is definitely (widly)
> inconsistent. Most times ioc->lock is grabbed disabling interrupts, but

Hmm... the only place I see is the one Dan pointed out.

> there are also uses that doesn't disable interrupts, coming from things
> like seq_file show paths which certainly look like they need it. lockdep
> should certainly warn about this, only explanation I have is that nobody
> bothered to do that :-)

The locks are intended to be IRQ-safe but it looks like they don't need to
be at least for now. I'll send a patch to update the ioc_weight_write()
pair.

Thanks.

-- 
tejun

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ