Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1694678

Possible race in spi-tegra114.ko

From Anton Volkov <avolkov@ispras.ru>
Newsgroups linux.kernel
Subject Possible race in spi-tegra114.ko
Date 2017-07-24 14:40 +0200
Message-ID <u6KOt-4Qj-9@gated-at.bofh.it> (permalink)
References <u6KOt-4Qj-11@gated-at.bofh.it> <u6KOt-4Qj-13@gated-at.bofh.it> <u6KOt-4Qj-15@gated-at.bofh.it> <u6KOt-4Qj-17@gated-at.bofh.it> <u6KOt-4Qj-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


Hello.
While searching for races in Linux kernel I've come across 
drivers/spi/spi-tegra114.ko module. Here is the question that I came up 
with while analysing results. Lines are given using the info from Linux 
v4.12.

Consider the following case:
Thread 1:                                  Thread 2:
tegra_spi_probe
   -> request_threaded_irq
       (spi-tegra114.c: line 1070)
   ------------interrupt comes------------- tegra_spi_isr_thread
                                              -> handle_dma_based_xfer
                                                   -> 
tegra_spi_start_dma_based_transfer
                                                        -> 
tegra_spi_copy_client_txbuf_to_spi_txbuf
                                                             -> 
dma_sync_single_for_cpu(tspi->dev, tspi->tx_dma_phys, ...) 
(spi-tegra114.c: line 368)
   -> tspi->tx_dma_phys = ...
      (spi-tegra114.c: line 621 or 625)

If the situation above is feasible then the value of tspi->tx_dma_phys 
(which is 0) is passed to dma_sync_single_for_cpu and further down the 
callstack. This is probably not good.
Note that other fields of tspi structure can also be affected using the 
similar templates.
Similar cases can occur also for tspi structure in 
drivers/spi/spi-tegra20-slink.ko module and for tsd structure in 
drivers/spi/spi-tegra20-sflash.ko module.
So the question is: is there a possibility of interrupt triggering 
before the registration of master (spi-tegra114.c: line 1125) or a write 
to tspi->def_command1_reg (spi-tegra114.c: line 1121)?

Thank you for your time.

-- Anton Volkov
Linux Verification Center, ISPRAS
web: http://linuxtesting.org
e-mail: avolkov@ispras.ru <mailto:avolkov@ispras.ru>

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Possible race in spi-tegra114.ko Anton Volkov <avolkov@ispras.ru> - 2017-07-24 14:40 +0200
  Re: Possible race in spi-tegra114.ko Thierry Reding <thierry.reding@gmail.com> - 2017-07-31 12:50 +0200

csiph-web