Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1736778
| Path | csiph.com!news.redatomik.org!weretis.net!feeder4.news.weretis.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod |
|---|---|
| From | Christopher Lameter <cl@linux.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v3 02/31] usercopy: Enforce slab cache usercopy region boundaries |
| Date | Thu, 21 Sep 2017 17:30:03 +0200 |
| Message-ID | <usbAn-2Ne-25@gated-at.bofh.it> (permalink) |
| References | <urU6t-818-3@gated-at.bofh.it> <urUga-855-39@gated-at.bofh.it> |
| X-Original-To | Kees Cook <keescook@chromium.org> |
| X-X-Sender | cl@nuc-kabylake |
| User-Agent | Alpine 2.20 (DEB 67 2015-01-07) |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset=US-ASCII |
| X-Cmae-Envelope | MS4wfFn7AqO6rWFW6ppxsCVMoLxVfkDALygboEJgOJpCzPopLlB+ixGyoo9yTAbC6sMC6npdq40qXy0lXXeqHnsCmOAUnaHEJ0+8uxq40Esjyxs3EdKxtBgW 328YlSD+agDN2i2a/p19lAFf4jy83glxWdU/0cN0L6ZiFHnEF3NOFT1+OM75XJ4vAwHYvqXUGAYLC3r/ilAzDEdjrUNVL7uLs67ff8X9PyIgg5TCnPdEZuNv pLrfyeJsxbVW3XXnB2wL4/FJqAnfDG8Br/eSW79pH1g2qpkSEegfu4HKnccryIJe3JWJS6g9tAOenjtPeiX1jkyH6LrZoIcirGDeX3eAYjYnOjxROGSSuPGq b+8Hclcjy0O1Fiuu+6XCkhIkJio5j8C9uSEloIjD+sBOMjwK1lKGcGShTnGJ8DxaYM+WWk97/Gk2dKJe3phL75pwGeMvkJrCSCI5mncIJUOK8MOAUr/cuK7e uopi9dTLhaaGdRP90aqiz4fr5933iJ0wxqEUG9MiUwPZMAGPgEaaniNb7/HTre1nMBL12CMQsLPOzDBpsH5kIv/gJGh+BaYlSNVPhOV0ArCpYAuKudG08c1H i9N3iI6p1Zb/kigeSaZbaatSTxPVVT4GVleIlxAPBTVkRmvljI/jHsh+ydjS0w66Ywo= |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 39 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | linux-kernel@vger.kernel.org, David Windsor <dave@nullcore.net>, Pekka Enberg <penberg@kernel.org>, David Rientjes <rientjes@google.com>, Joonsoo Kim <iamjoonsoo.kim@lge.com>, Andrew Morton <akpm@linux-foundation.org>, Laura Abbott <labbott@redhat.com>, Ingo Molnar <mingo@kernel.org>, Mark Rutland <mark.rutland@arm.com>, linux-mm@kvack.org, linux-xfs@vger.kernel.org, linux-fsdevel@vger.kernel.org, netdev@vger.kernel.org, kernel-hardening@lists.openwall.com |
| X-Original-Date | Thu, 21 Sep 2017 10:23:45 -0500 (CDT) |
| X-Original-Message-ID | <alpine.DEB.2.20.1709211022550.14427@nuc-kabylake> |
| X-Original-References | <1505940337-79069-1-git-send-email-keescook@chromium.org> <1505940337-79069-3-git-send-email-keescook@chromium.org> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1736778 |
Show key headers only | View raw
On Wed, 20 Sep 2017, Kees Cook wrote: > diff --git a/mm/slab.c b/mm/slab.c > index 87b6e5e0cdaf..df268999cf02 100644 > --- a/mm/slab.c > +++ b/mm/slab.c > @@ -4408,7 +4408,9 @@ module_init(slab_proc_init); > > #ifdef CONFIG_HARDENED_USERCOPY > /* > - * Rejects objects that are incorrectly sized. > + * Rejects incorrectly sized objects and objects that are to be copied > + * to/from userspace but do not fall entirely within the containing slab > + * cache's usercopy region. > * > * Returns NULL if check passes, otherwise const char * to name of cache > * to indicate an error. > @@ -4428,11 +4430,15 @@ const char *__check_heap_object(const void *ptr, unsigned long n, > /* Find offset within object. */ > offset = ptr - index_to_obj(cachep, page, objnr) - obj_offset(cachep); > > - /* Allow address range falling entirely within object size. */ > - if (offset <= cachep->object_size && n <= cachep->object_size - offset) > - return NULL; > + /* Make sure object falls entirely within cache's usercopy region. */ > + if (offset < cachep->useroffset) > + return cachep->name; > + if (offset - cachep->useroffset > cachep->usersize) > + return cachep->name; > + if (n > cachep->useroffset - offset + cachep->usersize) > + return cachep->name; > > - return cachep->name; > + return NULL; > } > #endif /* CONFIG_HARDENED_USERCOPY */ Looks like this is almost the same for all allocators. Can we put this into mm/slab_common.c?
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH v3 00/31] Hardened usercopy whitelisting Kees Cook <keescook@chromium.org> - 2017-09-20 22:50 +0200
[PATCH v3 26/31] fork: Provide usercopy whitelisting for task_struct Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 15/31] xfs: Define usercopy region in xfs_inode slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 07/31] ext4: Define usercopy region in ext4_inode_cache slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 29/31] arm: Implement thread_struct whitelist for hardened usercopy Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 25/31] fork: Define usercopy region in thread_stack slab caches Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 02/31] usercopy: Enforce slab cache usercopy region boundaries Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
Re: [PATCH v3 02/31] usercopy: Enforce slab cache usercopy region boundaries Christopher Lameter <cl@linux.com> - 2017-09-21 17:30 +0200
[PATCH v3 23/31] net: Restrict unwhitelisted proto caches to size 0 Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 17/31] scsi: Define usercopy region in scsi_sense_cache slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 19/31] ip: Define usercopy region in IP proto slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 28/31] arm64: Implement thread_struct whitelist for hardened usercopy Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 21/31] sctp: Define usercopy region in SCTP proto slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 31/31] lkdtm: Update usercopy tests for whitelisting Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 01/31] usercopy: Prepare for usercopy whitelisting Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
Re: [PATCH v3 01/31] usercopy: Prepare for usercopy whitelisting Christopher Lameter <cl@linux.com> - 2017-09-21 17:30 +0200
[PATCH v3 08/31] ext2: Define usercopy region in ext2_inode_cache slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 18/31] net: Define usercopy region in struct proto slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 24/31] fork: Define usercopy region in mm_struct slab caches Kees Cook <keescook@chromium.org> - 2017-09-20 23:00 +0200
[PATCH v3 04/31] dcache: Define usercopy region in dentry_cache slab cache Kees Cook <keescook@chromium.org> - 2017-09-20 23:10 +0200
[PATCH v3 27/31] x86: Implement thread_struct whitelist for hardened usercopy Kees Cook <keescook@chromium.org> - 2017-09-20 23:10 +0200
[PATCH v3 03/31] usercopy: Mark kmalloc caches as usercopy caches Kees Cook <keescook@chromium.org> - 2017-09-20 23:10 +0200
Re: [PATCH v3 03/31] usercopy: Mark kmalloc caches as usercopy caches Christopher Lameter <cl@linux.com> - 2017-09-21 17:30 +0200
Re: [kernel-hardening] Re: [PATCH v3 03/31] usercopy: Mark kmalloc caches as usercopy caches Kees Cook <keescook@chromium.org> - 2017-09-21 17:50 +0200
Re: [kernel-hardening] Re: [PATCH v3 03/31] usercopy: Mark kmalloc caches as usercopy caches Christopher Lameter <cl@linux.com> - 2017-09-21 18:10 +0200
Re: [kernel-hardening] Re: [PATCH v3 03/31] usercopy: Mark kmalloc caches as usercopy caches Kees Cook <keescook@chromium.org> - 2017-09-21 20:30 +0200
csiph-web