summaryrefslogtreecommitdiffstats
path: root/sys/compat/linux/linux_futex.c
Commit message (Collapse)AuthorAgeFilesLines
* MFC r317645:dchagin2017-05-081-3/+6
| | | | | | | Fix NULL pointer dereference in futex_wake_op() in case when the same address specified for arguments uaddr and uaddr2. PR: 218987
* MFC r316395:dchagin2017-04-151-3/+0
| | | | Remove excess tv_nsec test as this is done by linux_to_native_timespec().
* For future use move futex timeout code to the separate function anddchagin2016-05-221-41/+68
| | | | | | switch to the high resolution sbintime_t. MFC after: 1 week
* Due to lack the priority propagation feature replace sx by mutex. WIth thisdchagin2016-05-221-44/+77
| | | | | | commit NPTL tests are ends in 1 minute faster. MFC after: 1 week
* Add my copyright as I rewrote most of the futex code. Minor style(9) cleanupdchagin2016-05-221-3/+4
| | | | | | while here. MFC after: 1 week
* 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
* 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
* Do not use struct l_timespec without conversion. While here movedchagin2015-05-241-32/+35
| | | | | | | args->timeout handling before acquiring the futex key at FUTEX_WAIT path. Differential Revision: https://reviews.freebsd.org/D1520 Reviewed by: trasz
* Add prototypes for static futex functions.dchagin2015-05-241-0/+16
| | | | | Differential Revision: https://reviews.freebsd.org/D1519 Reviewed by: trasz
* Print out unsupported futex operation message only once for the process.dchagin2015-05-241-23/+45
| | | | Differential Revision: https://reviews.freebsd.org/D1498
* Where possible we will use M_LINUX malloc(9) type.dchagin2015-05-241-3/+0
| | | | | | | Move M_FUTEX defines to the linux_common.ko. Differential Revision: https://reviews.freebsd.org/D1077 Reviewed by: emaste
* Refund the proc emuldata struct for future use. For now move flags fromdchagin2015-05-241-4/+4
| | | | | | | | | | thread emuldata to proc emuldata as it was originally intended. As we can have both 64 & 32 bit Linuxulator running any eventhandler can be called twice for us. To prevent this move eventhandlers code from linux_emul.c to the linux_common.ko module. Differential Revision: https://reviews.freebsd.org/D1073
* Switch linuxulator to use the native 1:1 threads.dchagin2015-05-241-28/+24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The reasons: 1. Get rid of the stubs/quirks with process dethreading, process reparent when the process group leader exits and close to this problems on wait(), waitpid(), etc. 2. Reuse our kernel code instead of writing excessive thread managment routines in Linuxulator. Implementation details: 1. The thread is created via kern_thr_new() in the clone() call with the CLONE_THREAD parameter. Thus, everything else is a process. 2. The test that the process has a threads is done via P_HADTHREADS bit p_flag of struct proc. 3. Per thread emulator state data structure is now located in the struct thread and freed in the thread_dtor() hook. Mandatory holdig of the p_mtx required when referencing emuldata from the other threads. 4. PID mangling has changed. Now Linux pid is the native tid and Linux tgid is the native pid, with the exception of the first thread in the process where tid and pid are one and the same. Ugliness: In case when the Linux thread is the initial thread in the thread group thread id is equal to the process id. Glibc depends on this magic (assert in pthread_getattr_np.c). So for system calls that take thread id as a parameter we should use the special method to reference struct thread. Differential Revision: https://reviews.freebsd.org/D1039
* Fix Clang warning: passing 'unsigned int *' to parameter of type 'int *' ↵dchagin2015-01-011-4/+5
| | | | | | converts between pointers to integer types with different sign. MFC after: 1 week
* Glibc was switched to the FUTEX_WAIT_BITSET op and CLOCK_REALTIMEdchagin2014-05-311-31/+40
| | | | | | | | | | | | | | | | flag has been added instead of FUTEX_WAIT to replace the FUTEX_WAIT logic which needs to do gettimeofday() calls before the futex syscall to convert the absolute timeout to a relative timeout. Before this the CLOCK_MONOTONIC used by the FUTEX_WAIT_BITSET op. When the FUTEX_CLOCK_REALTIME is specified the timeout is an absolute time, not a relative time. Rework futex_wait to handle this. On the side fix the futex leak in error case and remove useless parentheses. Properly calculate the timeout for the CLOCK_MONOTONIC case. MFC after: 3 days
* In r218101 I have not changed properly the futex syscall definition.dchagin2014-05-281-13/+16
| | | | | | | | | | | | | | Some Linux futex ops atomically verifies that the futex address uaddr (uval) contains the value val. Comparing signed uval and unsigned val may lead to an unexpected result, mostly to a deadlock. So copyin uaddr to an unsigned int to compare the parameters correctly. While here change ktr records to print parameters in more readable format. Tested by eadler@ MFC after: 3 days
* - For kernel compiled only with KDTRACE_HOOKS and not any lock debuggingattilio2013-11-251-1/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | option, unbreak the lock tracing release semantic by embedding calls to LOCKSTAT_PROFILE_RELEASE_LOCK() direclty in the inlined version of the releasing functions for mutex, rwlock and sxlock. Failing to do so skips the lockstat_probe_func invokation for unlocking. - As part of the LOCKSTAT support is inlined in mutex operation, for kernel compiled without lock debugging options, potentially every consumer must be compiled including opt_kdtrace.h. Fix this by moving KDTRACE_HOOKS into opt_global.h and remove the dependency by opt_kdtrace.h for all files, as now only KDTRACE_FRAMES is linked there and it is only used as a compile-time stub [0]. [0] immediately shows some new bug as DTRACE-derived support for debug in sfxge is broken and it was never really tested. As it was not including correctly opt_kdtrace.h before it was never enabled so it was kept broken for a while. Fix this by using a protection stub, leaving sfxge driver authors the responsibility for fixing it appropriately [1]. Sponsored by: EMC / Isilon storage division Discussed with: rstone [0] Reported by: rstone [1] Discussed with: philip
* Fix some typos that were causing probe argument types to show up as unknown.markj2013-10-011-1/+1
| | | | | | Reviewed by: rwatson (mac provider) Approved by: re (glebius) MFC after: 1 week
* Arithmetic on pointers takes into account the size of the type. Properly ↵dchagin2013-01-251-2/+2
| | | | | | cast the pointer to avoid incorrect pointer scaling. MFC after: 1 Week
* - >500 static DTrace probes for the linuxulatornetchild2012-05-051-84/+425
| | | | | | | | | | | | | | | | | | - DTrace scripts to check for errors, performance, ... they serve mostly as examples of what you can do with the static probe;s with moderate load the scripts may be overwhelmed, excessive lock-tracing may influence program behavior (see the last design decission) Design decissions: - use "linuxulator" as the provider for the native bitsize; add the bitsize for the non-native emulation (e.g. "linuxuator32" on amd64) - Add probes only for locks which are acquired in one function and released in another function. Locks which are aquired and released in the same function should be easy to pair in the code, inter-function locking is more easy to verify in DTrace. - Probes for locks should be fired after locking and before releasing to prevent races (to provide data/function stability in DTrace, see the man-page of "dtrace -v ..." and the corresponding DTrace docs).
* Mark MALLOC_DEFINEs static that have no corresponding MALLOC_DECLAREs.ed2011-11-071-2/+2
| | | | This means that their use is restricted to a single C file.
* Remove now-obsolete comment.jhb2011-03-101-6/+1
| | | | | Submitted by: netchild MFC after: 1 week
* Print out shared flag for debug purpose.dchagin2011-03-031-8/+8
| | | | MFC after: 1 Week
* Switch PROCESS_SHARE to AUTO_SHARE (as umtx do). Even for SHARED,dchagin2011-03-031-1/+1
| | | | | | | | if page mapped MAP_ANON linux uses private algorithm too. Disscussed with: jhb MFC after: 3 Days
* Use umtx_key objects to uniquely identify futexes. Private futexes injhb2011-02-231-17/+32
| | | | | | | | | | | | different processes that happen to use the same user address in the separate processes will now be treated as distinct futexes rather than the same futex. We can now honor shared futexes properly by mapping them to a PROCESS_SHARED umtx_key. Private futexes use THREAD_SHARED umtx_key objects. In conjunction with: dchagin Reviewed by: kib MFC after: 1 week
* Style(9) fix. Do not initialize variables in the declarations.dchagin2011-02-141-2/+5
|
* Sort include files in the alphabetical order.dchagin2011-02-131-1/+1
|
* Remove comment about 'ftlk' LOR.dchagin2011-02-131-2/+1
|
* Stop printing the LOR, as this is expected behavior.dchagin2011-02-131-1/+1
|
* The bitset field of freshly created futex should be initialized explicity.dchagin2011-02-131-0/+1
| | | | Otherwise, REQUEUE operations fails.
* Rename used_requeue and use it as bitwise field to store more flags.dchagin2011-02-121-2/+2
| | | | Reimplement used_requeue logic with LINUX_XDEPR_REQUEUEOP flag.
* Yet another unimplemented futex operation, print out about.dchagin2011-01-311-0/+7
| | | | | Submitted by: arundel MFC after: 1 month.
* Implement a futex BITSET op.dchagin2011-01-311-25/+44
| | | | | Submitted by: arundel MFC after: 1 month.
* Remove trailing dot from the unimplemented futex messages to makenetchild2010-11-221-5/+5
| | | | | | | them consistent with the syscall and ipc messages. Submitted by: arundel MFC after: 3 days
* Some style(9) fixes.netchild2010-11-151-5/+5
| | | | | Submitted by: arundel MFC after: 1 week
* - print out the PID and program name of the program trying to use annetchild2010-11-151-6/+42
| | | | | | | | | | | | | | | | | unsupported futex operation - for those futex operations which are known to be not supported, print out which futex operation it is - shortcut the error return of the unsupported FUTEX_CLOCK_REALTIME in some cases: FUTEX_CLOCK_REALTIME can be used to tell linux to use CLOCK_REALTIME instead of CLOCK_MONOTONIC. FUTEX_CLOCK_REALTIME however must only be set, if either FUTEX_WAIT_BITSET or FUTEX_WAIT_REQUEUE_PI are set too. If that's not the case we can die with ENOSYS right at the beginning. Submitted by: arundel Reviewed by: rdivacky (earlier iteration of the patch) MFC after: 1 week
* Simplify timeout check in futex_wait() using itimerfix() and return errorjkim2010-10-061-22/+10
| | | | | if the given timeout is invalid. Consistently use int type for timeout and correct a format string in futex_sleep().
* Fix a comparision of an uninitialised pointer.netchild2010-10-061-1/+1
| | | | | | Submitted by: arundel Found by: clang analysis (automatic service by uqs@) Reviewed by: rdivacky
* Remove extraneous semicolons, no functional changes.mbr2010-01-071-1/+1
| | | | | Submitted by: Marc Balmer <marc@msys.ch> MFC after: 1 week
* Unlock process lock when return error from getrobustlist call.dchagin2009-06-141-1/+3
| | | | | | Tested by: Alexander Best <alexbestms at math uni-muenster de> Approved by: kib (mentor) MFC after: 3 days
* Add KTR(9) tracing for futex emulation.dchagin2009-05-071-11/+49
| | | | | Approved by: kib (mentor) MFC after: 1 month
* Move extern variable definitions to the header file.dchagin2009-05-021-1/+1
| | | | | Approved by: kib (mentor) MFC after: 1 month
* Reimplement futexes.dchagin2009-05-011-358/+449
| | | | | | | | | | | | | | | | | | | | Old implemention used Giant to protect the kernel data structures, but at the same time called malloc(M_WAITOK), that could cause the calling thread to sleep and lost Giant protection. User-visible result was the missed wakeup. New implementation uses one sx lock per futex. The sx protects the futex structures and allows to sleep while copyin or copyout are performed. Unlike linux, we return EINVAL when FUTEX_CMP_REQUEUE operation is requested and either caller specified futexes are equial or second futex already exists. This is acceptable since the situation can only occur from the application error, and glibc falls back to old FUTEX_WAKE operation when FUTEX_CMP_REQUEUE returns an error. Approved by: kib (mentor) MFC after: 1 month
* Remove support for FUTEX_REQUEUE operation.dchagin2009-04-191-13/+18
| | | | | | | | | | | | | | | | Glibc does not use this operation since 2.3.3 version (Jun 2004), as it is racy and replaced by FUTEX_CMP_REQUEUE operation. Glibc versions prior to 2.3.3 fall back to FUTEX_WAKE when FUTEX_REQUEUE returned EINVAL. Any application directly using FUTEX_REQUEUE without return value checking are definitely broken. Limit quantity of messages per process about unsupported operation. Approved by: kib (mentor) MFC after: 1 month
* Sort include files in the alphabetical order.dchagin2009-03-161-5/+4
| | | | | Approved by: kib (mentor) MFC after: 2 weeks
* Ignore FUTEX_FD op, as it is done by linux.dchagin2009-03-151-7/+0
| | | | | Approved by: kib (mentor) MFC after: 2 weeks
* Include linux_futex.h before linux_emul.hdchagin2009-03-151-1/+1
| | | | | Approved by: kib (mentor) MFC after: 6 days
* In the robust futexes list head, futex_offset shall be signed,kib2008-11-161-2/+2
| | | | | | and glibc actually supplies negative offsets. Change l_ulong to l_long. Submitted by: dchagin
* Make robust futexes work on linux32/amd64. Use PTRIN to readkib2008-10-141-3/+3
| | | | | | | | user-mode pointers. Change types used in the structures definitions to properly-sized architecture-specific types. Submitted by: dchagin MFC after: 1 week
OpenPOWER on IntegriCloud