From: Anton Eidelman <anton@lightbitslabs.com>
To: Christopher Lameter <cl@linux.com>
Cc: Kees Cook <keescook@chromium.org>,
Matthew Wilcox <willy@infradead.org>,
Laura Abbott <labbott@redhat.com>, Linux-MM <linux-mm@kvack.org>,
linux-hardened@lists.openwall.com
Subject: Re: HARDENED_USERCOPY will BUG on multiple slub objects coalesced into an sk_buff fragment
Date: Tue, 5 Jun 2018 13:45:58 -0700 [thread overview]
Message-ID: <CAKYffwqf5EhabhFwT85iTYNLjpR0noQ9Kua+2aOYNZ5AaJAWOw@mail.gmail.com> (raw)
In-Reply-To: <01000163d08f00b4-068f6b54-5d34-447d-90c6-010a24fc36d5-000000@email.amazonses.com>
[-- Attachment #1: Type: text/plain, Size: 3343 bytes --]
Hi Christopher,
This eliminates the failure as expected (at the source).
I do not think such a solution is required, and it probably affect
performance.
As Matthew said, slab objects should not be used in sk_buff fragments.
The source of these is my kernel TCP sockets, where kernel_sendpage() is
used with slab payload.
I eliminated this, and the failure disappeared, even though with this kind
of fine timing issues, no failure does not mean anything
Moreover, I tried triggering on slab in sk_buff fragments and nothing came
up.
So far:
1) Use of slab payload in kernel_sendpage() is not polite, even though we
do not BUG on this and documentation does not tell it was just wrong.
2) RX path cannot bring sk_buffs in slab: drivers use alloc_pagexxx or
page_frag_alloc().
What I am still wondering about (and investigating), is how kernel_sendpage()
with slab payload results in slab payload on another socket RX.
Do you see how page ref-counting can be broken with extra references taken
on a slab page containing the fragments, and dropped when networking is
done with them?
Thanks,
Anton
On Tue, Jun 5, 2018 at 8:27 AM, Christopher Lameter <cl@linux.com> wrote:
> On Fri, 1 Jun 2018, Anton Eidelman wrote:
>
> > I do not have a way of reproducing this decent enough to recommend: I'll
> > keep digging.
>
> If you can reproduce it: Could you try the following patch?
>
>
>
> Subject: [NET] Fix false positives of skb_can_coalesce
>
> Skb fragments may be slab objects. Two slab objects may reside
> in the same slab page. In that case skb_can_coalesce() may return
> true althought the skb cannot be expanded because it would
> cross a slab boundary.
>
> Enabling slab debugging will avoid the issue since red zones will
> be inserted and thus the skb_can_coalesce() check will not detect
> neighboring objects and return false.
>
> Signed-off-by: Christoph Lameter <cl@linux.com>
>
> Index: linux/include/linux/skbuff.h
> ===================================================================
> --- linux.orig/include/linux/skbuff.h
> +++ linux/include/linux/skbuff.h
> @@ -3010,8 +3010,29 @@ static inline bool skb_can_coalesce(stru
> if (i) {
> const struct skb_frag_struct *frag =
> &skb_shinfo(skb)->frags[i - 1];
>
> - return page == skb_frag_page(frag) &&
> - off == frag->page_offset + skb_frag_size(frag);
> + if (page != skb_frag_page(frag))
> + return false;
> +
> + if (off != frag->page_offset + skb_frag_size(frag))
> + return false;
> +
> + /*
> + * This may be a slab page and we may have pointers
> + * to different slab objects in the same page
> + */
> + if (!PageSlab(skb_frag_page(frag)))
> + return true;
> +
> + /*
> + * We could still return true if we would check here
> + * if the two fragments are within the same
> + * slab object. But that is complicated and
> + * I guess we would need a new slab function
> + * to check if two pointers are within the same
> + * object.
> + */
> + return false;
> +
> }
> return false;
> }
>
[-- Attachment #2: Type: text/html, Size: 5611 bytes --]
next prev parent reply other threads:[~2018-06-05 20:46 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-01 0:03 Anton Eidelman
2018-06-01 19:02 ` Laura Abbott
2018-06-01 20:49 ` Kees Cook
2018-06-01 20:58 ` Matthew Wilcox
2018-06-01 21:55 ` Kees Cook
2018-06-01 23:34 ` Anton Eidelman
2018-06-05 15:27 ` Christopher Lameter
2018-06-05 20:45 ` Anton Eidelman [this message]
2018-06-05 21:43 ` Christopher Lameter
2018-06-05 14:51 ` Christopher Lameter
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=CAKYffwqf5EhabhFwT85iTYNLjpR0noQ9Kua+2aOYNZ5AaJAWOw@mail.gmail.com \
--to=anton@lightbitslabs.com \
--cc=cl@linux.com \
--cc=keescook@chromium.org \
--cc=labbott@redhat.com \
--cc=linux-hardened@lists.openwall.com \
--cc=linux-mm@kvack.org \
--cc=willy@infradead.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox