Commit Graph

172 Commits

Author SHA1 Message Date
Corinna Vinschen e7bcf4633e cygwin: wincap: handle W10 1703
Add has_unprivileged_createsymlink flag and set to true on 1703 and
later.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2017-04-24 17:14:03 +02:00
Corinna Vinschen 63f19278b9 cygwin: wincap: fix evaluation of build number
RtlGetNtVersionNumbers returns the build number with some upper bits
set for no apparent reason.  The fact that RtlGetNtVersionNumbers is
undocumented doesn't exactly help.

Just filter out the upper WORD for now.  If build numbers are in
danger to become 6 digit numbers, re-evaluate.
2017-04-24 17:12:16 +02:00
Corinna Vinschen 67fd2101ab Drop max_sys_priv wincap
Convert sys_privs to const struct with TOKEN_PRIVILEGES layout.
Drop function get_system_priv_list.  Just use pointer to sys_privs.

Dropping max_sys_priv from wincaps requires to make sure that the
bitfield is 8 byte aligned on x86_64, otherwise gcc (5.3 only?)
apparently breaks access to the bitfield (off by 4 bytes).

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 21:00:04 +02:00
Corinna Vinschen b15d129559 Drop accidentally leftover comment from wincapc::init 2016-06-24 16:02:41 +02:00
Corinna Vinschen c7fe56dd65 Default to latest wincap 2016-06-24 16:02:41 +02:00
Corinna Vinschen b47a67e493 Drop Windows XP/2003 wincaps 2016-06-24 16:02:40 +02:00
Corinna Vinschen 8dd446a7b1 Drop has_broken_rtl_query_process_debug_information flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 2467e6f99b Drop terminate_thread_frees_stack flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 0bf159ab72 Drop has_pipe_reject_remote_clients flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 23a556f2c5 Drop has_set_thread_stack_guarantee flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen 8b8c6c014b Drop has_program_compatibility_assistant flag 2016-06-24 16:02:40 +02:00
Corinna Vinschen bd4339e2a2 Drop wow64_has_secondary_stack flag 2016-06-24 15:49:45 +02:00
Corinna Vinschen 105f79b489 Drop use_dont_resolve_hack flag
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-24 15:42:06 +02:00
Corinna Vinschen 807a628ec6 Drop has_restricted_raw_disk_access flag 2016-06-24 14:31:56 +02:00
Corinna Vinschen 9aab8eb5b6 Drop has_transactions flag 2016-06-24 13:12:20 +02:00
Corinna Vinschen ffcef702e7 Drop has_fast_cwd flag 2016-06-24 13:08:36 +02:00
Corinna Vinschen 94f98f18db Drop has_localenames flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen ed0ff4b940 Drop has_always_all_codepages flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen e931b1a0eb Drop has_broken_udf flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 222e412f8d Drop has_sendmsg flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen aacc4f63d0 Drop has_mandatory_integrity_control flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 380b9affd1 Drop has_restricted_stack_args flag 2016-06-23 22:21:23 +02:00
Corinna Vinschen 6f560555bd Drop supports_all_posix_ai_flags 2016-06-23 22:21:23 +02:00
Corinna Vinschen a759558418 Drop has_gaa_on_link_prefix flag and remove obsolete functions thusly 2016-06-23 22:18:42 +02:00
Corinna Vinschen 2fb0813caa Drop has_recycle_dot_bin 2016-06-23 22:01:14 +02:00
Corinna Vinschen 6e623e9320 Switching the Cygwin DLL to LGPLv3+, dropping commercial buyout option
Bump GPLv2+ to GPLv3+ for some files, clarify BSD 2-clause.

Everything else stays under GPLv3+.

New Linking Exception exempts resulting executables from LGPLv3 section 4.

Add CONTRIBUTORS file to keep track of licensing.

Remove 'Copyright Red Hat Inc' comments.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-06-23 10:09:17 +02:00
Corinna Vinschen 48511f3d38 Overwite potentially faked kernel version with correct values
* ntdll.h (RtlGetNtVersionNumbers): Declare.
	* wincap.cc (wincapc::init): Overwrite kernel version info
	returned by RtlGetVersion with correct info returnd by
	RtlGetNtVersionNumbers.  Add comment.

Originally, using RtlGetVersion instead of GetVersionEx was supposed to
fix the fact that GetVersionInfo returns the wrong kernel version if the
executable has been built with an old manifest (or none at all), starting
with Windows 8.1.  Either this never really worked as desired and our
testing was flawed, or this has been changed again with Windows 10, so
that RtlGetVersion does the kernel faking twist as well.  Since we're
only reading the value in the first process in a process tree. the entire
process tree is running with a wrong OS version information in that case.

Fortunately, the (undocumented) RtlGetNtVersionNumbers function is not
affected by this nonsense, so we simply override the OS version info
fields with the correct values now.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-03-09 23:10:17 +01:00
Corinna Vinschen 205862ed08 setuid: Create token from scratch without credentials of caller
* sec_auth.cc (get_token_group_sidlist): Drop auth_luid and
	auth_pos parameter.  Remove code adding a logon SID.
	(get_initgroups_sidlist): Drop auth_luid and auth_pos parameter.
	Drop in call to get_token_group_sidlist. Accommodate in callers.
	(get_setgroups_sidlist): Ditto.
	(create_token): Explicitely set auth_luid to ANONYMOUS_LOGON_LUID
	or LOCALSERVICE_LUID depending on OS.  Explain why.
	Remove handling of logon SID since we don't generate one anymore.
	(lsaauth): Drop now unused local variable auth_luid and auth_pos.
	* wincap.h (wincaps::has_broken_whoami): New element.
	* wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-02-18 11:22:12 +01:00
Corinna Vinschen fcda8810a2 Don't use LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32). It hangs
Observed running hexchat under X.  For some reason the call to
	LoadLibraryEx(..., LOAD_LIBRARY_SEARCH_SYSTEM32) in dll_load
	hangs when trying to autoload MsgWaitForMultipleObjectsEx in
	select.cc after hexchat forks to run DNS calls.  Dropping the
	call and just using full paths as in 2.3.1 fixes the issue.

	* autoload.cc (dll_load): Drop call to LoadLibraryEx with
	LOAD_LIBRARY_SEARCH_SYSTEM32 flag.
	* wincap.h (wincaps::has_load_lib_search_flags): Remove.
	* wincap.cc (wincaps::has_load_lib_search_flags): Drop handling
	this flag.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-27 15:43:15 +01:00
Corinna Vinschen 15d6f564cd Try loading with safe path using LOAD_LIBRARY_SEARCH_SYSTEM32 first
* autoload.cc (dll_load): Move safe loading from std_dll_init here.
	Add code to handle systems supporting LOAD_LIBRARY_SEARCH flags.
	Add comments to explain what the code is doing.  Fix up comment
	preceeding this function.
	(std_dll_init): Move safe loading code to dll_load.
	* wincap.h (wincaps::has_load_lib_search_flags): New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2016-01-12 15:23:14 +01:00
Corinna Vinschen e753e4129a Always allocate main thread stack from pthread stack area on x86_64.
* dcrt0.cc: Semi-revert commit 12743c2d5d.
        (dll_crt0_0): Drop setting wow64_needs_stack_adjustment on 64 bit.
        (_dll_crt0): Split out 64 bit code again and always create new main
        thread stack, unless forked off from the non main thread in the parent.
        Call create_new_main_thread_stack with parent stack commitsize if
        started from the parent's main thread.
        Only call child_info_fork::alloc_stack for the latter case on 64 bit.
        Slightly rearrange moving rsp and rbp to new stack and document how.
        Revert 32 bit wow64 handling to its former self.
        * miscfunc.cc (create_new_main_thread_stack): Take a commitsize
        parameter and use it if it's not 0.  Don't set _main_tls here, it's
        done in the caller _dll_crt0 anyway.  Return stackbase - 16 bytes,
        rather than stacklimit (which was very wrong anyway).
        * miscfuncs.h (create_new_main_thread_stack): Accommodate declaration
        to aforementioned change.
        * wincap.h (wincaps::has_3264_stack_broken): Remove element.
        * wincap.cc: Ditto, throughout.
        * wow64.cc: Semi-revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520
        but keep architecture-agnostic type changes intact.  Fix formatting.
        * wow64.h: Revert to pre-12743c2d5d2721f3a80b4d7671a349be03c1f520.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-07 16:10:55 +01:00
Corinna Vinschen 12743c2d5d On 64 bit, only create new thread stack if started from 32 bit process on affected platforms
* dcrt0.cc (dll_crt0_0): On 64 bit, set wow64_needs_stack_adjustment
        if not started from a 64 bit process.
        (_dll_crt0): Enable wow64_needs_stack_adjustment branch on 64 bit
        as well.  Remove 64 bit only code.  Introduce CREATE_STACK and
        FIX_STACK macros to conditionalize the code.  Rearrange and
        partially rewrite comments.
        * wincap.h (wincaps::has_3264_stack_broken): New element.
        * wincap.cc: Implement above element throughout.
        (wincapc::init): Set has_3264_stack_broken to false on 32 bit.
        * wow64.cc: Enable functionality on 64 bit architecture, except for
        wow64_revert_to_original_stack.  Enhance comments to explain.
        (wow64_eval_expected_main_stack): Make 64 bit clean.
        (wow64_test_for_64bit_parent): Ditto.
        * wow64.h: Export wow64_revert_to_original_stack on 32 bit only,
        everything else on all architectures.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 22:56:44 +01:00
Corinna Vinschen f1ed5bfa83 Fix /proc/<PID>/maps output for PEB and TEBs on W10 1511
* fhandler_process.cc (heap_info::fill_if_match): Return NULL, not 0.
        (thread_info::fill_if_match): Ditto.
        (thread_info::fill_if_match): New method to extract TEB info from
        PEB/TEB region since W10 1511.
        (format_process_maps): Drop outdated FIXME comment.  Add code to handle
        PEB/TEB region since W10 1511.
        * mmap.cc (posix_madvise): Align comment to new W10 1511 version.
        * wincap.h (wincaps::has_new_pebteb_region): New element.
        * wincap.cc: Implement above element throughout.
        (wincap_10_1511): New global wincaps to support Windows 10 since 1511.
        (wincapc::init): Use wincap_10_1511 for W10 builds >= 10586.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-12-03 13:33:43 +01:00
Corinna Vinschen 35d5d87540 Implement POSIX_MADV_WILLNEED/POSIX_MADV_DONTNEED for newer OSes
* autoload.cc (DiscardVirtualMemory): Import.
        (PrefetchVirtualMemory): Import.
        * mmap.cc (posix_madvise): Actually implement POSIX_MADV_WILLNEED
        utilizing PrefetchVirtualMemory and POSIX_MADV_DONTNEED utilizing
        DiscardVirtualMemory on systems supporting them.
        * wincap.h (wincaps::has_broken_prefetchvm): New element.
        * wincap.cc: Implement above element throughout.
        (wincapc::init): Make sure has_broken_prefetchvm is only true on
        W10 under WOW64.
        * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2003.
        (CYGWIN_VERSION_API_MINOR): Reset to 0.

        * new-features.xml (ov-new2.3): New section, document posix_madvise
        POSIX_MADV_WILLNEED/POSIX_MADV_DONTNEED change.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-08-27 13:34:25 +02:00
Corinna Vinschen e0d48debed Fix /proc/cpuinfo topology and cache size info
* 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>
2015-08-13 17:59:47 +02:00
Corinna Vinschen d32ea61ae4 cygwin: Fix copyright dates
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-29 13:45:46 +02:00
Corinna Vinschen e426213a88 Disable fetching heap info on 64 bit XP/2003
* fhandler_process.cc (heap_info::heap_info): Disable fetching heap info
        on 64 bit XP/2003.  Explain why.
        * wincap.h (wincaps::has_broken_rtl_query_process_debug_information):
        New element.
        * wincap.cc: Implement above element throughout.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-05 12:53:30 +02:00
Corinna Vinschen 2cd7eb7f60 Fix original stack when running signal handler on alternate stack
* autoload.cc (SetThreadStackGuarantee): Import.
        * cygtls.h (struct _cygtls): Replace thread_context with a ucontext_t
        called context.
        * exceptions.cc (exception::handle): Exit from process via signal_exit
        in case sig_send returns from handling a stack overflow SIGSEGV.
        Explain why.
        (dumpstack_overflow_wrapper): Thread wrapper to create a stackdump
        from another thread.
        (signal_exit): Fix argument list to reflect three-arg signal handler.
        In case we have to create a stackdump for a stack overflow condition,
        do so from a separate thread.  Explain why.
        (sigpacket::process): Don't run signal_exit on alternate stack.
        (altstack_wrapper): Wrapper function to do stack correction when
        calling the signal handler on an alternate stack to handle a stack
        overflow.  Make sure to have lots of comments.
        (_cygtls::call_signal_handler): Drop local context variable to reduce
        stack pressure.  Use this->context instead.  Change inline assembler
        to call altstack_wrapper.
        (_cygtls::signal_debugger): Accommodate aforementioned change to
        struct _cygtls.
        * tlsoffset.h: Regenerate.
        * tlsoffset64.h: Regenerate.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2015-07-04 22:49:30 +02:00
Corinna Vinschen 9e9d7a8ce1 * wincap.cc (wincap_minimal): Remove.
(wincaps): Drop has_physical_mem_access.
	(wincap_10): New global wincaps to support Windows 10.
	(wincapc::init): Use wincap_10 for version >= 6.4 and as default.
	* wincap.h (wincaps::has_physical_mem_access): remove.
2014-12-01 14:02:55 +00:00
Corinna Vinschen 8764af1eb1 * uinfo.cc (cygheap_user::init): Fix formatting in debug output.
(struct cyg_USER_INFO_24): Define temporarily.  Explain why.
	(pwdgrp::fetch_account_from_windows): Handle sane primary group
	setting for Microsoft Accounts.  Explain why.
	* wincap.h (wincaps::has_microsoft_accounts): New element.
	* wincap.cc: Implement above element throughout.
2014-05-08 19:33:07 +00:00
Corinna Vinschen c9f36df332 * ntdll.h (RtlGetVersion): Declare.
* wincap.cc (wincapc::init): Rather than GetVersionEx, call
	RtlGetVersion which is not crippled by missing Windows 8.1 manifest.
	* wincap.h (wincapc): Change type of version to RTL_OSVERSIONINFOEXW.
	Align formatting of all class members.
2013-11-19 22:21:11 +00:00
Corinna Vinschen 690d1333f5 * wincap.cc (wincapc::init): Revert previous change. It's not working. 2013-11-19 20:37:27 +00:00
Corinna Vinschen 705b50fe39 * wincap.cc (wincapc::init): Fix dwMinorVersion for Windows 8.1 and
Server 2012.  Explain why this is necessary.
2013-11-19 18:01:04 +00:00
Corinna Vinschen 7584fa98d4 * autoload.cc (GetSystemTimePreciseAsFileTime): Define.
* times.cc (GetSystemTimePreciseAsFileTime): Temporarily declare here
	to workaround missing definition in 32 bit w32api headers.
	(get_system_time): New always inline function to call either
	GetSystemTimePreciseAsFileTime or GetSystemTimeAsFileTime on a per OS
	basis.  Call throughout instead of GetSystemTimeAsFileTime.
	* wincap.h (wincaps::has_precise_system_time): New element.
	* wincap.cc: Implement above element throughout.
2013-06-14 15:41:17 +00:00
Corinna Vinschen 61522196c7 * Merge in cygwin-64bit-branch. 2013-04-23 09:44:36 +00:00
Corinna Vinschen 4aa4632ad2 * cygthread.cc (cygthread::terminate_thread): Only try to free
thread stack on systems not freeing it by themselves.
	* wincap.h (wincaps::terminate_thread_frees_stack): New element.
	* wincap.cc: Implement above element throughout.
2013-03-29 17:00:36 +00:00
Christopher Faylor bc837d22f3 Throughout, update copyrights to reflect dates which correspond to main-branch
checkins.  Regularize copyright format.
2013-01-21 04:38:31 +00:00
Corinna Vinschen 67d71dbf10 * wincap.cc (wincapc::init): Drop memset call since it can result in
a race condition.  Drop all considerations for pre-Windows 2000 systems
	since Cygwin won't start on them anyway.
2012-07-24 13:56:14 +00:00
Corinna Vinschen 00a76ece10 * net.cc (get_adapters_addresses): Only create thread on affected
systems.  Change comment acordingly.
	* wincap.h (wincaps::has_gaa_largeaddress_bug): New element.
	* wincap.cc: Implement above element throughout.
	(wincap_8): New globale wincaps to support Windows 8.
	(wincapc::init): Take Windows 8 into account.  Set new
	has_gaa_largeaddress_bug member to false on 32 bit systems.
2012-05-03 08:34:44 +00:00
Christopher Faylor aba77cbe8f wincap.h: Rename assitant to assistant throughout. wincap.cc: Ditto.
* devices.in (exists_console): Use fhandler_console::exists () rather than raw
test.
* devices.cc: Regenerate.
* fhandler.h (fhandler_console::exists): Define new function.
* fhandler_console.cc (fhandler_console::need_invisible): Use
fhandler_console::exists () rather than raw test.
* spawn.cc: Rename assitant to assistant throughout.
(child_info_spawn::worker): Simplify test for when to start a non-Cygwin
process in its own process group.  Just do it whenever we start a non-Cygwin
process.
2012-04-15 17:51:22 +00:00