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] [day] [month] [year] [list]
Message-ID:
 <DM6PR04MB6575B668C3A5124BFDAA9B9AFCE02@DM6PR04MB6575.namprd04.prod.outlook.com>
Date: Thu, 23 Jan 2025 20:03:26 +0000
From: Avri Altman <Avri.Altman@....com>
To: Geert Uytterhoeven <geert@...ux-m68k.org>
CC: "Martin K . Petersen" <martin.petersen@...cle.com>,
	"linux-scsi@...r.kernel.org" <linux-scsi@...r.kernel.org>,
	"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, Manivannan
 Sadhasivam <manisadhasivam.linux@...il.com>, Bart Van Assche
	<bvanassche@....org>, Dmitry Baryshkov <dmitry.baryshkov@...aro.org>,
	Linux-Renesas <linux-renesas-soc@...r.kernel.org>
Subject: RE: [PATCH] scsi: ufs: core: Ensure clk_gating.lock is used only
 after initialization

> I just ran into the same issue on R-Car S4 (S4 Starter Kit).
> 
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -9142,7 +9142,7 @@ static int ufshcd_setup_clocks(struct ufs_hba *hba,
> bool on)
> >                         if (!IS_ERR_OR_NULL(clki->clk) && clki->enabled)
> >                                 clk_disable_unprepare(clki->clk);
> >                 }
> > -       } else if (!ret && on) {
> > +       } else if (!ret && on && hba->clk_gating.is_initialized) {
> >                 scoped_guard(spinlock_irqsave, &hba->clk_gating.lock)
> >                         hba->clk_gating.state = CLKS_ON;
> >                 trace_ufshcd_clk_gating(dev_name(hba->dev),
> 
> This looks like a very fragile solution to me...
> 
> In addition, while this change does fix this particular spinlock warning, it just
> BUGs in a different place later:
> 
>   do_raw_spin_lock+0x34/0xb4
>   _raw_spin_lock_irqsave+0x1c/0x30
>   class_spinlock_irqsave_constructor+0x18/0x30
> - ufshcd_setup_clocks+0x98/0x23c
> - ufshcd_init+0x268/0xd2c
> + ufshcd_release+0x30/0x74
> + ufshcd_send_uic_cmd+0x70/0x90
> + ufshcd_link_startup.constprop.0+0x70/0x258
> + ufshcd_init+0xa38/0xd2c
>   ufshcd_pltfrm_init+0x618/0x738
>   ufs_renesas_probe+0x18/0x24
>   platform_probe+0x68/0xb8
I don't understand how it is possible that `ufshcd_init_clk_gating(hba)` is called after `ufshcd_link_startup(hba)` in 'ufshcd_init'.
Nor how concurrency could take place in this init flow.
Evidently, this is happening.

> 
> I think you should initialize all your spinlocks (and mutexes) early in
> ufshcd_init(), instead of sprinkled across various helper functions.
This is the case today.  Let me suggest a different fix.

Thanks,
Avri

> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@...ux-
> m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But when
> I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ