summaryrefslogtreecommitdiffstats
path: root/sys/compat
Commit message (Collapse)AuthorAgeFilesLines
* Rename P_KTHREAD struct proc p_flag to P_KPROC.kib2016-02-091-1/+1
| | | | | | | | I left as is an apparent bug in ntoskrnl_var.h:AT_PASSIVE_LEVEL() definition. Suggested by: jhb Sponsored by: The FreeBSD Foundation
* fork: plug a use after free of the returned processmjg2016-02-041-2/+0
| | | | | | | | | | | | | | fork1 required its callers to pass a pointer to struct proc * which would be set to the new process (if any). procdesc and racct manipulation also used said pointer. However, the process could have exited prior to do_fork return and be automatically reaped, thus making this a use-after-free. Fix the problem by letting callers indicate whether they want the pid or the struct proc, return the process in stopped state for the latter case. Reviewed by: kib
* fork: pass arguments to fork1 in a dedicated structuremjg2016-02-042-6/+22
| | | | Suggested by: kib
* Update and add various macros to the LinuxKPI and resolve a macrohselasky2016-01-265-9/+17
| | | | | | | | redefinition issue in the cxgb driver. MFC after: 1 week Sponsored by: Mellanox Technologies Reviewed by: np @
* LinuxKPI list updates:hselasky2016-01-262-36/+62
| | | | | | | | | | | | | | | - Add some new hlist macros. - Update existing hlist macros removing the need for a temporary iteration variable. - Properly define the RCU hlist macros to be SMP safe with regard to RCU. - Safe list macro arguments by adding a pair of parentheses. - Prefix the _list_add() and _list_splice() functions with "linux" to reflect they are LinuxKPI internal functions. Obtained from: Linux MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement ether_addr_equal(), ether_addr_equal_64bits() andhselasky2016-01-261-0/+24
| | | | | | | random_ether_addr() for the LinuxKPI. MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement is_vlan_dev() and vlan_dev_vlan_id() for the LinuxKPI.hselasky2016-01-261-1/+18
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement bitmap_weight() and bitmap_equal() for the LinuxKPI.hselasky2016-01-261-1/+31
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Add more network related macros and functions to the LinuxKPI.hselasky2016-01-261-0/+15
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Add definition for the NETDEV_CHANGE event and tidy up the LinuxKPIhselasky2016-01-261-19/+17
| | | | | | | notifier header file a bit while at it. MFC after: 1 week Sponsored by: Mellanox Technologies
* Define __get_user() and __put_user() for the LinuxKPI.hselasky2016-01-261-1/+12
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Add more LinuxKPI PCI related functions and defines.hselasky2016-01-261-56/+51
| | | | | | | Removed comments deriving from Linux. MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement 64-bit atomic operations for the LinuxKPI.hselasky2016-01-211-0/+104
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* LinuxKPI atomic fixes:hselasky2016-01-212-22/+22
| | | | | | | | | | | | - Fix implementation of atomic_add_unless(). The atomic_cmpset_int() function returns a boolean and not the previous value of the atomic variable. - The atomic counters should be signed according to Linux. - Some minor cosmetics and styling while at it. Reviewed by: alfred @ MFC after: 1 week Sponsored by: Mellanox Technologies
* Use function macro instead of non-function macro to reduce chance ofhselasky2016-01-211-1/+1
| | | | | | | incorrect expansion. MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement idr_preload(), idr_preload_end(), idr_alloc() andhselasky2016-01-212-16/+101
| | | | | | | | idr_alloc_cyclic() in the LinuxKPI. Bump the FreeBSD version to force recompilation of all KLDs due to IDR structure size change. MFC after: 2 weeks Sponsored by: Mellanox Technologies
* Initialize vm_page_prot to VM_MEMATTR_DEFAULT instead of 0.jhb2016-01-201-1/+1
| | | | | | | | | | | | | | | If a driver's Linux mmap callback passed vm_page_prot through unchanged, then linux_dev_mmap_single() would try to apply whatever VM_MEMATTR_xxx value 0 is to the mapping. On x86, VM_MEMATTR_DEFAULT is the PAT value for write-back (WB) which is 6, while 0 maps to the PAT value for uncacheable (UC). Thus, any mmap request that did not explicitly set page_prot was tried to map memory as UC triggering the warning in sg_pager_getpages(). Tested by: np Reported by: Krishnamraju Eraparaju @ Chelsio MFC after: 3 days Sponsored by: Chelsio Communications
* Prevent double free of control in common sendmsg path as sosenddchagin2016-01-171-0/+1
| | | | already freeing it.
* Implement support for PCI suspend, resume and shutdown events in thehselasky2016-01-152-2/+49
| | | | | | | | LinuxKPI. Fix a few spaces to tabs. Bump the FreeBSD version to force recompilation of existing KMODs. MFC after: 1 week Sponsored by: Mellanox Technologies
* Call crextend() before copying old credentials to the new credentialsglebius2016-01-141-1/+3
| | | | | | | | | | | | | and replace crcopysafe by crcopy as crcopysafe is is not intended to be safe in a threaded environment, it drops PROC_LOCK() in while() that can lead to unexpected results, such as overwrite kernel memory. In my POV crcopysafe() needs special attention. For now I do not see any problems with this function, but who knows. Submitted by: dchagin Found by: trinity Security: SA-16:04.linux
* Change linux get_robust_list system call to match actual linux one.glebius2016-01-141-1/+1
| | | | | | | | | | | | | | | | | | | | | The set_robust_list system call request the kernel to record the head of the list of robust futexes owned by the calling thread. The head argument is the list head to record. The get_robust_list system call should return the head of the robust list of the thread whose thread id is specified in pid argument. The list head should be stored in the location pointed to by head argument. In contrast, our implemenattion of get_robust_list system call copies the known portion of memory pointed by recorded in set_robust_list system call pointer to the head of the robust list to the location pointed by head argument. So, it is possible for a local attacker to read portions of kernel memory, which may result in a privilege escalation. Submitted by: mjg Security: SA-16:03.linux
* Unlock process lock when return error from getrobustlist call and adddchagin2016-01-101-1/+5
| | | | | | | an forgotten dtrace probe when return the same error. MFC after: 3 days XMFC with: r292743
* Implement vsyscall hack. Prior to 2.13 glibc uses vsyscalldchagin2016-01-092-0/+2
| | | | | | | | | instead of vdso. An upcoming linux_base-c6 needs it. Differential Revision: https://reviews.freebsd.org/D1090 Reviewed by: kib, trasz MFC after: 1 week
* LinuxKPI style changes:hselasky2016-01-085-126/+130
| | | | | | | | | | | - Properly prefix internal functions with "linux_" instead of only a single underscore to avoid future namespace collisions. - Make some functions global instead of inline to ease debugging and to avoid unnecessary code duplication. - Remove no longer existing kthread_create() function's prototype. MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement RCU mechanism using shared exclusive locks.hselasky2016-01-052-1/+84
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Handle when filedescriptors are closed before initialized. An earlyhselasky2015-12-311-3/+4
| | | | | | | | | | fdclose() call can cause fget_unlocked() to fail. Found by: mjg @ MFC after: 1 week Reviewed by: Mark Block <markb@mellanox.com> Sponsored by: Mellanox Technologies Differential Revision: https://reviews.freebsd.org/D4351
* Minor LinuxKPI code cleanup:hselasky2015-12-316-182/+192
| | | | | | | | | | | | | - Declare some static functions in linux_compat.c instead if inside various header files. - Prefix FreeBSD local functions in the LinuxKPI with "linux_" to avoid symbol name conflicts in the future and to make debugging easier. - Make the "struct kobj_ktype" declaractions constant to shave off a few bytes from the data segment. MFC after: 1 week Sponsored by: Mellanox Technologies
* Make the kobject refcounting compliant with Linux. Refcounting on thehselasky2015-12-312-4/+8
| | | | | | | | parent kobject cannot be factored out and must be done by the kobject consumers. MFC after: 1 week Sponsored by: Mellanox Technologies
* Reduce memory consumption when allocating kobject strings in thehselasky2015-12-282-24/+45
| | | | | | | | | LinuxKPI. Compute string length before allocating memory instead of using fixed size allocations. Make kobject_set_name_vargs() global instead of inline to save some bytes when compiling. MFC after: 1 week Sponsored by: Mellanox Technologies
* Return EINVAL in case of incorrect sigev_signo value specified instead of ↵dchagin2015-12-261-0/+4
| | | | panicing.
* Do not allow access to emuldata for non Linux processes.dchagin2015-12-261-0/+2
| | | | | Pointed out by: mjg@ Security: https://admbugs.freebsd.org/show_bug.cgi?id=679
* Implement drain_workqueue() function.hselasky2015-12-212-1/+19
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* In the zero delay case in queue_delayed_work() use the return valuehselasky2015-12-211-5/+7
| | | | | | | | from taskqueue_enqueue() instead of reading "ta_pending" unlocked and also ensure the callout is stopped before proceeding. MFC after: 1 week Sponsored by: Mellanox Technologies
* Minor workqueue cleanup:hselasky2015-12-212-63/+71
| | | | | | | | - Make some functions global instead of inline to ease debugging. - Fix some minor style issues. MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement sleepable RCU mechanism using shared exclusive locks.hselasky2015-12-211-0/+72
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Implement ACCESS_ONCE(), WRITE_ONCE() and READ_ONCE().hselasky2015-12-211-0/+16
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Fix style issues around existing SDT probes.markj2015-12-161-2/+2
| | | | | | | | | - Use SDT_PROBE<N>() instead of SDT_PROBE(). This has no functional effect at the moment, but will be needed for some future changes. - Don't hardcode the module component of the probe identifier. This is set automatically by the SDT framework. MFC after: 1 week
* Add some structures and defines which will be used when decoding smallhselasky2015-12-031-0/+19
| | | | | | | | form factor, SFF, standards compliant ethernet EEPROMs. MFC after: 1 week Obtained from: Linux Sponsored by: Mellanox Technologies
* Remove incorrect defines. The proper version of these macros ishselasky2015-12-031-4/+0
| | | | | | | defined in linux/etherdevice.h. MFC after: 1 week Sponsored by: Mellanox Technologies
* Add more functions and types to the LinuxKPI.hselasky2015-11-302-2/+19
| | | | | MFC after: 1 week Sponsored by: Mellanox Technologies
* Remove sv_prepsyscall, sv_sigsize and sv_sigtbl members of the structkib2015-11-282-6/+0
| | | | | | | | | | | | | | | | sysent. sv_prepsyscall is unused. sv_sigsize and sv_sigtbl translate signal number from the FreeBSD namespace into the ABI domain. It is only utilized on i386 for iBCS2 binaries. The issue with this approach is that signals for iBCS2 were delivered with the FreeBSD signal frame layout, which does not follow iBCS2. The same note is true for any other potential user if sv_sigtbl. In other words, if ABI needs signal number translation, it really needs custom sv_sendsig method instead. Sponsored by: The FreeBSD Foundation
* Split kerne timekeep ABI structure vdso_sv_tk out of the structkib2015-11-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | sysentvec. This allows the timekeep data to be shared between similar ABIs which cannot share sysentvec. Make the timekeep_push_vdso() tick callback to the timekeep structures instead of sysentvecs. If several sysentvec share the vdso_sv_tk structure, we would update the userspace data several times on each tick, without the change. Only allocate vdso_sv_tk in the exec_sysvec_init() sysinit when sysentvec is marked with the new SV_TIMEKEEP flag. This saves allocation and update of unneeded vdso_sv_tk for ABIs which do not provide userspace gettimeofday yet, which are PowerPCs arches right now. Make vdso_sv_tk allocator public, namely split out and export alloc_sv_tk() and alloc_sv_tk_compat32(). ABIs which share timekeep data now can allocate it manually and share as appropriate. Requested by: nwhitehorn Tested by: nwhitehorn, pho Sponsored by: The FreeBSD Foundation MFC after: 2 weeks
* Add assert and note about the size of "unsigned long" inside thehselasky2015-11-131-0/+8
| | | | | | LinuxKPI for the future. Sponsored by: Mellanox Technologies
* Build fixes:hselasky2015-11-123-7/+34
| | | | | | | | | | - Add some missing I/O functions for non-i386 and amd64 platforms. - Stub ioremap() to NULL using a macro to ensure non-existing memory attributes are not referred when they do not exist. - Add more header files to linux/list.h to resolve driver compilation issues on Sparc64 and PowerPC platforms. Sponsored by: Mellanox Technologies
* linuxkpi/sysfs.h: Cast arg2 through intptr_t to avoid GCC warningcem2015-11-091-1/+1
| | | | | | | | | | | The code compiles fine under Clang, but GCC on PPC is less permissive about integer and pointer sizes. (An intmax_t is clearly *large enough* to hold a pointer value.) Another follow-up to r290475. Reported by: jhibbits Sponsored by: EMC / Isilon Storage Division
* Make all the LinuxKPI include files compile standalone.hselasky2015-11-0325-26/+72
| | | | Sponsored by: Mellanox Technologies
* Finish process of moving the LinuxKPI module into the default kernel build.hselasky2015-10-2995-0/+13644
| | | | | | | | | | | | | | | | | | | - Move all files related to the LinuxKPI into sys/compat/linuxkpi and its subfolders. - Update sys/conf/files and some Makefiles to use new file locations. - Added description of COMPAT_LINUXKPI to sys/conf/NOTES which in turn adds the LinuxKPI to all LINT builds. - The LinuxKPI can be added to the kernel by setting the COMPAT_LINUXKPI option. The OFED kernel option no longer builds the LinuxKPI into the kernel. This was done to keep the build rules for the LinuxKPI in sys/conf/files simple. - Extend the LinuxKPI module to include support for USB by moving the Linux USB compat from usb.ko to linuxkpi.ko. - Bump the FreeBSD_version. - A universe kernel build has been done. Reviewed by: np @ (cxgb and cxgbe related changes only) Sponsored by: Mellanox Technologies
* Fix build for the KTR-enabled kernels.kib2015-10-231-2/+9
| | | | Sponsored by: The FreeBSD Foundation
* Refactoring: move out generic bits from cloudabi64_sysvec.c.ed2015-10-222-0/+158
| | | | | | | | | | In order to make it easier to support CloudABI on ARM64, move out all of the bits from the AMD64 cloudabi_sysvec.c into a new file cloudabi_module.c that would otherwise remain identical. This reduces the AMD64 specific code to just ~160 lines. Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D3974
* Properly format pointer size independent CloudABI system calls.ed2015-10-081-0/+7
| | | | | | | | | | | | | | | | | | | | | | CloudABI has approximately 50 system calls that do not depend on the pointer size of the system. As the ABI is pretty compact, it takes little effort to each truss(8) the formatting rules for these system calls. Start off by formatting pointer size independent system calls. Changes: - Make it possible to include the CloudABI system call definitions in FreeBSD userspace builds. Add ${root}/sys to the truss(8) Makefile so we can pull in <compat/cloudabi/cloudabi_syscalldefs.h>. - Refactoring: patch up amd64-cloudabi64.c to use the CLOUDABI_* constants instead of rolling our own table. - Add table entries for all of the system calls. - Add new generic formatting types (UInt, IntArray) that we'll be using to format unsigned integers and arrays of integers. - Add CloudABI specific formatting types. Approved by: jhb Differential Revision: https://reviews.freebsd.org/D3836
OpenPOWER on IntegriCloud