[PATCH v3] pps: generators: tio: fix platform_set_drvdata()

Raag Jadav posted 1 patch 9 months ago
drivers/pps/generators/pps_gen_tio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[PATCH v3] pps: generators: tio: fix platform_set_drvdata()
Posted by Raag Jadav 9 months ago
platform_set_drvdata() is setting a double pointer to struct pps_tio as
driver_data, which will point to the local stack of probe function instead
of intended data. Set driver_data correctly and fix illegal memory access
by its user.

 BUG: unable to handle page fault for address: ffffc9000117b738
 RIP: 0010:hrtimer_active+0x2b/0x60
 Call Trace:
  ? hrtimer_active+0x2b/0x60
  hrtimer_cancel+0x19/0x50
  pps_gen_tio_remove+0x1e/0x80 [pps_gen_tio]

Fixes: c89755d1111f ("pps: generators: Add PPS Generator TIO Driver")
Signed-off-by: Raag Jadav <raag.jadav@intel.com>
Acked-by: Rodolfo Giometti <giometti@enneenne.com>
---

v2: Add crash details in commit message (Greg, Andy)
v3: Shorten the call trace, rephrase commit message (Andy)

 drivers/pps/generators/pps_gen_tio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pps/generators/pps_gen_tio.c b/drivers/pps/generators/pps_gen_tio.c
index 6c46b46c66cd..6e4a383957d9 100644
--- a/drivers/pps/generators/pps_gen_tio.c
+++ b/drivers/pps/generators/pps_gen_tio.c
@@ -230,7 +230,7 @@ static int pps_gen_tio_probe(struct platform_device *pdev)
 	hrtimer_init(&tio->timer, CLOCK_REALTIME, HRTIMER_MODE_ABS);
 	tio->timer.function = hrtimer_callback;
 	spin_lock_init(&tio->lock);
-	platform_set_drvdata(pdev, &tio);
+	platform_set_drvdata(pdev, tio);
 
 	return 0;
 }

base-commit: a24b18aa4fd619cc7961dae3395473c355bb5b6a
-- 
2.34.1
Re: [PATCH v3] pps: generators: tio: fix platform_set_drvdata()
Posted by Andy Shevchenko 9 months ago
On Tue, Mar 18, 2025 at 05:10:38PM +0530, Raag Jadav wrote:
> platform_set_drvdata() is setting a double pointer to struct pps_tio as
> driver_data, which will point to the local stack of probe function instead
> of intended data. Set driver_data correctly and fix illegal memory access
> by its user.
> 
>  BUG: unable to handle page fault for address: ffffc9000117b738
>  RIP: 0010:hrtimer_active+0x2b/0x60
>  Call Trace:
>   ? hrtimer_active+0x2b/0x60
>   hrtimer_cancel+0x19/0x50
>   pps_gen_tio_remove+0x1e/0x80 [pps_gen_tio]

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

-- 
With Best Regards,
Andy Shevchenko
Re: [PATCH v3] pps: generators: tio: fix platform_set_drvdata()
Posted by Raag Jadav 8 months, 2 weeks ago
On Tue, Mar 18, 2025 at 03:43:46PM +0200, Andy Shevchenko wrote:
> On Tue, Mar 18, 2025 at 05:10:38PM +0530, Raag Jadav wrote:
> > platform_set_drvdata() is setting a double pointer to struct pps_tio as
> > driver_data, which will point to the local stack of probe function instead
> > of intended data. Set driver_data correctly and fix illegal memory access
> > by its user.
> > 
> >  BUG: unable to handle page fault for address: ffffc9000117b738
> >  RIP: 0010:hrtimer_active+0x2b/0x60
> >  Call Trace:
> >   ? hrtimer_active+0x2b/0x60
> >   hrtimer_cancel+0x19/0x50
> >   pps_gen_tio_remove+0x1e/0x80 [pps_gen_tio]
> 
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

Thank you.

Any guidance on routing this one?

Raag