Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1736127
| From | Kees Cook <keescook@chromium.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | [PATCH v3 17/31] scsi: Define usercopy region in scsi_sense_cache slab cache |
| Date | 2017-09-20 23:00 +0200 |
| Message-ID | <urUga-855-43@gated-at.bofh.it> (permalink) |
| References | <urU6t-818-3@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
From: David Windsor <dave@nullcore.net>
SCSI sense buffers, stored in struct scsi_cmnd.sense and therefore
contained in the scsi_sense_cache slab cache, need to be copied to/from
userspace.
cache object allocation:
drivers/scsi/scsi_lib.c:
scsi_select_sense_cache(...):
return ... ? scsi_sense_isadma_cache : scsi_sense_cache
scsi_alloc_sense_buffer(...):
return kmem_cache_alloc_node(scsi_select_sense_cache(), ...);
scsi_init_request(...):
...
cmd->sense_buffer = scsi_alloc_sense_buffer(...);
...
cmd->req.sense = cmd->sense_buffer
example usage trace:
block/scsi_ioctl.c:
(inline from sg_io)
blk_complete_sghdr_rq(...):
struct scsi_request *req = scsi_req(rq);
...
copy_to_user(..., req->sense, len)
scsi_cmd_ioctl(...):
sg_io(...);
In support of usercopy hardening, this patch defines a region in
the scsi_sense_cache slab cache in which userspace copy operations
are allowed.
This region is known as the slab cache's usercopy region. Slab
caches can now check that each copy operation involving cache-managed
memory falls entirely within the slab's usercopy region.
Signed-off-by: David Windsor <dave@nullcore.net>
[kees: adjust commit log, provide usage trace]
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
---
drivers/scsi/scsi_lib.c | 9 +++++----
1 file changed, 5 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 9cf6a80fe297..88bfab251693 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -79,14 +79,15 @@ int scsi_init_sense_cache(struct Scsi_Host *shost)
if (shost->unchecked_isa_dma) {
scsi_sense_isadma_cache =
kmem_cache_create("scsi_sense_cache(DMA)",
- SCSI_SENSE_BUFFERSIZE, 0,
- SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA, NULL);
+ SCSI_SENSE_BUFFERSIZE, 0,
+ SLAB_HWCACHE_ALIGN | SLAB_CACHE_DMA, NULL);
if (!scsi_sense_isadma_cache)
ret = -ENOMEM;
} else {
scsi_sense_cache =
- kmem_cache_create("scsi_sense_cache",
- SCSI_SENSE_BUFFERSIZE, 0, SLAB_HWCACHE_ALIGN, NULL);
+ kmem_cache_create_usercopy("scsi_sense_cache",
+ SCSI_SENSE_BUFFERSIZE, 0, SLAB_HWCACHE_ALIGN,
+ 0, SCSI_SENSE_BUFFERSIZE, NULL);
if (!scsi_sense_cache)
ret = -ENOMEM;
}
--
2.7.4
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