Skip to contentSkip to conversation

mfd: ezx-pcap: Possible sleep-in-atomic-context bugs in pcap_adc_irq()

BUG Jia-Ju Bai 2 participants 5 messages Sep 15, 2018 – Oct 10, 2018

lore
Share & tools
lore

Jia-Ju Bai

author
#0 lore raw

The driver may sleep in an interrupt handler.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 272:
mutex_lock_nested in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 100:
mutex_lock_nested in ezx_pcap_read
drivers/mfd/ezx-pcap.c, 281:
ezx_pcap_read in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 85:
mutex_lock_nested in ezx_pcap_write
drivers/mfd/ezx-pcap.c, 285:
ezx_pcap_write in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 244:
mutex_lock_nested in pcap_adc_trigger
drivers/mfd/ezx-pcap.c, 299:
pcap_adc_trigger in pcap_adc_irq (interrupt handler)

These bugs are found by my static analysis tool DSAC.

Best wishes,
Jia-Ju Bai

#1 lore raw
Quoted 19 lines · Jia-Ju Bai

The driver may sleep in an interrupt handler.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 272:
mutex_lock_nested in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 100:
mutex_lock_nested in ezx_pcap_read
drivers/mfd/ezx-pcap.c, 281:
ezx_pcap_read in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 85:
mutex_lock_nested in ezx_pcap_write
drivers/mfd/ezx-pcap.c, 285:
ezx_pcap_write in pcap_adc_irq (interrupt handler)

Quoted 7 lines

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 244:
mutex_lock_nested in pcap_adc_trigger
drivers/mfd/ezx-pcap.c, 299:
pcap_adc_trigger in pcap_adc_irq (interrupt handler)

These bugs are found by my static analysis tool DSAC.

Not sure what you want me to do with this.

Do you have something in mind?

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#2 lore raw
Quoted 27 lines · Lee Jones
Quoted 25 lines · Jia-Ju Bai

The driver may sleep in an interrupt handler.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 272:
mutex_lock_nested in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 100:
mutex_lock_nested in ezx_pcap_read
drivers/mfd/ezx-pcap.c, 281:
ezx_pcap_read in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 85:
mutex_lock_nested in ezx_pcap_write
drivers/mfd/ezx-pcap.c, 285:
ezx_pcap_write in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 244:
mutex_lock_nested in pcap_adc_trigger
drivers/mfd/ezx-pcap.c, 299:
pcap_adc_trigger in pcap_adc_irq (interrupt handler)

Quoted 5 lines
Quoted 1 line

These bugs are found by my static analysis tool DSAC.

Not sure what you want me to do with this.

Do you have something in mind?

I find some possible bugs in this driver, but I do not know how to correctly fix them... Could you find a good solution?

Best wishes,
Jia-Ju Bai

#3 lore raw
Quoted 31 lines · Jia-Ju Bai
Quoted 28 lines · Lee Jones
Quoted 26 lines · Jia-Ju Bai

The driver may sleep in an interrupt handler.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 272:
mutex_lock_nested in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 100:
mutex_lock_nested in ezx_pcap_read
drivers/mfd/ezx-pcap.c, 281:
ezx_pcap_read in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 85:
mutex_lock_nested in ezx_pcap_write
drivers/mfd/ezx-pcap.c, 285:
ezx_pcap_write in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 244:
mutex_lock_nested in pcap_adc_trigger
drivers/mfd/ezx-pcap.c, 299:
pcap_adc_trigger in pcap_adc_irq (interrupt handler)

These bugs are found by my static analysis tool DSAC.

Quoted 8 lines
Quoted 4 lines

Not sure what you want me to do with this.

Do you have something in mind?

I find some possible bugs in this driver, but I do not know how to correctly fix them...
Could you find a good solution?

If you have found bugs and do not intend on fixing them, please report them via the 'File a Bug' option here:

https://bugzilla.kernel.org/

Signature · 4 lines
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog
author
#4 lore raw
Quoted 36 lines · Lee Jones
Quoted 34 lines · Jia-Ju Bai
Quoted 32 lines · Lee Jones
Quoted 19 lines · Jia-Ju Bai

The driver may sleep in an interrupt handler.
The function call paths (from bottom to top) in Linux-4.17 are:

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 272:
mutex_lock_nested in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 100:
mutex_lock_nested in ezx_pcap_read
drivers/mfd/ezx-pcap.c, 281:
ezx_pcap_read in pcap_adc_irq (interrupt handler)

[FUNC] mutex_lock_nested drivers/mfd/ezx-pcap.c, 85:
mutex_lock_nested in ezx_pcap_write
drivers/mfd/ezx-pcap.c, 285:
ezx_pcap_write in pcap_adc_irq (interrupt handler)

Quoted 7 lines

[FUNC] mutex_lock_nested
drivers/mfd/ezx-pcap.c, 244:
mutex_lock_nested in pcap_adc_trigger
drivers/mfd/ezx-pcap.c, 299:
pcap_adc_trigger in pcap_adc_irq (interrupt handler)

These bugs are found by my static analysis tool DSAC.

Not sure what you want me to do with this.

Do you have something in mind?

Quoted 8 lines
Quoted 3 lines

I find some possible bugs in this driver, but I do not know how to correctly fix them...
Could you find a good solution?

If you have found bugs and do not intend on fixing them, please report them via the 'File a Bug' option here:

https://bugzilla.kernel.org/

Okay, thanks.

Best wishes,
Jia-Ju Bai