aboutsummaryrefslogtreecommitdiff
path: root/sys/compat/linux/linux_uid16.c
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2020-08-18 22:04:22 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2020-08-18 22:04:22 +0000
commita125ed50a6c82329997ecf4df593056a8a616cbe (patch)
tree959920e14b4713c09eb4242ab67becdbb888086b /sys/compat/linux/linux_uid16.c
parentd5e3895ea4fe4ef9db8823774e07b4368180a23e (diff)
downloadsrc-a125ed50a6c82329997ecf4df593056a8a616cbe.tar.gz
src-a125ed50a6c82329997ecf4df593056a8a616cbe.zip
linux: add sysctl compat.linux.use_emul_path
This is a step towards facilitating jails with only Linux binaries. Supporting emul_path adds path lookups which are completely spurious if the binary at hand runs in a Linux-based root directory. It defaults to on (== current behavior). make -C /root/linux-5.3-rc8 -s -j 1 bzImage: use_emul_path=1: 101.65s user 68.68s system 100% cpu 2:49.62 total use_emul_path=0: 101.41s user 64.32s system 100% cpu 2:45.02 total
Notes
Notes: svn path=/head/; revision=364366
Diffstat (limited to 'sys/compat/linux/linux_uid16.c')
-rw-r--r--sys/compat/linux/linux_uid16.c71
1 files changed, 39 insertions, 32 deletions
diff --git a/sys/compat/linux/linux_uid16.c b/sys/compat/linux/linux_uid16.c
index d58184ed4460..0d1e782b7efa 100644
--- a/sys/compat/linux/linux_uid16.c
+++ b/sys/compat/linux/linux_uid16.c
@@ -112,22 +112,25 @@ linux_chown16(struct thread *td, struct linux_chown16_args *args)
char *path;
int error;
- LCONVPATHEXIST(td, args->path, &path);
-
- /*
- * The DTrace probes have to be after the LCONVPATHEXIST, as
- * LCONVPATHEXIST may return on its own and we do not want to
- * have a stray entry without the corresponding return.
- */
- LIN_SDT_PROBE3(uid16, linux_chown16, entry, args->path, args->uid,
- args->gid);
- LIN_SDT_PROBE1(uid16, linux_chown16, conv_path, path);
-
- error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
- CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), 0);
- LFREEPATH(path);
-
- LIN_SDT_PROBE1(uid16, linux_chown16, return, error);
+ if (!LUSECONVPATH(td) && !SDT_PROBES_ENABLED()) {
+ error = kern_fchownat(td, AT_FDCWD, args->path, UIO_USERSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), 0);
+ } else {
+ LCONVPATHEXIST(td, args->path, &path);
+ /*
+ * The DTrace probes have to be after the LCONVPATHEXIST, as
+ * LCONVPATHEXIST may return on its own and we do not want to
+ * have a stray entry without the corresponding return.
+ */
+ LIN_SDT_PROBE3(uid16, linux_chown16, entry, args->path, args->uid,
+ args->gid);
+ LIN_SDT_PROBE1(uid16, linux_chown16, conv_path, path);
+
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), 0);
+ LFREEPATH(path);
+ LIN_SDT_PROBE1(uid16, linux_chown16, return, error);
+ }
return (error);
}
@@ -137,22 +140,26 @@ linux_lchown16(struct thread *td, struct linux_lchown16_args *args)
char *path;
int error;
- LCONVPATHEXIST(td, args->path, &path);
-
- /*
- * The DTrace probes have to be after the LCONVPATHEXIST, as
- * LCONVPATHEXIST may return on its own and we do not want to
- * have a stray entry without the corresponding return.
- */
- LIN_SDT_PROBE3(uid16, linux_lchown16, entry, args->path, args->uid,
- args->gid);
- LIN_SDT_PROBE1(uid16, linux_lchown16, conv_path, path);
-
- error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
- CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), AT_SYMLINK_NOFOLLOW);
- LFREEPATH(path);
-
- LIN_SDT_PROBE1(uid16, linux_lchown16, return, error);
+ if (!LUSECONVPATH(td) && !SDT_PROBES_ENABLED()) {
+ error = kern_fchownat(td, AT_FDCWD, args->path, UIO_USERSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), AT_SYMLINK_NOFOLLOW);
+ } else {
+ LCONVPATHEXIST(td, args->path, &path);
+
+ /*
+ * The DTrace probes have to be after the LCONVPATHEXIST, as
+ * LCONVPATHEXIST may return on its own and we do not want to
+ * have a stray entry without the corresponding return.
+ */
+ LIN_SDT_PROBE3(uid16, linux_lchown16, entry, args->path, args->uid,
+ args->gid);
+ LIN_SDT_PROBE1(uid16, linux_lchown16, conv_path, path);
+
+ error = kern_fchownat(td, AT_FDCWD, path, UIO_SYSSPACE,
+ CAST_NOCHG(args->uid), CAST_NOCHG(args->gid), AT_SYMLINK_NOFOLLOW);
+ LFREEPATH(path);
+ LIN_SDT_PROBE1(uid16, linux_lchown16, return, error);
+ }
return (error);
}