From: Matthew Wilcox <willy@infradead.org>
To: Eric Dumazet <edumazet@google.com>
Cc: "David S . Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Neal Cardwell <ncardwell@google.com>,
netdev@vger.kernel.org, eric.dumazet@gmail.com,
ZhangPeng <zhangpeng362@huawei.com>,
Arjun Roy <arjunroy@google.com>,
linux-mm@kvack.org, Andrew Morton <akpm@linux-foundation.org>,
linux-fsdevel@vger.kernel.org
Subject: Re: [PATCH net] tcp: add sanity checks to rx zerocopy
Date: Thu, 25 Jan 2024 16:09:55 +0000 [thread overview]
Message-ID: <ZbKH04PDW7NhImjV@casper.infradead.org> (raw)
In-Reply-To: <ZbKHVt_wkIfjKJXB@casper.infradead.org>
Fixing email address for linux-mm.
On Thu, Jan 25, 2024 at 04:07:50PM +0000, Matthew Wilcox wrote:
> On Thu, Jan 25, 2024 at 10:33:17AM +0000, Eric Dumazet wrote:
> > +++ b/net/ipv4/tcp.c
> > @@ -1786,7 +1786,17 @@ static skb_frag_t *skb_advance_to_frag(struct sk_buff *skb, u32 offset_skb,
> >
> > static bool can_map_frag(const skb_frag_t *frag)
> > {
> > - return skb_frag_size(frag) == PAGE_SIZE && !skb_frag_off(frag);
> > + struct page *page;
> > +
> > + if (skb_frag_size(frag) != PAGE_SIZE || skb_frag_off(frag))
> > + return false;
> > +
> > + page = skb_frag_page(frag);
> > +
> > + if (PageCompound(page) || page->mapping)
> > + return false;
>
> I'm not entirely sure why you're testing PageCompound here. If a driver
> allocates a compound page, we'd still want to be able to insert it,
> right?
>
> I have a feeling that we want to fix this in the VM layer. There are
> some weird places calling vm_insert_page() and we should probably make
> them all fail.
>
> Something like this, perhaps?
>
> diff --git a/mm/memory.c b/mm/memory.c
> index 1a60faad2e49..ae0abab56d38 100644
> --- a/mm/memory.c
> +++ b/mm/memory.c
> @@ -1871,6 +1871,10 @@ static int insert_page_into_pte_locked(struct vm_area_struct *vma, pte_t *pte,
>
> if (!pte_none(ptep_get(pte)))
> return -EBUSY;
> + if (folio->mapping &&
> + ((addr - vma->vm_start) / PAGE_SIZE + vma->vm_pgoff) !=
> + (folio->index + folio_page_idx(folio, page)))
> + return -EINVAL;
> /* Ok, finally just insert the thing.. */
> folio_get(folio);
> inc_mm_counter(vma->vm_mm, mm_counter_file(folio));
>
next prev parent reply other threads:[~2024-01-25 16:09 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-25 10:33 [PATCH net] tcp: add sanity checks to rx zerocopy Eric Dumazet
2024-01-25 16:07 ` Matthew Wilcox
2024-01-25 16:09 ` Matthew Wilcox [this message]
2024-01-25 16:54 ` Eric Dumazet
2024-01-25 22:23 ` Arjun Roy
2024-01-29 12:10 ` patchwork-bot+netdevbpf
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=ZbKH04PDW7NhImjV@casper.infradead.org \
--to=willy@infradead.org \
--cc=akpm@linux-foundation.org \
--cc=arjunroy@google.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=eric.dumazet@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ncardwell@google.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=zhangpeng362@huawei.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;
as well as URLs for NNTP newsgroup(s).