* signal.cc (sigwait): Fix return value to reflect errno in case of
error according to POSIX. Never return EINTR.
* thread.cc (pthread_kill): Return errno if sig_send failed.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* init.cc (munge_threadfunc): Check that we're actually replacing
the correct original function address on the stack.
* ntdll.h (enum _THREADINFOCLASS): Add ThreadQuerySetWin32StartAddress.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* strfuncs.cc (sys_cp_wcstombs): Always return number of multibytes
without trailing NUL as the documentation implies. Throughout Cygwin,
fix usage to align to this pattern.
* fhandler_process.cc (format_process_winexename): Drop trailing NUL
and LF from output.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* thread.cc (pthread_getattr_np): Fix memory leak, remove usage of
malloc for small local buffer.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* flock.cc (lockf_t::create_lock_obj_attr): Add buffer parameter.
Call _everyone_sd with buffer argument from caller rather than
everyone_sd with locally allocated stack buffer.
(lockf_t::create_lock_obj): Call create_lock_obj_attr only once
outside the loop and with additional buffer argument.
(lockf_t::open_lock_obj): Call create_lock_obj_attr with additional
buffer argument.
* include/sys/unistd.h (_SC_LEVEL*): Add cache-related variables as
on Linux.
* fhandler_proc.cc (format_proc_cpuinfo): Fetch cache information
from new cache functions in sysconf.cc, get_cpu_cache_intel and
get_cpu_cache_amd.
* sysconf.cc (__nt_query_system): New local helper.
(get_nproc_values): Utilize __nt_query_system on pre-Windows 7 systems.
Use GetLogicalProcessorInformationEx otherwise to handle more than
64 CPUs. Only handle _SC_NPROCESSORS_CONF and _SC_NPROCESSORS_ONLN.
(get_phys_pages): New helper to handle _SC_PHYS_PAGES.
(cpuid2_cache_descriptor): New array to map Intel CPUID 2 descriptor
values to cache type, cache size, associativity and linesize.
(cpuid2_cache_desc_compar): Comparision function for bsearch over
cpuid2_cache_descriptor.
(get_cpu_cache_intel_cpuid2): New function to fetch cache info from
Intel CPUID 2.
(get_cpu_cache_intel_cpuid4): Ditto from Intel CPUID 4.
(get_cpu_cache_intel): New function as CPU-specific entry point.
(assoc): New array to map associativity values from AMD CPUID
0x80000006.
(get_cpu_cache_amd): New function to fetch cache info from AMD CPUIDs
0x80000005 and 0x80000006.
(get_cpu_cache): New function to fetch cache info.
(sca): Call get_phys_pages if _SC_PHYS_PAGES is requested. Call
get_cpu_cache for new _SC_* cache requests.
(SC_MAX): Set to _SC_LEVEL4_CACHE_LINESIZE.
(get_phys_pages(void)): Call get_phys_pages(int).
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* new-features.xml (ov-new2.3): Document sysconf cache addition.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler_proc.cc (format_proc_cpuinfo): Only fetch group relations,
we don't need anything else.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* winsup.h (_WIN32_WINNT): Set to 0x0a00 for Windows 10.
(WINVER): Ditto. Remove outdated comment.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
System DLLs are always first in the DLL search order so
http://www.microsoft.com/technet/security/advisory/2269637.mspx
doesn't apply for them.
* autoload.cc (std_dll_init): Revert using full paths to system DLLs.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This fixes a long-standing problem when GetProcAddress fails
to load a function. The noload code calls SetLastError on
i686 without saving the edx register. Starting with Windows 7,
SetLastError apparently uses $edx and the register is set to
0x00000000 on return. So the subsequent `jmp *$edx' in noload
supposed to return to the caller, actually jumps to address NULL,
which results in a SEGV.
* autoload.cc (noload): i686 only: Save and restore $edx when calling
SetLastError to avoid clobbering return address stating with Windows 7.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* grp.cc (internal_getgrfull): Drop asking caches. Explain why.
(internal_getgroups): In case we're not utilizing the Windows account
DBs, don't call LsaLookupSids but iterate over the group SIDs in the
token and call internal_getgrsid for each of them. Explain why.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Rearrange
to fall back to myself uid/gid in case we don't utilize Windows
account DBs, just as prior to 1.7.34.
* sec_helper.cc (cygpsid::get_id): Disable Samba user/group mapping per
RFC2307 if we're not utilizing Windows account DBs.
* security.cc (convert_samba_sd): Revert previous patch.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
When globals.cc has CRLF line endings, winsup.h is not removed, and
compilation fails for duplicate definitions.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base_overlapped::raw_write): When performing
nonblocking I/O, copy user space data into own buffer. Add longish
comment to explain why.
* fhandler.h (fhandler_base_overlapped::atomic_write_buf): New member.
(fhandler_base_overlapped::fhandler_base_overlapped): Initialize
atomic_write_buf.
(fhandler_base_overlapped::fhandler_base_overlapped): New destructor,
free'ing atomic_write_buf.
(fhandler_base_overlapped::copyto): Set atomic_write_buf to NULL in
copied fhandler.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* fhandler_disk_file.cc (fhandler_base::fstat_by_nfs_ea): Only try
to map user and group info per RFC2307 if account info is fetched
from Windows account DB.
(convert_samba_sd): Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* security,cc (get_attribute_from_acl): Merge all group perms into
user perms if user is member of group.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* autoload.cc (GetLogicalProcessorInformationEx): Import.
(SetThreadGroupAffinity): Import.
* fhandler_proc.cc (add_size): New macro.
(get_msb): New inline function.
(mask_bits): Ditto.
(format_proc_cpuinfo): Drop handling of old CPUs. Check if we're
running on a OS version supporting porcessor groups. If so, use
SetThreadGroupAffinity to set thread affinity. Improve cache info
to include 3rd level cache on Intel CPUs. Improve multi core info.
* wincap.h (wincaps::has_processor_groups): New element.
* wincap.cc: Implement above element throughout.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
https://cygwin.com/ml/cygwin/2015-07/msg00344.html:
RtlFillMemory and RtlCopyMemory only work for size values
up to 2GB. Fix this problem by using NetBSD code for
memset and memcpy. Add entry points for memmove, wmemset,
wmemmove, wmemcpy. Thanks to Roman Petrovski
<RPetrovski@illumina.com> for pointing this out.
* miscfuncs.cc (memset): x86_64 only: Implement in assembler.
(memmove,memcpy): x86_64 only: Ditto.
(wmemmove,wmemcpy): x86_64 only: Ditto.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* cygtls.h: Include cygtls_padsize.h and define CYGTLS_PADSIZE there.
* cygtls_padsize.h: New file. Define CYGTLS_PADSIZE.
* environ.cc (parse_options): Fix NULL pointer access.
* init.cc (threadfunc_fe): Do not force stack align on x86_64.
* strace.cc (main2): Rename from main.
(main): Make room for _cygtls area on stack and just call main2. Add
comment to explain why.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
glibc's tst-makecontext2 testcase uncovered a bug in
__cont_link_context. If the function misses to reserve
shadow space for the calls to setcontext/cygwin_exit,
both functions could overwrite memory beyond the stack
configured in uc_stack.
* exceptions.cc (__cont_link_context): x86_64: align stack and reserve
shadow space for subsequent function calls, otherwise suffer potential
buffer overflow.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* uinfo.cc (cygheap_user::ontherange): Ignore $HOME if it's not
starting with a slash (aka, absolute POSIX Path).
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
* libc/include/machine/setjmp.h (siglongjmp): Declare as function on
Cygwin.
(sigsetjmp): Ditto.
(_longjmp): Mark as noreturn function on Cygwin.
* common.din (siglongjmp): Export.
(sigsetjmp): Export.
* gendef: Change formatting of some comments.
(sigsetjmp): Implement.
(siglongjmp): Implement.
(__setjmpex): x86_64 only: Drop entry point.
(setjmp): x86_64 only: Store tls stackptr in Frame now, store MXCSR
and FPUCW registers in Spare, as MSVCRT does.
(longjmp): x86_64 only: Restore tls stackptr from Frame now, restore
MXCSR and FPUCW registers from Spare.
* include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump.
* new-features.xml (ov-new2.2): Document sigsetjmp, siglongjmp.
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>