summaryrefslogtreecommitdiff
path: root/sys/compat/common
AgeCommit message (Collapse)Author
2022-08-03Apply patch, requested by riastradh in ticket #1487:martin
sys/compat/common/vfs_syscalls_20.c (apply patch) sys/compat: Memset zero before copyout. Just in case of uninitialized padding which would lead to kernel stack disclosure. If the compiler can prove the memset redundant then it can optimize it away; otherwise better safe than sorry.
2022-08-03Pull up following revision(s), all via patchmartin
(requested by riastradh in ticket #1487): sys/compat/linux/arch/i386/linux_machdep.c: revision 1.168 sys/compat/sunos/sunos_misc.c: revision 1.177 sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.52 sys/compat/common/kern_resource_43.c: revision 1.23 sys/compat/netbsd32/netbsd32_conv.h: revision 1.46 sys/compat/linux/arch/i386/linux_ptrace.c: revision 1.35 sys/compat/common/vfs_syscalls_12.c: revision 1.38 sys/compat/ultrix/ultrix_misc.c: revision 1.126 sys/compat/common/kern_sig_43.c: revision 1.37 sys/compat/linux/common/linux_mtio.c: revision 1.8 sys/compat/freebsd/freebsd_misc.c: revision 1.34 sys/compat/freebsd/freebsd_machdep.c: revision 1.5 sys/compat/linux/common/linux_olduname.c: revision 1.67 sys/compat/linux/arch/mips/linux_machdep.c: revision 1.44 sys/compat/freebsd/freebsd_sched.c: revision 1.23 sys/compat/ossaudio/ossaudio.c: revision 1.84 sys/compat/sys/time_types.h: revision 1.6 sys/compat/linux/arch/powerpc/linux_machdep.c: revision 1.51 sys/compat/common/ieee80211_20.c: revision 1.7 sys/compat/linux/common/linux_file.c: revision 1.119 sys/compat/linux/arch/arm/linux_machdep.c: revision 1.34 sys/compat/netbsd32/netbsd32_wait.c: revision 1.25 sys/compat/linux32/common/linux32_time.c: revision 1.38 sys/compat/linux/arch/powerpc/linux_ptrace.c: revision 1.33 sys/compat/linux/arch/alpha/linux_machdep.c: revision 1.52 sys/compat/linux32/arch/amd64/linux32_machdep.c: revision 1.46 sys/compat/netbsd32/netbsd32_compat_12.c: revision 1.36 sys/compat/ultrix/ultrix_ioctl.c: revision 1.39 sys/compat/linux/common/linux_misc.c: revision 1.252 sys/compat/linux/common/linux_hdio.c: revision 1.19 sys/compat/sunos/sunos_ioctl.c: revision 1.71 sys/compat/linux/common/linux_sched.c: revision 1.79 sys/compat/common/kern_info_43.c: revision 1.40 sys/compat/linux32/common/linux32_exec_elf32.c: revision 1.20 sys/compat/linux/common/linux_socket.c: revision 1.153 sys/compat/linux/arch/amd64/linux_machdep.c: revision 1.60 sys/compat/common/vfs_syscalls_43.c: revision 1.68 sys/compat/linux/arch/powerpc/linux_exec_powerpc.c: revision 1.25 sys/compat/netbsd32/netbsd32_ptrace.c: revision 1.9 sys/compat/common/kern_time_50.c: revision 1.37 sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.42 sys/compat/linux/common/linux_cdrom.c: revision 1.28 sys/compat/linux/arch/m68k/linux_machdep.c: revision 1.43 sys/compat/common/kern_info_09.c: revision 1.22 sys/compat/linux32/common/linux32_resource.c: revision 1.12 sys/compat/linux/common/linux_oldolduname.c: revision 1.67 sys/compat/common/if_media_80.c: revision 1.4 sys/compat/linux/arch/alpha/linux_osf1.c: revision 1.5 sys/compat/netbsd32/netbsd32_nfssvc.c: revision 1.8 sys/compat/linux32/common/linux32_signal.c: revision 1.21 sys/compat/common/kern_sig_13.c: revision 1.22 sys/compat/sunos32/sunos32_ioctl.c: revision 1.36 sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.62 sys/compat/linux/arch/arm/linux_ptrace.c: revision 1.23 sys/compat/netbsd32/netbsd32_time.c: revision 1.56 sys/compat/linux/common/linux_signal.c: revision 1.84 sys/compat/netbsd32/netbsd32_signal.c: revision 1.52 sys/compat/sunos32/sunos32_misc.c: revision 1.85 sys/compat/linux/common/linux_time.c: revision 1.40 sys/compat/linux/common/linux_fdio.c: revision 1.14 sys/compat/common/vfs_syscalls_30.c: revision 1.43 sys/compat: Memset zero before copyout. Just in case of uninitialized padding which would lead to kernel stack disclosure. If the compiler can prove the memset redundant then it can optimize it away; otherwise better safe than sorry.
2021-08-15Pull up following revision(s) (requested by christos in ticket #1337):martin
sys/compat/common/vfs_syscalls_43.c: revision 1.67 sys/compat/common/vfs_syscalls_50.c: revision 1.26 sys/compat/common/vfs_syscalls_30.c: revision 1.42 - memset struct stat to avoid kernel memory disclosure of padded fields (thanks Trend Micro for the report) - use do_fhstat - consistency in argument order of compat functions
2020-10-10Pull up following revision(s) (requested by nia in ticket #1106):martin
sys/compat/common/tty_43.c: revision 1.38 tty_43: Check a bitset from userspace is valid before shifting it Passing a negative value to these legacy compat ioctls results in left shift on a negative value which is undefined behaviour and results in the tty (at least, possibly other things) locking up. The argument to the ioctl should always be > 0. Return EINVAL otherwise. While here, adjustments to code style to match current guidelines. Found by UBSan.
2020-07-17Pull up following revision(s) (requested by msaitoh in ticket #1018):martin
sys/net/if.c: revision 1.479 sys/compat/common/uipc_syscalls_40.c: revision 1.23 sys/compat/linux/common/linux_socket.c: revision 1.150 sys/compat/linux32/common/linux32_socket.c: revision 1.31 Don't accept negative value.
2020-02-27Pull up following revision(s) (requested by pgoyette in ticket #741):martin
sys/compat/common/vfs_syscalls_43.c: revision 1.65 Include all of the vfs syscalls in the syscall_package, not just oquota. Should fix PR kern/55025 XXX pullup-9
2020-01-02Pull up following revision(s) (requested by maxv in ticket #597):martin
sys/compat/common/kern_sig_43.c: revision 1.36 sys/compat/netbsd32/netbsd32_compat_20.c: revision 1.39 sys/compat/netbsd32/netbsd32_compat_43.c: revision 1.59 sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.44 Fix sizeof mismatch in copyin. This leads to a user-triggerable stack overflow. On my test build at least, by luck, the compiler orders the variables in a way that the overflow hits only local structures which haven't yet been initialized and used, so the overflow is harmless. Very easily seeable with kASan - just invoke the syscall from a 32bit binary. Fix three stack info leaks, found by kMSan when just invoking all syscalls with a zero page as argument. MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb32' From compat_20_netbsd32_getfsstat() MSan: Uninitialized Stack Memory In copyout() At Offset 12, Variable 'oss' From compat_43_sys_sigstack() MSan: Uninitialized Stack Memory In copyout() At Offset 0, Variable 'sb' From compat_50_netbsd32___fhstat40()
2019-12-29Pull up following revision(s) (requested by pgoyette in ticket #588):martin
sys/compat/common/compat_30_mod.c: revision 1.3 For the built-in COMPAT_30 module code, make sure to initialize the uipc_syscalls_30 stuff, notably to include compat_30_socket(). PR kern/54804 XXX Pullup-9 XXX
2019-12-18Pull up following revision(s) (requested by tsutsui in ticket #570):martin
sys/compat/netbsd32/netbsd32_compat_50_sysv.c: revision 1.3 sys/dev/raidframe/rf_compat50.h: revision 1.6 sys/arch/emips/emips/bus_space.c: revision 1.3 sys/compat/net/if.h: revision 1.5 sys/arch/emips/stand/common/bootinfo.c: revision 1.2 sys/compat/common/sysv_msg_50.c: revision 1.5 sys/compat/common/kern_time_30.c: revision 1.8 sys/arch/emips/stand/common/bootinfo.h: revision 1.2 sys/arch/ia64/include/bus.h: revision 1.4 sys/arch/ia64/ia64/bus_space.c: revision 1.2 sys/compat/common/sysv_shm_50.c: revision 1.5 sys/dev/ic/adw.h: revision 1.15 sys/compat/common/uipc_syscalls_50.c: revision 1.10 sys/arch/emips/ebus/flash_ebus.c: revision 1.22 sys/dev/ic/adv.h: revision 1.15 sys/dev/ic/adwmcode.c: revision 1.18 sys/dev/ic/advlib.c: revision 1.29 sys/arch/hpcarm/include/kloader.h: revision 1.3 sys/dev/usb/uberry.c: revision 1.16 sys/compat/common/sysv_sem_50.c: revision 1.5 sys/compat/netbsd32/netbsd32_compat_50.c: revision 1.43 sys/dev/ic/advlib.h: revision 1.21 sys/dev/ic/adv.c: revision 1.50 sys/compat/netinet6/in6_var.h: revision 1.5 sys/arch/hpc/stand/hpcboot/arm/arm_sa1100_asm.asm: revision 1.2 sys/arch/emips/include/loadfile_machdep.h: revision 1.3 sys/arch/emips/stand/common/prom_iface.c: revision 1.7 sys/dev/ic/adw.c: revision 1.56 sys/dev/ic/adwmcode.h: revision 1.12 sys/dev/ic/advmcode.c: revision 1.10 sys/arch/emips/ebus/ace_ebus.c: revision 1.22 sys/compat/netbsd32/netbsd32_compat_60.c: revision 1.5 sys/dev/raidframe/rf_compat50.c: revision 1.13 sys/arch/x68k/dev/intiovar.h: revision 1.15 sys/dev/usb/uipad.c: revision 1.8 sys/arch/zaurus/include/kloader.h: revision 1.3 sys/arch/emips/stand/common/bootxx.c: revision 1.2 sys/dev/ic/adwlib.h: revision 1.23 sys/dev/ic/adwlib.c: revision 1.44 sys/compat/netbsd32/netbsd32_compat_16.c: revision 1.3 sys/arch/amigappc/include/intr.h: revision 1.27 sys/arch/x68k/dev/mfp.c: revision 1.27 sys/arch/arm/at91/at91dbgu.c: revision 1.17 sys/dev/ic/advmcode.h: revision 1.7 sys/compat/ultrix/ultrix_exec.h: revision 1.7 sys/compat/common/vfs_syscalls_50.c: revision 1.24 sys/arch/mips/cavium/octeon_dma.c: revision 1.3 sys/arch/hpc/stand/hpcboot/arm/arm_pxa2x0_asm.asm: revision 1.2 Remove clause 3 and 4 from TNF licenses. Ok'ed by martin@ in PR/54760. Remove clause 3 and 4 leftovers from TNF licenses in more sources. Confirmed by martin@ in PR/54760.
2019-11-11Pull up following revision(s) (requested by pgoyette in ticket #413):martin
sys/kern/kern_core.c: revision 1.27 (patch) sys/kern/kern_sig.c: revision 1.377 (patch) sys/kern/kern_sig.c: revision 1.378 (patch) sys/kern/sys_sig.c: revision 1.50 sys/kern/sys_ptrace_common.c: revision 1.70 sys/kern/compat_stub.c: revision 1.16 sys/compat/common/kern_sig_16.c: revision 1.4 sys/kern/compat_stub.c: revision 1.17 sys/sys/compat_stub.h: revision 1.20 sys/sys/signalvar.h: revision 1.98 sys/sys/compat_stub.h: revision 1.21 sys/sys/signalvar.h: revision 1.99 Convert the sendsig_sigcontext_16 function pointer to use the new compat_hook mechanism. XXX Despite being a kernel<-->module abi change, this should be XXX pulled up to -9 - Convert the coredump_vec modular function pointer to use the new compat_hook mechanism. XXX Should be pulled up to -9 despite the kernel <--> module ABI XXX change.
2019-10-21Pull up following revision(s) (requested by pgoyette in ticket #339):martin
sys/compat/common/kern_uipc_socket_50.c: revision 1.3 sys/sys/compat_stub.h: revision 1.19 sys/kern/uipc_socket.c: revision 1.284 Actually return the updated pointer-to-mbuf-pointer to the caller rather than discarding-after-assignment. Introduced from the [pgoyette-compat] branch work.
2019-06-18Drop unused retval pointer from do_sys_mknod{,at}()kamil
No functional change intended.
2019-06-17Add QUOTA ifdef (Paul Goyette)christos
2019-06-17Use tabs, not spaces, for indentation. NFCIpgoyette
2019-06-17If we don't compile a kernel with QUOTA, we don't support the compat quotachristos
syscalls. XXX: need to fix the modules build.
2019-05-17 The max subtype of the ifmedia word is 31. It's too small for Ethernet now.msaitoh
We currently use use it up to 30. We should extend the limit to be able to use more than 10Gbps speeds. Our ifmedia(4) is inconvenience and have some problem so we should redesign the interface, but it's too late for netbsd-9 to do it. So, we keep the data structure size and modify the structure a bit. The strategy is almost the same as FreeBSD. Many bits of IFM_OMASK for Ethernet have not used, so use some of them for Ethernet's subtype. The differences against FreeBSD are: - We use NetBSD style compat code (i.e. no SIOCGIFXMEDIA). - FreeBSD's IFM_ETH_XTYPE's bit location is from 11 to "14" even though IFM_OMASK is from 8 to "15". We use _IFM_ETH_XTMASK from bit 13 to "15". - FreeBSD changed the meaning of IFM_TYPE_MATCH(). I think we should not do it. We keep it not changing and added new IFM_TYPE_SUBTYPE_MATCH() macro for matching both TYPE and SUBTYPE. - Added up to 400GBASE-SR16. New layout of the media word is as follows (from ifmedia_h): * if_media Options word: * Bits Use * ---- ------- * 0-4 Media subtype MAX SUBTYPE == 255 for ETH and 31 for others * 5-7 Media type * 8-15 Type specific options * 16-18 Mode (for multi-mode devices) * 19 (Reserved for Future Use) * 20-27 Shared (global) options * 28-31 Instance * * 3 2 1 * 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 * +-------+---------------+-+-----+---------------+-----+---------+ * | | |R| | | | | * | IMASK | GMASK |F|MMASK+-----+ OMASK |NMASK| TMASK | * | | |U| |XTMSK| | | | * +-------+---------------+-+-----+-----+---------+-----+---------+ * <-----> <---> <---> * IFM_INST() IFM_MODE() IFM_TYPE() * * IFM_SUBTYPE(other than ETH)<-------> * * <---> IFM_SUBTYPE(ETH)<-------> * * * <-------------> <-------------> * IFM_OPTIONS()
2019-04-29Introduce rt_addrmsg_src which adds RTA_AUTHOR to the message.roy
Use this when we notify userland of a duplicate address and set RTA_AUTHOR to the hardware address of the sender. While here, match the logging diagnostic of INET6 to the simpler one of INET so it's consistent.
2019-04-29rtsock: Route address message simplificationroy
Rename rt_newaddrmsg to rt_addrmsg_rt. Add rt_addrmsg which drops the error and route arguments which are only needed by one caller.
2019-04-29Move the set-up of the net.oroute... sysctl tree to compat_50 sincepgoyette
the new AF_ROUTE was introduced in NetBSD-6.0
2019-04-29For the rtsock compat code, make sure we create the "oroute" sysctlpgoyette
tree. Otherwise a 5.2 version of getifaddrs(2) gets errors. This makes the 5.2 version of ifconfig(8) behave the same on both NetBSD-8 and -current. HOWEVER, both of them print nothing (for ``ifconfig -l'' command) so there's still a bug somewhere. As reported originally by der Mouse.
2019-04-23 KNF. No functional change.msaitoh
2019-04-18Zero out the ifreq struct for SIOCGIFCONF to avoid up to 127 bytes of stackchristos
disclosure. From Andy Nguyen, many thanks! This is the compat code part pointed out by ozaki-r@
2019-04-17 KNF. No functional change.msaitoh
2019-04-16Rename ifreqo2n() and ifreqo2n() to IFREQO2N_43() and IFREQN2O_43():msaitoh
- ifreqo2n() and ifreqn2o() are for COMPAT_43, so add _43 to the name. - Uppercase to make it clear those are macros.
2019-04-15Clean up this mess and simplify, so that all the socket options getpgoyette
handled correctly whether or not the compat_50 module is loaded.
2019-04-15Split the COMPAT_50 socket-timeout stuff out of kern/uipc_socket.cpgoyette
and into its own source file, which is now included in the compat_50 module. (Not sure how this got missed during the original [pgoyette-compat] work)
2019-04-14Only need to #include sys/vnode.h oncepgoyette
2019-03-01Rename the MODULE_*_HOOK() macros to MODULE_HOOK_*() as brieflypgoyette
discussed on irc. NFCI intended. Ride the earlier kernel bump - it;s getting crowded.
2019-01-29Normalize all the compat hooks' names to the formpgoyette
<subsystem>_<function>_<version>_hook NFCI XXX Note that although this introduces a change in the kernel-to- XXX module interface, we are NOT bumping the kernel version number. XXX We will bump the version number once the interface stabilizes.
2019-01-29Rename the if43_20_hook to if43_cvtcmd_20_hookpgoyette
2019-01-29The if43_20_hook function returns an errno; use it to determine whetherpgoyette
to allow conversion of the ioctl cmd --> ncmd Should address issue reported by msaitoh@ on irc as well as via e-mail from Patrick Welche and Ryo ONODERA.
2019-01-28- Don't expose random data conversion functions, but expose the high levelchristos
entry point (such as ioctl) instead. - Attempt to autoload the module before using it. Naming: Should the names of the hooks be: <category>_<version>_<function>_hook_t or: <category>_<function>_<version>_hook_t We should make those consistent.
2019-01-28- provide a hook for the 43 tty ioctlschristos
- make the 60 tty ioctl hook look the same - fix the tty code to call both hooks and remove unused lock
2019-01-27Include new header from correct directorypgoyette
2019-01-27- autoload the compat_80 for modstatchristos
- move compat struct to a compat header
2019-01-27make this compile again (enable #if 0 code)christos
2019-01-27Merge the [pgoyette-compat] branchpgoyette
2018-10-30Paranoia: zero COMPAT_30 ntptimeval and 32-bit ntptimeval too.riastradh
These structs don't have padding but safer to keep the code structured the same way between the various ntp_gettimes in case anyone makes more copypasta of it for future updates.
2018-10-30Zero ntptimeval50 too to prevent 4-byte kernel stack disclosure.riastradh
From Thomas Barabosch of Fraunhofer FKIE. XXX pullup-7, pullup-8 (along with rev. 1.60 of kern_ntptime.c)
2018-09-12 Fix a bug that SIOC[GZ]IFDATA returned old ifreq structure.msaitoh
2018-09-06Remove the network ATM code.maxv
2018-09-03Rename min/max -> uimin/uimax for better honesty.riastradh
These functions are defined on unsigned int. The generic name min/max should not silently truncate to 32 bits on 64-bit systems. This is purely a name change -- no functional change intended. HOWEVER! Some subsystems have #define min(a, b) ((a) < (b) ? (a) : (b)) #define max(a, b) ((a) > (b) ? (a) : (b)) even though our standard name for that is MIN/MAX. Although these may invite multiple evaluation bugs, these do _not_ cause integer truncation. To avoid `fixing' these cases, I first changed the name in libkern, and then compile-tested every file where min/max occurred in order to confirm that it failed -- and thus confirm that nothing shadowed min/max -- before changing it. I have left a handful of bootloaders that are too annoying to compile-test, and some dead code: cobalt ews4800mips hp300 hppa ia64 luna68k vax acorn32/if_ie.c (not included in any kernels) macppc/if_gm.c (superseded by gem(4)) It should be easy to fix the fallout once identified -- this way of doing things fails safe, and the goal here, after all, is to _avoid_ silent integer truncations, not introduce them. Maybe one day we can reintroduce min/max as type-generic things that never silently truncate. But we should avoid doing that for a while, so that existing code has a chance to be detected by the compiler for conversion to uimin/uimax without changing the semantics until we can properly audit it all. (Who knows, maybe in some cases integer truncation is actually intended!)
2018-06-05use the standard rules, instead of rolling our own.christos
2018-05-27- Introduce :q modifier for make variables and make it double escape $'s sochristos
that passing variables to recursive makes with :q works as expected. - Revert :Q to work as before. - Adjust makefiles that use recursive make to use :q Discussed on tech-toolchain@ XXX: pullup 8
2018-05-10Added missing ifi_link_state at compat_50_rt_oifmsg() and compat_50_iflist().nonaka
2018-05-04Clean up a stray #ifdef _MODULE - it prevented definition ofpgoyette
COMPAT_SIGCONTEXT which in turn prevented building of the SYS_compat16_sigaction_14 code. Should address PR kern/53260 XXX Pull-up to netbsd-8
2018-05-03Fix COMPAT_NETBSD32 cmsg handling:christos
1. alignment was wrong for > 1 message 2. macros were doing incorrect pointer comparisons, fortunately ending the iteration early after the fists cmsg instead of crashing. 3. don't output 32 bit ktrace records for cmsg. 32 bit programs running under emulation on 64 bit systems should produce 64 bit ktrace records so that the native ktrace can handle the records; remove extra arguments that are now not needed (the 32 bit msghdr). 4. output the correct type for cmsg trace records. 5. output all the cmsg records in traces instead of just the first one. Welcome to 8.99.15 because of the argument removal. XXX: Really all the code should be changed to use the CMSG_{FIRST,NXT}HDR macros...
2018-04-26Test for valid interface for ioctls that demand it.roy
Thanks to Robert Swindells for the patch.
2018-04-12If we are modular, allow us to use modules for compat; don't load all thechristos
compat code in.
2018-04-12provide vectors for the ifconf compat code and ifdatareq compat code.christos