From: Al Viro <viro@zeniv.linux.org.uk>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dan Williams <dan.j.williams@intel.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
linux-fsdevel <linux-fsdevel@vger.kernel.org>,
nvdimm@lists.linux.dev, David Howells <dhowells@redhat.com>
Subject: Re: [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter()
Date: Tue, 14 Jun 2022 00:25:03 +0100 [thread overview]
Message-ID: <YqfHT7Ha/N/wAdcG@ZenIV> (raw)
In-Reply-To: <Yqe6EjGTpkvJUU28@ZenIV>
On Mon, Jun 13, 2022 at 11:28:34PM +0100, Al Viro wrote:
> Dave, could you explain what's going on there? Note that pipe_write()
> does *not* use that thing at all; it's only splice (i.e. ITER_PIPE
> stuff) that is using it.
>
> What's wrong with
> p_occupancy = pipe_occupancy(head, tail);
> if (p_occupancy >= pipe->max_usage)
> return 0;
> else
> return pipe->max_usage - p_occupancy;
>
> which would match the way you are using ->max_usage in pipe_write()
> et.al. Including the use in copy_page_to_iter_pipe(), BTW...
The more I'm looking at that thing, the more it smells like a bug;
it had the same 3 callers since the time it had been introduced.
1) pipe_get_pages(). We are about to try and allocate up to that
many pipe buffers. Allocation (done in push_pipe()) is done only
if we have !pipe_full(pipe->head, pipe->tail, pipe->max_usage).
It simply won't give you more than max_usage - occupancy.
Your function returns min(ring_size - occupancy, max_usage), which
is always greater than or equal to that (ring_size >= max_usage).
2) pipe_get_pages_alloc(). Same story, same push_pipe() being
called, same "we'll never get that much - it'll hit the limit
first".
3) iov_iter_npages() in case of ITER_PIPE. Again, the value
is bogus - it should not be greater than the amount of pages
we would be able to write there.
AFAICS, 6718b6f855a0 "pipe: Allow pipes to have kernel-reserved slots"
broke it for cases when ring_size != max_usage...
next prev parent reply other threads:[~2022-06-13 23:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-13 0:10 [RFC][PATCH] fix short copy handling in copy_mc_pipe_to_iter() Al Viro
2022-06-13 17:54 ` Linus Torvalds
2022-06-13 22:28 ` Al Viro
2022-06-13 23:25 ` Al Viro [this message]
2022-06-13 23:34 ` Al Viro
2022-06-14 0:53 ` Al Viro
2022-06-14 17:12 ` Al Viro
2022-06-14 6:36 ` David Howells
2022-06-14 12:11 ` Al Viro
2022-06-16 21:22 ` Dan Williams
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=YqfHT7Ha/N/wAdcG@ZenIV \
--to=viro@zeniv.linux.org.uk \
--cc=dan.j.williams@intel.com \
--cc=dhowells@redhat.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=nvdimm@lists.linux.dev \
--cc=torvalds@linux-foundation.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.