Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F105815587
D33616.id100463.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D33616.id100463.diff
View Options
Index: sys/kern/kern_jail.c
===================================================================
--- sys/kern/kern_jail.c
+++ sys/kern/kern_jail.c
@@ -239,6 +239,8 @@
{
uint8_t *file, *data;
size_t size;
+ char buf[sizeof(prison0.pr_hostuuid)];
+ bool valid;
prison0.pr_cpuset = cpuset_ref(thread0.td_cpuset);
prison0.pr_osreldate = osreldate;
@@ -258,10 +260,31 @@
while (size > 0 && data[size - 1] <= 0x20) {
size--;
}
- if (validate_uuid(data, size, NULL, 0) == 0) {
- (void)strlcpy(prison0.pr_hostuuid, data,
- size + 1);
- } else if (bootverbose) {
+
+ valid = false;
+
+ /*
+ * Not NUL-terminated when passed from loader, but
+ * validate_uuid requires that due to using sscanf (as
+ * does the subsequent strlcpy, since it still reads
+ * past the given size to return the true length);
+ * bounce to a temporary buffer to fix.
+ */
+ if (size >= sizeof(buf))
+ goto done;
+
+ memcpy(buf, data, size);
+ buf[size] = '\0';
+
+ if (validate_uuid(buf, size, NULL, 0) != 0)
+ goto done;
+
+ valid = true;
+ (void)strlcpy(prison0.pr_hostuuid, buf,
+ sizeof(prison0.pr_hostuuid));
+
+done:
+ if (bootverbose && !valid) {
printf("hostuuid: preload data malformed: '%.*s'\n",
(int)size, data);
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 2:52 AM (21 h, 2 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15550133
Default Alt Text
D33616.id100463.diff (1 KB)
Attached To
Mode
D33616: Fix buffer overread in preloaded hostuuid parsing
Attached
Detach File
Event Timeline
Log In to Comment