Re: [PATCH net-next v6 06/18] net: Add a function to splice pages into an skbuff for MSG_SPLICE_PAGES

From: Al Viro
Date: Thu Apr 13 2023 - 00:41:51 EST


On Tue, Apr 11, 2023 at 05:08:50PM +0100, David Howells wrote:
> Add a function to handle MSG_SPLICE_PAGES being passed internally to
> sendmsg(). Pages are spliced into the given socket buffer if possible and
> copied in if not (ie. they're slab pages or have a zero refcount).

That "ie." would better be "e.g." - that condition is *not* enough for
tell the unsafe ones from the rest.

sendpage_ok() would be better off called "might_be_ok_to_sendpage()".
If it's false, we'd better not grab a reference to the page and expect the
sucker to stay safe until the reference is dropped. However, AFAICS
it might return true on a page that is not safe in that respect.

What rules do you propose for sendpage users? "Pass whatever page reference
you want, it'll do the right thing"? Anything short of that would better
be documented as explicitly as possible...