[bug report] CIFS: Fix splice read for non-cached files

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello Pavel Shilovsky,

The patch 9c25702cee14: "CIFS: Fix splice read for non-cached files"
from Jan 19, 2017, leads to the following Smatch static checker
warning:

	lib/iov_iter.c:293 append_pipe()
	warn: sleeping in atomic context

fs/cifs/file.c
  3524  static int
  3525  cifs_readdata_to_iov(struct cifs_readdata *rdata, struct iov_iter *iter)
  3526  {
  3527          size_t remaining = rdata->got_bytes;
  3528          unsigned int i;
  3529  
  3530          for (i = 0; i < rdata->nr_pages; i++) {
  3531                  struct page *page = rdata->pages[i];
  3532                  size_t copy = min_t(size_t, remaining, PAGE_SIZE);
  3533                  size_t written;
  3534  
  3535                  if (unlikely(iov_iter_is_pipe(iter))) {
  3536                          void *addr = kmap_atomic(page);

Should this be atomic?

  3537  
  3538                          written = copy_to_iter(addr, copy, iter);

Smatch complains that copy_to_iter() can sleep so it leads to a sleeping
in atomic warning.  The call tree is:

cifs_readdata_to_iov() <- disables preempt
-> copy_to_iter()
   -> _copy_to_iter()
      -> copy_pipe_to_iter()
         -> append_pipe() the push_anon() function does a sleeping alloc

  3539                          kunmap_atomic(addr);
  3540                  } else
  3541                          written = copy_page_to_iter(page, 0, copy, iter);
  3542                  remaining -= written;
  3543                  if (written < copy && iov_iter_count(iter) > 0)
  3544                          break;
  3545          }
  3546          return remaining ? -EFAULT : 0;
  3547  }

regards,
dan carpenter



[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux