Commit Graph

144 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 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 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 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 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 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
Corinna Vinschen 801bf9f272 * shared.cc (shared_info::init_obcaseinsensitive): Check actual state
of case sensitivity on post-Windows 2000 systems.
	* wincap.h (wincaps::kernel_is_always_casesensitive): New element.
	* wincap.cc: Implement above element throughout.
2012-02-21 17:03:51 +00:00
Corinna Vinschen 1cb1472404 * ntdll.h (struct _PEB): Add EnvironmentUpdateCount member.
* spawn.cc (child_info_spawn::worker): Speed up job recognition.  Expand
	comment to explain every little detail and so we never forget.
	* wincap.h (wincaps::has_program_compatibility_assitant): New element.
	* wincap.cc: Implement above element throughout.
2012-02-17 14:26:18 +00:00
Corinna Vinschen f08bc85858 * dcrt0.cc (dll_crt0_0): Check for wincap.wow64_has_secondary_stack
rather than for wincap.is_wow64.  Accommodate name change from
	wow64_has_64bit_parent to wow64_needs_stack_adjustment.  Align comment.
	(_dll_crt0): Ditto.
	* wincap.h (wincaps::wow64_has_secondary_stack): New element.
	* wincap.cc: Implement above element throughout.
	(wincapc::init): Set wow64_has_secondary_stack to false on non-64 bit
	systems.
	* wow64.cc (wow64_needs_stack_adjustment): Rename (hopefully the last
	time) from wow64_has_64bit_parent.
	(wow64_eval_expected_main_stack): Fix comment to reflect real life.
	(wow64_test_for_64bit_parent): Fix comment.
	* wow64.h (wow64_needs_stack_adjustment): Accommodate new name.
2011-12-19 12:50:35 +00:00
Corinna Vinschen c52fd6cd47 * sec_auth.cc (get_token_group_sidlist): Add CONSOLE LOGON SID on
systems supporting it.  Never add SERVICE SID but keep code in for
	future reference.  Explain why.
	(get_priv_list): Add cygpsid pointer parameter.  Point it to the
	mandatory integrity SID which matches account and privileges.
	(create_token): Fetch mandatory integrity SID from call to
	get_priv_list.
	(lsaauth): Call get_priv_list with additional NULL pointer.  Change
	comment accordingly.
	* sec_helper.cc (well_known_console_logon_sid): New static SID.
	(cygpriv): Change to structure containing extra flag to store info
	about required integrity level.
	(privilege_luid): Accommodate changes to cygpriv.  Return integrity
	level in new high_integrity parameter.
	(privilege_name): Accommodate changes to cygpriv.
	(set_privilege): Drop trailing \n from debug output.
	(set_cygwin_privileges): Don't set SE_CREATE_GLOBAL_PRIVILEGE anymore
	since it's just not needed, but keep code in for future reference.
	Change comment accordingly.
	* security.h (well_known_console_logon_sid): Declare.
	(privilege_luid): Align declaration to above change.
	* wincap.h (wincaps::has_console_logon_sid): New element.
	* wincap.cc: Implement above element throughout.
2011-10-15 16:31:57 +00:00
Christopher Faylor 53ad6f1394 * cygthread.cc (cygthread::async_create): Define new function.
* cygthread.h (cygthread::create): Use correct regparm.
(cygthread::standalone): Delete from class and from all constructors.
(cygthread::cygthread): Use three only arguments for detached threads, and
start the thread via QueueUserAPC/async_create.
* dcrt0.cc (dll_crt0_0): Remove handling for wincap.has_buggy_thread_startup.
(dll_crt0_1): Ditto.
* wincap.cc: Ditto throughout.
* wincap.h: Ditto.
2011-07-30 20:50:23 +00:00
Corinna Vinschen 89d3c72d51 * child_info.h (CURR_CHILD_INFO_MAGIC): Update.
(class child_info_fork): Remove stacksize, add stackaddr and guardsize
	members.
	* dcrt0.cc (child_info_fork::alloc_stack_hard_way): Partial rewrite
	to regenerate the stack exactly as in the parent.
	(child_info_fork::alloc_stack): Set stackaddr to 0, rather than
	stacksize.
	(dll_crt0_1): Check for stackaddr before changing the stack addresses
	in the TEB.
	* fork.cc (frok::child): Check for stackaddr here.
	(frok::parent): Set ch.stackaddr and ch.guardsize if not called from
	the main thread.
	* init.cc (dll_entry): Replace pointer to NT_TIB with pointer to TEB.
	Fix incorrectly changed address test before removing _my_tls.
	Set StackLimit to NULL on Windows 2000.  Explain why.
	* miscfuncs.cc (struct thread_wrapper_arg): Store stackbase rather
	than stacksize, store commitaddr, remove guardsize.  Store all pointers
	as char * for easier address arithmetic.
	(thread_wrapper): Rewrite to remove OS stack before calling thread
	function.  Add lots of comments to explain what we do.
	(CygwinCreateThread): Reserve our own stack in case we got no
	application stack.  Add comments.
	* ntdll.h (struct _TEB): Extend defintion up to DeallocationStack
	member.
	* thread.cc (pthread_attr::pthread_attr): Use "(size_t) -1"
	rather then 0xffffffff.
	* wincap.h (wincaps::has_stack_size_param_is_a_reservation): New
	element.
	* wincap.cc: Implement above element throughout.
2011-05-20 07:23:11 +00:00
Corinna Vinschen 883ea27df0 * heap.cc (heap_init): Rewrite initial heap allocation to use addresses
beyond 0x20000000.  Explain why and how.
	* shared.cc (shared_info::heap_slop_size): Remove.
	* shared_info.h (class shared_info): Remove heap_slop_inited and
	heap_slop members.  Remove heap_slop_size declaration.
	(CURR_SHARED_MAGIC): Update.
	* wincap.cc: Throughout, drop heapslop.
	* wincap.h (struct wincaps): Drop heapslop.
2011-05-16 10:27:14 +00:00
Corinna Vinschen c29e693388 * fhandler_proc.cc (format_proc_uptime): Don't call GetSystemInfo.
Fetch CPU count from wincap.
	(format_proc_stat): Ditto.
	* globals.cc (system_info): Move to wincap.
	* heap.cc (heap_init): Fetch page size from wincap.
	* syscalls.cc (getpagesize): Fetch allocation granularity from wincap.
	(getsystempagesize): Fetch page size from wincap.
	* wincap.cc (wincap_2003): Default is_server to false.
	(wincapc::init): Call GetSystemInfo here.  Always set is_server value.
	* wincap.h (class wincapc): Add system_info as private member.
	(wincapc::cpu_count): New public method.
	(wincapc::page_size): Ditto.
	(wincapc::allocation_granularity): Ditto.
2011-05-10 15:39:02 +00:00