Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1707114
| From | Laurent Pinchart <laurent.pinchart@ideasonboard.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: Possible null pointer dereference in rcar-dmac.ko |
| Date | 2017-08-09 10:00 +0200 |
| Message-ID | <ucu4h-44e-3@gated-at.bofh.it> (permalink) |
| References | <ucbuH-8cT-55@gated-at.bofh.it> <ucu4h-44e-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
Hello, On Wednesday 09 Aug 2017 00:49:40 Kuninori Morimoto wrote: > Hi Anton > > # add Laurent > > > While searching for races in the Linux kernel I've come across > > "drivers/dma/sh/rcar-dmac.ko" module. Here is a question that I came > > up with while analyzing results. Lines are given using the info from > > Linux v4.12. > > > > Consider the following case: > > > > Thread 1: Thread 2: > > rcar_dmac_probe > > ->rcar_dmac_chan_probe > > > > (&dmac->channels[i]) > > > > rchan = &dmac->channels[i] > > chan = &rchan->chan > > devm_request_threaded_irq(rchan) > > chan->device = &dmac->engine rcar_dmac_isr_channel > > > > ->rcar_dmac_isr_transfer_end(chan) > > > > ->rcar_dmac_chan_start_xfer(chan) > > > > engine->dev = &pdev->dev; <READ chan->chan.device->dev> > > (rcar-dmac.c: line 1828) (rcar-dmac.c: line 351) > > > > As far as I understand engine->dev is NULL before its initialization > > in probe. Thus there might be a NULL pointer dereference in > > rcar_dmac_chan_start_xfer while accessing chan->chan.device->dev which > > is equal to (&dmac->engine)->dev. Is this possible from your point of > > view? > > Very rare case, but not impossible (?). > I think these engine->xxx initialize should be done before > of_dma_controller_register(); > engine.channels is initialized independently somehow... There should be no interrupt pending at the time the interrupt handler is registered, but to be safe it's indeed a good practice to register the interrupt handler after everything else has been initialized. Patches are welcome :-) -- Regards, Laurent Pinchart
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Possible null pointer dereference in rcar-dmac.ko Anton Volkov <avolkov@ispras.ru> - 2017-08-08 14:10 +0200
Re: Possible null pointer dereference in rcar-dmac.ko Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-09 10:00 +0200
Re: Possible null pointer dereference in rcar-dmac.ko Laurent Pinchart <laurent.pinchart@ideasonboard.com> - 2017-08-10 17:00 +0200
csiph-web