From: Christopher Lameter <cl@linux.com>
To: Anton Eidelman <anton@lightbitslabs.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 15:27:02 +0000 [thread overview]
Message-ID: <01000163d08f00b4-068f6b54-5d34-447d-90c6-010a24fc36d5-000000@email.amazonses.com> (raw)
In-Reply-To: <CAKYffwpAAgD+a+0kebid43tpyS6L+8o=4hBbDvhfgaoV_gze1g@mail.gmail.com>
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;
}
next prev parent reply other threads:[~2018-06-05 15:27 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 [this message]
2018-06-05 20:45 ` Anton Eidelman
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=01000163d08f00b4-068f6b54-5d34-447d-90c6-010a24fc36d5-000000@email.amazonses.com \
--to=cl@linux.com \
--cc=anton@lightbitslabs.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