Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F178095010
D62075.1795945062.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None
D62075.1795945062.diff
View Options
diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c
--- a/sys/kern/imgact_elf.c
+++ b/sys/kern/imgact_elf.c
@@ -1012,6 +1012,14 @@
return (0);
}
+/*
+ * Maximum size of the PT_INTERP segment. Linux accepts up to PATH_MAX
+ * (4096) bytes, and some toolchains (e.g. the Yocto/Poky relocatable
+ * SDK) NUL-pad the interpreter path out to that size so that it can be
+ * rewritten in place. The path itself must still fit in MAXPATHLEN.
+ */
+#define ELF_INTERP_MAXSZ 4096
+
static int
__elfN(get_interp)(struct image_params *imgp, const Elf_Phdr *phdr,
char **interpp, bool *free_interpp)
@@ -1024,7 +1032,7 @@
ASSERT_VOP_LOCKED(imgp->vp, __func__);
/* Path to interpreter */
- if (phdr->p_filesz < 2 || phdr->p_filesz > MAXPATHLEN) {
+ if (phdr->p_filesz < 2 || phdr->p_filesz > ELF_INTERP_MAXSZ) {
uprintf("Invalid PT_INTERP\n");
return (ENOEXEC);
}
@@ -1058,6 +1066,11 @@
return (error);
}
interp[interp_name_len] = '\0';
+ if (strnlen(interp, MAXPATHLEN) >= MAXPATHLEN) {
+ free(interp, M_TEMP);
+ uprintf("Invalid PT_INTERP\n");
+ return (ENOEXEC);
+ }
*interpp = interp;
*free_interpp = true;
@@ -1065,7 +1078,8 @@
}
interp = __DECONST(char *, imgp->image_header) + phdr->p_offset;
- if (interp[interp_name_len - 1] != '\0') {
+ if (interp[interp_name_len - 1] != '\0' ||
+ strnlen(interp, MAXPATHLEN) >= MAXPATHLEN) {
uprintf("Invalid PT_INTERP\n");
return (ENOEXEC);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 29, 9:37 AM (6 h, 22 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
42032538
Default Alt Text
D62075.1795945062.diff (1 KB)
Attached To
Mode
D62075: imgact_elf: accept PT_INTERP segments up to 4096 bytes
Attached
Detach File
Event Timeline