Linux CIFS filesystem development
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: pshilov@microsoft.com
Cc: linux-cifs@vger.kernel.org
Subject: [bug report] CIFS: Fix splice read for non-cached files
Date: Tue, 12 Jul 2022 14:03:34 +0300	[thread overview]
Message-ID: <Ys1VBuMKjFzjth4Y@kili> (raw)

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

                 reply	other threads:[~2022-07-12 11:04 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ys1VBuMKjFzjth4Y@kili \
    --to=dan.carpenter@oracle.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=pshilov@microsoft.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox