Commit Graph

5564 Commits

Author SHA1 Message Date
mrg
2449b0a157 include <compat/sys/siginfo.h> for siginfo32_t. 2017-12-18 00:33:32 +00:00
christos
f818d5c42e handle siginfo requests for ptrace32 2017-12-17 20:59:27 +00:00
maxv
e9069ab139 compat_util.c must be compiled by default in the kernel. It is needed by
generic non-compat code, so it must not depend on anything (libcompat or
whatever option we choose to associate it to).
2017-12-16 10:15:12 +00:00
maxv
cd4e50d80d Build these functions regardless of whether COMPAT_50 or COMPAT_70 are
enabled. They must be there, because they are needed in rtsock.c even
when no compat option is enabled.
2017-12-16 09:10:30 +00:00
maxv
b1fa3d10bb Build libcompat as an object, not as a library. We want all of its
functions compiled in, because compat modules loaded from the filesystem
may depend on them.
2017-12-16 08:31:36 +00:00
mrg
56320bfe05 remove check for netbsd 1.5 without 5.0. it doesn't happen. 2017-12-16 07:59:14 +00:00
kre
a2da047f16 Finally (hopefully) return completely to the state where compat_linux is
enabled by default.

While here make it possible to enable this if already enabled, or disable
if already disabled, without error.   Some minor KNF.
2017-12-10 00:43:05 +00:00
kre
9f22166744 Finish the previous change - as well as setting the default for these
compat modules back to enabled, stop forcing it to switch back to
disabled any time the module is init'd (which is truly barbaric behaviour.)
2017-12-08 15:31:13 +00:00
christos
8ff9f539e7 disable 32 bit signal ktrace records; 32 bit traced process produce 64 bit
trace records, the only record that we can't parse is that one :-)
XXX: pullup-8
2017-12-06 19:15:27 +00:00
christos
ce69bf4a1a don't forget to convert the timespec.
XXX: pullup-8
2017-12-06 04:12:25 +00:00
christos
6d44e11a08 Make code look the same, in particular zero out the rest of the directory
record.
XXX: pullup-8
2017-12-03 15:23:30 +00:00
maxv
2180dcb46d Fix uninitialized pointer, found by Mootja. Not a surprise in untested
code.
2017-12-03 12:53:52 +00:00
joerg
c08407dd01 Unbreak Linux emulation by default. While not loading it automatically
is somewhat sensible, breaking functionality of GENERIC is not and has
been objected to on a regular base.
2017-12-01 22:14:52 +00:00
christos
ea05286d92 add fo_name so we can identify the fileops in a simple way. 2017-11-30 20:25:54 +00:00
jmcneill
17b1a5f764 Add support for SIOCGIFGENERIC and SIOCSIFGENERIC ioctls. 2017-11-26 17:46:13 +00:00
martin
3f44d155bc #idef the label next_ifa: just like the only goto using it. 2017-11-22 15:25:34 +00:00
ozaki-r
a78ad86cbf Fix and make consistent of usages of psz/psref in ifconf variants 2017-11-22 10:19:14 +00:00
maxv
f5676abd4d This should be "linux_sg_version", not "version". 2017-11-21 10:45:12 +00:00
kre
41a73baf28 unconst machine_arch32 for sysctl data .. pointed out by Riccardo Mottola 2017-10-31 16:10:25 +00:00
martin
9356c11652 PR kern/52681: fix msghdr conversion. 2017-10-31 12:43:56 +00:00
martin
a6bab1a764 Allow architectures to define a macro PROC_MACHINE_ARCH(P) and
PROC_MACHINE_ARCH32(P) to override the value for sysctl hw.machine_arch
(native and netbsd32 commpat resp.).

Use these for arm and mips instead of the (not working, noisy, in case
of arm) sysctl override and #ifdef __mips__ in architecture neutral
code.
2017-10-31 12:37:23 +00:00
maxv
576743ba1e Include opt_user_ldt.h when needed. 2017-10-21 07:24:26 +00:00
maxv
1fe402e2a1 Always mask the 16 bits of the segregs in the trapframe. We don't zero-
extend the uint64_t's when building it, so we're leaking 48 bits of kernel
stack to userland.

Having said that, it appears that I unintentionally fixed most of this
issue in locore.S::rev1.127 - by building the frame with interrupts
disabled, we are implicitly guaranteeing that the structure doesn't get
overwritten by the kernel. Which means, we are leaking to userland data
that comes from userland anyway.

(still other places with this issue, but I'll fix them differently)
2017-10-19 10:01:09 +00:00
maxv
f10c10f470 Use two separate functions: cpu_segregs32_zero and cpu_segregs64_zero. The
way segment registers work on amd64 will diverge between 32bit and 64bit
LWPs.
2017-10-15 12:49:53 +00:00
maxv
c3992c95be Make sure the 32bit LWPs don't have MDL_IRET set. That's not a problem
right now, but will be in the future.
2017-10-15 11:36:15 +00:00
maxv
252ca9c54a Remove compat_linux32 from the autoload list and add a enable/disable
sysctl, like compat_linux.
2017-09-29 17:47:29 +00:00
maxv
aef145dda9 Remove compat_linux from the autoload list, and add a sysctl to enable or
disable it - which defaults to disabled. The following command is now
required to use linux binaries:

	sysctl -w emul.linux.enabled=1

After a discussion on tech-kern@. All the other ideas to reduce the attack
surface have drawbacks, and this sysctl seems to be the best option.
2017-09-29 17:08:00 +00:00
maxv
7ad103f49c Remove the second argument from USERMODE and KERNELMODE, it is unused
now that we don't have vm86 anymore.
2017-09-17 09:41:35 +00:00
martin
253325b049 Make debug code compile 2017-09-16 09:04:50 +00:00
maxv
5eea203ec8 Fix a subtle ring0 escalation vulnerability in amd64, and implement a
mitigation against similar bugs.

The operations on segment registers can generate a page fault if there is
an issue when touching the in-memory gdt. Theoretically, it is never
supposed to happen, since the gdt is mapped correctly. However, in the
kernel we allow the gdt to be resized, and to do that, we allocate the
maximum amount of va needed by it, but only kenter a few pages until we
need more. Moreover, to avoid reloading the gdt each time we grow it, the
'size' field of gdtr is set to the maximum value. All of this means that
if a mov or iretq is done with a segment register whose index hits a page
that has not been kentered, a page fault is sent.

Such a page fault, if received in kernel mode, does not trigger a swapgs
on amd64; in other words, the kernel would be re-entered with the userland
tls.

And there just happens to be a place in compat_linux32 where the index of
%cs is controlled by userland, making it easy to trigger the page fault
and get kernel privileges.

The mitigation simply consists in abandoning the gdt_grow mechanism and
allocating/kentering the maximum size right away, in such a way that no
page fault can be triggered because of segment registers.
2017-09-02 12:57:03 +00:00
kamil
a69b333e73 Remove the filesystem tracing feature
This is a legacy interface from 4.4BSD, and it was
introduced to overcome shortcomings of ptrace(2) at that time, which are
no longer relevant (performance). Today /proc/#/ctl offers a narrow
subset of ptrace(2) commands and is not applicable for modern
applications use beyond simplistic tracing scenarios.

This removal will simplify kernel internals. Users will still be able to
use all the other /proc files.

This change won't affect other procfs files neither Linux compat
features within mount_procfs(8). /proc/#/ctl isn't available on Linux.

Remove:
 - /proc/#/ctl from mount_procfs(8)
 - P_FSTRACE note from the documentation of ps(1)
 - /proc/#/ctl and filesystem tracing documentation from mount_procfs(8)
 - KAUTH_REQ_PROCESS_PROCFS_CTL documentation from kauth(9)
 - source code file miscfs/procfs/procfs_ctl.c
 - PFSctl and procfs_doctl() from sys/miscfs/procfs/procfs.h
 - KAUTH_REQ_PROCESS_PROCFS_CTL from sys/sys/kauth.h
 - PSL_FSTRACE (0x00010000) from sys/sys/proc.h
 - P_FSTRACE (0x00010000) from sys/sys/sysctl.h

Reduce code complexity after removal of this functionality.

Update TODO.ptrace accordingly: remove two entries about /proc tracing.

Do not keep legacy notes as comments in the headers about removed
PSL_FSTRACE / P_FSTRACE, as this interface had little number of users
(close or equal to zero).

Proposed on tech-kern@.

All filesystem tracing utility users are encouraged to switch to ptrace(2).

Sponsored by <The NetBSD Foundation>
2017-08-28 00:46:06 +00:00
maxv
9e6f33ab7c Remove vm86.
Pass 3.
2017-08-12 07:21:57 +00:00
maxv
7a3268ffdb Remove vm86. Simplifies a number of critical places.
Pass 2.
2017-08-12 07:07:53 +00:00
maxv
9f479233db Remove __i386__. 2017-08-09 18:52:00 +00:00
maxv
0f16c35db3 Move freebsd_machdep.h into sys/compat/freebsd, and don't install it. Now,
the compat_freebsd files are all contained in sys/compat/freebsd.
2017-08-08 08:04:05 +00:00
maxv
7f006e6030 typos 2017-08-04 09:33:03 +00:00
maxv
74ea430004 Move arch/i386/i386/freebsd_* into compat/freebsd/. COMPAT_FREEBSD is
i386-specific.
2017-08-01 14:43:54 +00:00
maxv
6873fa8a0b Remove references to COMPAT_OLDSOCK (itself removed years ago). 2017-07-31 15:38:01 +00:00
christos
34e14598e5 make it compile again. 2017-07-30 12:31:46 +00:00
maxv
02de58a76a Remove exec_aout support in compat_freebsd. The only reason we still have
compat_freebsd is because of tw_cli, and it is an elf32 binary (could test,
manuel sent it to me).
2017-07-29 10:39:48 +00:00
maxv
ebdd118f49 Only compat_43 needs compat_osock. Note that the use of vec_compat_ifioctl
is racy.
2017-07-29 06:12:50 +00:00
riastradh
37bfd4eb93 Kill needless nested extern of vec_compat_cvtcmd/ioctl.
Already declared in if_43.h.
2017-07-29 04:08:47 +00:00
riastradh
cf25436d17 Declare mountcompatnames in sys/vfs_syscalls.h to kill nested extern. 2017-07-29 04:02:49 +00:00
riastradh
d82060bc36 Put suser check in the right function: settimeofday, not gettimeofday.
While here, remove wrong comment.

Noted by kre@.
2017-07-29 02:31:22 +00:00
riastradh
787a001e33 Only let the superuser set the compat_linux timezone.
Not really keen to invent a new kauth cookie for this useless purpose.

From Ilja Van Sprundel.
2017-07-29 01:14:59 +00:00
riastradh
33f11e8b80 Little happy on the commit trigger. Actually use the out label. 2017-07-29 01:14:00 +00:00
riastradh
9fc613c20d Don't drop vnode ref until we're done with mount in ibcs2_stat(v)fs.
Nothing else guarantees the mount will stick around.

From Ilja Van Sprundel.
2017-07-29 01:05:54 +00:00
riastradh
7756a99ec4 Zero buffers in ibcs2 ioctl to avoid disclosing stack to userland.
From Ilja Van Sprundel.
2017-07-28 17:57:48 +00:00
riastradh
ce78c80ccb Check bounds in svr4_sys_putmsg. Check more svr4_strmcmd bounds.
svr4 streams code is still a disaster.

From Ilja Van Sprundel.
2017-07-28 17:52:47 +00:00
riastradh
c5012f3010 Feebly attempt to get this reference counting less bad.
This svr4 streams code is bad and it should feel bad.

From Ilja Van Sprundel.
2017-07-28 17:43:46 +00:00