Page MenuHomeFreeBSD

D61858.1795333479.diff
No OneTemporary

Authored By
Unknown
Size
1 KB
Referenced Files
None
Subscribers
None

D61858.1795333479.diff

Index: sys/compat/linux/linux_util.c
===================================================================
--- sys/compat/linux/linux_util.c
+++ sys/compat/linux/linux_util.c
@@ -84,16 +84,18 @@
struct nameidata nd;
int error;
+ /*
+ * We never want the native altroot, in particular, for the
+ * linux_emul_path lookup.
+ */
+ pwd_altroot(td, NULL);
+
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, linux_emul_path);
error = namei(&nd);
- if (error != 0) {
- pwd_altroot(td, NULL);
- return (0);
- }
- NDFREE_PNBUF(&nd);
- error = pwd_altroot(td, nd.ni_vp);
if (error != 0)
- pwd_altroot(td, NULL);
+ return (0);
+ NDFREE_PNBUF(&nd);
+ (void)pwd_altroot(td, nd.ni_vp);
vrele(nd.ni_vp);
return (0);
}
Index: sys/kern/kern_exec.c
===================================================================
--- sys/kern/kern_exec.c
+++ sys/kern/kern_exec.c
@@ -858,11 +858,11 @@
}
/*
- * For security and other reasons, the file descriptor table cannot be
- * shared after an exec.
+ * For security and other reasons, the file descriptor table
+ * cannot be shared after an exec. pwd should not be shared
+ * either, this was handled earlier in exec_new_vmspace().
*/
fdunshare(td);
- pdunshare(td);
/* close files on exec */
fdcloseexec(td);
@@ -1265,6 +1265,13 @@
imgp->vmspace_destroyed = true;
imgp->sysent = sv;
+ /*
+ * Prevent an rforked process, possibly sharing pwd with
+ * us, from being affected by altroot. Exec is already past
+ * the point of no return.
+ */
+ pdunshare(td);
+
/*
* Drop altroot if setuid. It is done so late to avoid
* clearing altroot until there is no way for execve(2) to

File Metadata

Mime Type
text/plain
Expires
Sun, Nov 22, 7:44 AM (6 h, 48 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
41903473
Default Alt Text
D61858.1795333479.diff (1 KB)

Event Timeline