path: root/sys/sys/imgact_binmisc.h
diff options
authorKyle Evans <kevans@FreeBSD.org>2020-11-08 04:24:29 +0000
committerKyle Evans <kevans@FreeBSD.org>2020-11-08 04:24:29 +0000
commit8c28aa5e45d2a1dd4367bd686d22273e1e0d86c7 (patch)
tree57ed9c05b1aa42f48b9a02d49d14309254da7411 /sys/sys/imgact_binmisc.h
parentcc7edd258c2564fe9e3c4a0dc839acc4a71caff9 (diff)
imgact_binmisc: limit the extent of match on incoming entries
imgact_binmisc matches magic/mask from imgp->image_header, which is only a single page in size mapped from the first page of an image. One can specify an interpreter that matches on, e.g., --offset 4096 --size 256 to read up to 256 bytes past the mapped first page. The limitation is that we cannot specify a magic string that exceeds a single page, and we can't allow offset + size to exceed a single page either. A static assert has been added in case someone finds it useful to try and expand the size, but it does seem a little unlikely. While this looks kind of exploitable at a sideways squinty-glance, there are a couple of mitigating factors: 1.) imgact_binmisc is not enabled by default, 2.) entries may only be added by the superuser, 3.) trying to exploit this information to read what's mapped past the end would be worse than a root canal or some other relatably painful experience, and 4.) there's no way one could pull this off without it being completely obvious. The first page is mapped out of an sf_buf, the implementation of which (or lack thereof) depends on your platform. MFC after: 1 week
Notes: svn path=/head/; revision=367477
Diffstat (limited to 'sys/sys/imgact_binmisc.h')
1 files changed, 5 insertions, 0 deletions
diff --git a/sys/sys/imgact_binmisc.h b/sys/sys/imgact_binmisc.h
index add100110fd6..74ff68622075 100644
--- a/sys/sys/imgact_binmisc.h
+++ b/sys/sys/imgact_binmisc.h
@@ -47,6 +47,11 @@
#define IBE_MAX_ENTRIES 64 /* Max number of interpreter entries. */
+/* We only map the first page for identification purposes. */
+_Static_assert(IBE_MAGIC_MAX <= IBE_MATCH_MAX,
+ "Cannot identify binaries past the first page.");
* Imgact bin misc interpreter entry flags.