aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2026-02-12Silence -Wold-style-definition warningsHEADgithub/mastergithub/mainmastermainKim Kuparinen8-28/+10
Hi, I noticed that there were a few warnings about old-style function definitions. I saw some other patches fixing the same warning, so this just continues on from them. Now everything compiles neatly on my machine at least :) Signed-off-by: Kim Kuparinen <kimi.h.kuparinen@gmail.com>
2026-02-12Cygwin: hookapi.cc: Fix some handles not being inherited when spawningIgor Podgainoi1-0/+2
Under Windows on Arm (AArch64), the function hook_or_detect_cygwin will return NULL early, which will cause the call to real_path.set_cygexec in av::setup to accept false as a parameter instead of true. Afterwards, in child_info_spawn::worker the call to child_info_spawn::set would eventually pass that false result of real_path.iscygexec() to the child_info constructor as the boolean variable need_subproc_ready, where the flag _CI_ISCYGWIN will be erroneously not set. Later in child_info_spawn::worker the failed iscygwin() flag check will cause the "parent" process handle to become non-inheritable. This patch fixes the non-inheritability issue by introducing a new check for the IMAGE_FILE_MACHINE_ARM64 constant in the function PEHeaderFromHModule. Tests fixed on AArch64: winsup.api/signal-into-win32-api.exe winsup.api/ltp/fcntl07.exe winsup.api/ltp/fcntl07B.exe winsup.api/posix_spawn/chdir.exe winsup.api/posix_spawn/fds.exe winsup.api/posix_spawn/signals.exe Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
2026-02-12Cygwin: configure: disable High Entropy VA (64-bit ASLR) on AArch64Igor Podgainoi4-5/+5
Currently Cygwin does not support the High Entropy Virtual Addressing feature, also known as IMAGE_DLL_CHARACTERISTICS_HIGH_ENTROPY_VA and 64-bit Address Space Layout Randomization in Windows. Whereas on systems running on the x86_64 architecture this feature is already disabled by default in the toolchain during the build process, the AArch64 version of the toolchain leaves it enabled, even though it is not mandatory to use it on Windows on Arm. Only the normal ASLR flag IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE is mandatory, which this patch does not address. Therefore, this patch manually introduces the addition of High Entropy VA disabling flags into several places in various Makefile.am files. This should prevent memory overlap bugs on AArch64. Tests fixed on AArch64: winsup.api/ltp/fork06.exe winsup.api/ltp/fork07.exe winsup.api/ltp/fork11.exe Signed-off-by: Igor Podgainoi <igor.podgainoi@arm.com>
2026-02-12stdatomic.h: use latest FreeBSD file verbatimCorinna Vinschen1-27/+27
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-12features.h: define __ISO_C_VISIBLE as 2023 for ISO C23Corinna Vinschen3-6/+6
Aligned definition with FreeBSD to simplify porting FreeBSD headers. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-12machine/_default_types.h: define __ptrdiff_t and __wchar_tCorinna Vinschen1-0/+14
These are not strictly necessary, but POSIX headers can define other types based on them even if stddef.h isn't included. It also simplifies porting BSD headers. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-12stdint.h: move fast type evaluation to machine/_default_types.hCorinna Vinschen2-71/+92
Move the heavy machinery evaluating the fast types from stdint.h to machine/_default_types.h. Do not try to guess from INTMAX. In the unlikely case that __INT_FASTn_TYPE__ and __UINT_FASTn_TYPE__ are not defined, use the size-correct base types instead, just as with the least types. Nice side-effect: We don't need the "define fast as least" fallback code in stdint.h anymore, given that the definitions of least and fast types in machine/_default_types.h are now equivalent: If fast couldn't be defined, least couldn't have been defined either. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-09stdatomic.h: add atomic definitions for char8_t, char16_t and char32_tCorinna Vinschen1-3/+7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-09Cygwin: uchar.h: define char16_t / char32_t in terms of __char16_t / __char32_tCorinna Vinschen1-2/+2
Now that we have base definitions for these types, use them. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-09machine/_default_types.h: add definitions for __char16_t / __char32_tCorinna Vinschen1-0/+14
These types are to be used from stdatomic.h and uchar.h. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-09libc/include/regex.h: Add include of <sys/_types.h> for off_tJoel Sherrill1-1/+2
The winsup/ version of regex.h already had this include. Without it, including <regex.h> by itself would not compile.
2026-02-03Cygwin: security: make sure the type DBGSID is in the DLL debug infoCorinna Vinschen1-0/+5
This helps debugging the DLL when it comes to Windows account info a lot. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-03Cygwin: gencat: define __deadCorinna Vinschen1-0/+4
NetBSD defines __dead as __attribute__((__noreturn__)). Add a matching macro expression. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-03Cygwin: gencat: update to latest from NetBSDCorinna Vinschen1-123/+307
NetBSD gencat version 1.37 Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-03Cygwin: accounts: (re-)add flag for unix uid/gid cachingCorinna Vinschen4-8/+13
Commit b39fa2c88da8 ("* autoload.cc (CheckTokenMembership): Import.") introduced a method to recycle a ldap connection throughout a call stack. This broke caching the mapping from remote NFS or Samba uid/gid values to Cygwin uid/gid values partially. The pldap pointer given to pwdgrp::fetch_account_from_windows() was supposed to be NULL if not called from getpwent/getgrent, but in fact it was set to non-NULL in many callers for performance reasons. Re-introduce a bool argument telling pwdgrp::fetch_account_from_windows() if caching is desired or not, and set it to false only when called from getpwent/getgrent. Fixes: b39fa2c88da8 ("* autoload.cc (CheckTokenMembership): Import.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-02Cygwin: readdir: allow using FileIdBothDirectoryInformation on NFSCorinna Vinschen1-2/+9
As the comment in opendir() already outlines, dangling NFS symlinks only show up in directory listings with FileIdBothDirectoryInformation, if the NFS share is mounted to a drive letter. For that reason we always use FileNamesInformation on NFS instead. Add a check if the path is a drive letter path. If so, switch to using FileIdBothDirectoryInformation. This should give us a performance gain because this call immediately returns the inode number. We don't have to open every listed file, too, to fetch the inode number. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-02-02towupper/towlower: handle Turkic language special casingThomas Wolff3-5/+23
For case conversion, Unicode has a standard mapping and a separate list of mapping rules for special cases (file SpecialCasing.txt), some of which are also language-dependent (as configured via locale). However, most of these rules are context-dependent, e.g. Greek capital Sigma is lowered to two different small sigmas, depending on the position at the end of a word. The POSIX API function towupper and tolower cannot consider context as they work only on one character at a time. String casing functions are unfortunately not available. The only special case conversions that apply to a single character are i and I in Turkish and Azerbaijani, where i keeps the dot when capitalised (U+0130) and I keeps not having a dot when converted small (U+0131). The patch handles these special cases, based on locale consideration.
2026-01-26Cygwin: spawn: drop CREATE_SEPARATE_WOW_VDM process flagCorinna Vinschen1-1/+5
This is outdated and should have been removed when we dropped 32 bit support. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-26Cygwin: child_info: remove filler bytesCorinna Vinschen1-3/+1
The filler bytes in child_info were only necessary for Vista to workaround a bug in WOW64. We just neglected to remove them so far. Fixes: a4efb2a6698f ("Cygwin: remove support for Vista entirely") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-26Cygwin: fhandler_socket::fchown: fix check for admin userCorinna Vinschen1-1/+1
This has never worked as desired. The check for admin permissions is broken. The call to check_token_membership() expects a PSID argument. What it gets is a pointer to a cygpsid. There's no class-specific type conversion for this to a PSID, so the pointer is converted verbatim. Pass the cygpsid directly, because cygpsid has a type conversion method to PSID defined. Pity that GCC doesn't warn here... Fixes: 859d215b7e00 ("Cygwin: split out fhandler_socket into inet and local classes") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-26Revert "Cygwin: spawn/exec: drop breaking away from job"Corinna Vinschen1-0/+31
This reverts commit c9933e57dab77816b5491c67917d4aac755fa4c6. It turned out that the assumption from commit c9933e57dab7 ("Cygwin: spawn/exec: drop breaking away from job") was blatantly incorrect. Mintty is still triggering the Program Compatibility Assistant (PCA), even on Windows 11, despite having a full, Windows 10/11-compatible manifest. Apparently some heuristic in PCA finds something fishy in mintty, but there's no way to avoid something for which there's no explanation. So we still need the PCA workaround. Fixes: c9933e57dab7 ("Cygwin: spawn/exec: drop breaking away from job") Signed-off-by: Corinna Vinschen <corinna@vinschen.de> --- winsup/cygwin/dcrt0.cc | 2 +- winsup/cygwin/fork.cc | 13 ++++++- winsup/cygwin/globals.cc | 1 + winsup/cygwin/local_includes/child_info.h | 2 +- winsup/cygwin/resource.cc | 41 +++++++++++++++++++---- winsup/cygwin/spawn.cc | 11 ++++++ 6 files changed, 60 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 1d5a452b4fbc..e080aa41bca2 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -894,7 +894,7 @@ dll_crt0_1 (void *) uinfo_init (); /* initialize user info */ - setup_user_rlimits (); + enforce_breakaway_from_job = setup_user_rlimits (!child_proc_info); if (child_proc_info) child_proc_info->inherit_process_rlimits (); diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index eeed7155ee63..3e5d81fe46e8 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -152,7 +152,7 @@ frok::child (volatile char * volatile here) clear_procimptoken (); cygheap->user.reimpersonate (); - setup_user_rlimits (); + setup_user_rlimits (false); ch.inherit_process_rlimits (); #ifdef DEBUGGING @@ -253,6 +253,17 @@ frok::parent (volatile char * volatile stack_here) systems. */ c_flags |= CREATE_UNICODE_ENVIRONMENT; + /* Despite all our executables having a valid manifest, "mintty" still + triggers the "Program Compatibility Assistant (PCA) Service" for + some reason, maybe due to some heuristics in PCA. + We use job objects for rlimits extensively, so we still have to let + child processes breakaway from job. Otherwise we can't add processes + running in different terminals to an already existing per-user job. + The check for this situation is now done in setup_user_rlimits() + called from dll_crt0_1(). */ + if (enforce_breakaway_from_job) + c_flags |= CREATE_BREAKAWAY_FROM_JOB; + errmsg = NULL; hchild = NULL; diff --git a/winsup/cygwin/globals.cc b/winsup/cygwin/globals.cc index 86b0c2718a87..f73c35f88e7f 100644 --- a/winsup/cygwin/globals.cc +++ b/winsup/cygwin/globals.cc @@ -28,6 +28,7 @@ PWCHAR windows_directory = windows_directory_buf + 4; UINT windows_directory_length; UNICODE_STRING windows_directory_path; WCHAR global_progname[NT_MAX_PATH]; +bool NO_COPY enforce_breakaway_from_job; /* program exit the program */ diff --git a/winsup/cygwin/local_includes/child_info.h b/winsup/cygwin/local_includes/child_info.h index f2e4fb165862..e10aa777610c 100644 --- a/winsup/cygwin/local_includes/child_info.h +++ b/winsup/cygwin/local_includes/child_info.h @@ -203,7 +203,7 @@ extern child_info_spawn ch_spawn; #define have_execed_cygwin ch_spawn.has_execed_cygwin () /* resource.cc */ -extern void setup_user_rlimits (); +extern bool setup_user_rlimits (bool); extern "C" { extern child_info *child_proc_info; diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 83ae9add4cdb..12705eb36f78 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -376,8 +376,8 @@ child_info::inherit_process_rlimits () rlimit_as.rlim_max, rlimit_as.rlim_cur); } -static void -__setup_user_rlimits_single (int flags) +static bool +__setup_user_rlimits_single (int flags, bool root_process) { JOBOBJECT_EXTENDED_LIMIT_INFORMATION jobinfo = { 0 }; NTSTATUS status = STATUS_SUCCESS; @@ -385,6 +385,7 @@ __setup_user_rlimits_single (int flags) UNICODE_STRING uname; WCHAR jobname[32]; HANDLE job = NULL; + bool ret = false; RtlInitUnicodeString (&uname, job_shared_name (jobname, PER_USER | flags)); InitializeObjectAttributes (&attr, &uname, OBJ_OPENIF, @@ -393,7 +394,7 @@ __setup_user_rlimits_single (int flags) if (!NT_SUCCESS (status)) { debug_printf ("NtCreateJobObject (%S): status %y", &uname, status); - return; + return false; } /* Did we just create the job? */ if (status != STATUS_OBJECT_NAME_EXISTS) @@ -404,6 +405,28 @@ __setup_user_rlimits_single (int flags) &jobinfo, sizeof jobinfo); } NTSTATUS in_job = NtIsProcessInJob (NtCurrentProcess (), job); + + /* Check if we're already running in a job, even though we're not + running in one of our own user-specific jobs. If so, this process + is doomed, but we can try to create child processes with + CREATE_BREAKAWAY_FROM_JOB, so at least the next process in the + process tree will be happy. + We're only checking processes which have been started from non-Cygwin + processes (root processes of a Cygwin process tree). + Given that breaking away also requires that the foreign job allows + JOB_OBJECT_LIMIT_BREAKAWAY_OK, we're testing this right here, too. */ + if ((flags & HARD_LIMIT) && root_process + && in_job == STATUS_PROCESS_NOT_IN_JOB) + { + status = NtQueryInformationJobObject (NULL, + JobObjectExtendedLimitInformation, + &jobinfo, sizeof jobinfo, NULL); + if (NT_SUCCESS (status) + && (jobinfo.BasicLimitInformation.LimitFlags + & JOB_OBJECT_LIMIT_BREAKAWAY_OK)) + ret = true; + } + /* Assign the process to the job if it's not already assigned. */ if (NT_SUCCESS (status) && in_job == STATUS_PROCESS_NOT_IN_JOB) { @@ -412,13 +435,17 @@ __setup_user_rlimits_single (int flags) debug_printf ("NtAssignProcessToJobObject: %y\r", status); } /* Never close the handle. */ + return ret; } -void -setup_user_rlimits () +bool +setup_user_rlimits (bool root_process) { - __setup_user_rlimits_single (HARD_LIMIT); - __setup_user_rlimits_single (SOFT_LIMIT); + bool in_a_foreign_job; + + in_a_foreign_job = __setup_user_rlimits_single (HARD_LIMIT, root_process); + __setup_user_rlimits_single (SOFT_LIMIT, false); + return in_a_foreign_job; } extern "C" int diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc index 44566c34790e..5b25f7c1cee1 100644 --- a/winsup/cygwin/spawn.cc +++ b/winsup/cygwin/spawn.cc @@ -407,6 +407,17 @@ child_info_spawn::worker (const char *prog_arg, const char *const *argv, systems. */ c_flags |= CREATE_UNICODE_ENVIRONMENT; + /* Despite all our executables having a valid manifest, "mintty" still + triggers the "Program Compatibility Assistant (PCA) Service" for + some reason, maybe due to some heuristics in PCA. + We use job objects for rlimits extensively, so we still have to let + child processes breakaway from job. Otherwise we can't add processes + running in different terminals to an already existing per-user job. + The check for this situation is now done in setup_user_rlimits() + called from dll_crt0_1(). */ + if (enforce_breakaway_from_job) + c_flags |= CREATE_BREAKAWAY_FROM_JOB; + /* Add CREATE_DEFAULT_ERROR_MODE flag for non-Cygwin processes so they get the default error mode instead of inheriting the mode Cygwin uses. This allows things like Windows Error Reporting/JIT debugging -- 2.52.0
2026-01-23Changes for 4.6.0 snapshotnewlib-4.6.0Jeff Johnston7-68/+74
- bump up release to 4.6.0 - regenerate configure and Makefilein
2026-01-22towctrans_l: handle not _MB_CAPABLE targetsCorinna Vinschen1-0/+16
towctrans_l neglected to special case systems for which newlib has been built without _MB_CAPABLE. Add that code equivalent to other wide-char functions, calling the singlebyte functions toupper/tolower.
2026-01-22Cygwin: spawn/exec: drop breaking away from jobCorinna Vinschen1-31/+0
Remove breaking away from job during spawn/exec because it's not required anymore for 99% of the processes. This was required back when Cygwin executables didn't have a manifest claiming compatibility with all Windows versions since Vista. These days, only very few executables missing the manifest are left, certainly none in the distro. This frees up job breakaway for potential extensions to setrlimit. Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-21Fix dummy names in reent directoryAndrew Oates2-2/+2
libc: fix _dummy_signal_syscalls name in signalr.c libc: fix _dummy_fstat64_syscalls name in fstat64.c Co-authored-by: Jeff Johnston <jjohnstn@redhat.com>
2026-01-16Cygwin: gendef: Implement sigsetjmp for AArch64Thirumalai Nagalingam1-0/+21
Co-authored-by: Radek Bartoň <radek.barton@microsoft.com> Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: gendef: Implement siglongjmp for AArch64Thirumalai Nagalingam1-0/+26
Co-authored-by: Radek Bartoň <radek.barton@microsoft.com> Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: gendef: Implement _sigbe function for TLS stack management on AArch64Thirumalai Nagalingam1-0/+36
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: gendef: Implement _sigfe function for TLS handling on AArch64Thirumalai Nagalingam1-0/+37
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: gendef: add _sigfe_maybe for TLS initialization checks on AArch64Thirumalai Nagalingam1-2/+18
Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: gendef: add ARM64 stub for $fe in gendefThirumalai Nagalingam1-0/+11
This patch adds ARM64 stub with stack allocation and SEH unwind directives in gendef for $fe routine. Signed-off-by: Evgeny Karpov <Evgeny.Karpov@microsoft.com> Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-16Cygwin: internal_getlogin: always call internal_getgroupsCorinna Vinschen2-2/+5
Commit 29b7313d2225 ("* cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.") changed an initial conditional to skip calling internal_getgroups() if we're running with cygserver account caching in place. This breaks changing the primary group. Unfortunately the commit message doesn't explain why the change was made. Just calling internal_getgroups() all the time fixes this behaviour. Fixes: 29b7313d2225 ("* cygheap.h (enum cygheap_pwdgrp::cache_t): Remove.") Addresses: https://cygwin.com/pipermail/cygwin/2026-January/259250.html Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-15Cygwin: c32rtomb: add missing check for invalid UNICODE characterCorinna Vinschen2-0/+12
c32rtomb neglects to check the input character for being outside the valid UNICODE planes. It happily converts the invalid character into a valid (but wrong) surrogate pair and carries on. Add a check so characters beyond 0x10ffff are not converted anymore. Return -1 with errno set to EILSEQ instead. Fixes: 4f258c55e87f ("Cygwin: Add ISO C11 functions c16rtomb, c32rtomb, mbrtoc16, mbrtoc32.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2026-01-15Cygwin: doc: Explictly name the output when building .info filesJon Turney1-3/+3
This works around a bug in docbook2x-texi seen with bash 5.3 while cross-building from Fedora 42. If the --output-dir option to db2x_texixml isn't specified (always the case when invoked by docbook2x-texi), then the script attempts cd '' which is now an error ("cd: null directory") rather than being treated as equivalent to cd '.' Instead, explicitly name the output file when building .info files.
2026-01-10Cygwin: Rename cross-bootstrap config option back to mingw-progs to avoid ↵J.H. vd Water4-7/+11
confusion Revert the option name in AC_ARG_WITH([cross-bootstrap] back to its previous name, mingw-progs, in order to avoid confusion ... Also revert the meaning of the macro. About 10 years ago, Foley was messing around with a stage1 gcc cross-compiler for Cygwin on Linux, and decided he only required cygwin1.dll. He did not like to rebuild assets, like cygcheck, strace, for which he was forced to install the mingw-runtime (then: mingw-crt) and the MinGW toolchain. Foley decided to change the option name of the AC_ARG_WITH([mingw-progs] macro in winsup/configure.ac; however, he also inverted the meaning of the --with(out)-FOO switch (as Foley also inverted the test that follows the macro) ... --with-FOO changed from: "search for mingw" ... to "do NOT search for mingw" --without-FOO changed from: "do NOT search for mingw" ... to "search for mingw" Originally: AC_ARG_WITH([mingw-progs], ... if test "x$with_mingw_progs" != xno; then # search for MinGW After: AC_ARG_WITH([cross-bootstrap], ... if test "x$with_cross_bootstrap" != "xyes"; then # search for MinGW Foley changed the option name of the macro to "cross-bootstrap", which confused not only Corinna (since we went on to document the option as if it hadn't been inverted), but is still confusing to everyone today! Therefore I suggest to revert both the option name of the macro and the meaning of the macro to what they were: option name: mingw-progs, meaning: search for the MinGW toolchain (if --with-mingw-progs is specified). This reverts the remaining parts of e7e6119241d02241c3d114cff037340c12245393, after AC_WINDOWS_LIBS was removed in 78bfd7dbb96eae1d9541711578ff08e56ddbca5b. Signed-off-by: J.H. vd Water <dhr-incognito@xs4all.nl> Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk>
2026-01-10Cygwin: flock: Remove the unnecessary fdtab lockTakashi Yano1-2/+2
There are two more fdtab enumerations using fdtab locking, one is in inode_t::del_my_locks(), and the other is in fixup_lockf_after_exec(). They merely count the file descriptors affected by the corresponding lock, so locking fdtab seems unnecessary. The latter runs only during execve(), when no other threads exist. Therefore, these two locks are redundant. This patch removes them. Suggested-by: Corinna Vinschen <corinna@vinschen.de> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2026-01-09Cygwin: Update _endian.h to handle unsupported archThirumalai Nagalingam1-2/+6
Update _endian.h so that it explicitly throw an error when encountering an unsupported architecture instead of returning the unmodified x. Also tighten the arch detection logic by adding an explicit LE check. Fixes: b14e2e7d15a8 ("Cygwin: _endian.h: Add AArch64 implementations for ntohl and ntohs") Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-08Cygwin: Update release note for 3.6.6Takashi Yano1-0/+4
2026-01-08Cygwin: flock: Do not lock fdtab in create_lock_in_parent()Takashi Yano1-1/+1
Otherwise, a deadlock can occur if the child process attempts to lock a file while the parent process is closing the same file, which is already locked. The deadlock mechanism is as follows. When the child process attempts to lock a file, it notifies the parent process by calling CreateRemoteThread(), which creates a remote thread in the parent. That thread checks whether the file being locked is currently opened in the parent. During the operation, cygheap->fdtab is temporarily locked in order to enumerate the file descriptors. However, if the parent process is closing the same file at that moment, it also locks fdtab via cygheap_fdget cfd(fd, true) in __close(). If the parent acquires th fdtab lock first, it proceeds to call del_my_locks(), which attempts to lock the inode in inode_t:get(). At this point, the inode is already locked in the child, so the parent waits for the child to release the inode. Meanwhile, the child is waiting to acquire the fdtab lock, which is still held by the parent. As a result, the parent and child become deadlocked. There are two options to fix the deadlock: eather avoid locking fdtab in __close(), or avoid locking fdtab in create_lock_in_parent(). The latter is safer than the former because __close() calls release(), which modifies the fdtab contents, while cygheap_fdenum only reads them. Therefore, to resolve the issue, this patch removes the fdtab lock from create_lock_in_parent(). Addresses: https://cygwin.com/pipermail/cygwin/2025-December/259187.html Fixes: dbf576fd8614 ("(create_lock_in_parent): New thread function to create lockf_t structure in parent process.") Reported-by: Nahor <nahor.j+cygwin@gmail.com> Reviewed-by: Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2026-01-07Cygwin: _endian.h: Add AArch64 implementations for `ntohl` and `ntohs`Thirumalai Nagalingam1-0/+10
Add AArch64-specific implementations of __ntohl() and __ntohs() in `winsup/cygwin/include/machine/_endian.h`. For AArch64 targets, use the `REV` and `REV16` instructions to perform byte swapping, with explicit zero-extension for 16-bit values to ensure correct register semantics. Signed-off-by: Thirumalai Nagalingam <thirumalai.nagalingam@multicorewareinc.com>
2026-01-04Cygwin: thread: Fix stack alignment for PTHREAD_CANCEL_ASYNCHRONOUSTakashi Yano1-0/+25
The test case winsup/testsuites/winsup.api/pthread/cancel2 fails on Windows 11 and Windows Server 2025, while it works on Windows 10 and Windows Server 2022. PTHREAD_CANCEL_ASYNCHRONOUS is implemented by forcing the target thread's instruction pointer (IP) to pthread:: static_cancel_self() using [GS]etThreadContext(). static_cancel_self() will call Windows API function during thread shutdown. A misaligned stack will lead to unexpected exceptions. Previously, the stack pointer was not maintained to 16-byte alignment, even though this is required by 64-bit Windows ABI. At the start of the function prologue, the stack is expected to be at an offset of 8 byte from 16-byte boundary (SP % 16 == 8) in x86_64 architecture, as the call instruction has just pushed the return IP onto the stack. However, this appears to have been overlooked when cygwin first added x86_64 support. This patch fixes this issue by aligning the stack pointer as well as the instruction pointer in the PTHREAD_CANCEL_ASYNCHRONOUS handling. Addresses: https://cygwin.com/pipermail/cygwin/2025-December/259117.html Fixes: 61522196c715 ("* Merge in cygwin-64bit-branch.") Reported-by: Takashi Yano <takashi.yano@nifty.ne.jp> Reviewed-by: Jon Turney <jon.turney@dronecode.org.uk> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-12-22libgloss: mips: Support Lite Exit in crt0Spencer Alves1-0/+11
Based on the equivalent code in ARM
2025-12-22Cygwin: add release note for primary group override fixCorinna Vinschen1-0/+4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-12-22Cygwin: uinfo: fix overriding group from SAM comment on AD member machinesCorinna Vinschen1-2/+8
When overriding the (localized) primary group "None" of a local SAM account via SAM comment entry (e.g. '<cygwin group="some_group"/>') on a Active Directory domain member machine, we have to take into account, that the local account domain (actually the machine name) is always prepended to local account names, i. e. MACHINE+account because the names without prepended domain are reserved for the primary AD domain accounts. Therefore commit cc332c9e271b added code to prepend the local account domain to the group name from the SAM comment, if the machine is a domain member. But here's the problem: If the group in the SAM comment entry is a real local group, prepending the local account domain is all nice and dandy. But if the account used in the SAM comment is a builtin like "Authenticated Users" (S-1-5-11) or an alias like "Users" (S-1-5-32-545), this falls flat. This patch keeps the check for "MACHINE+account" first. This avoids fetching the AD group rather than the local SAM group, if a local group has the same name as an AD group. But now, if the group prepended with the local account domain doesn't result in a valid group entry, try again with the naked group name, to allow aliases or builtin accounts to pass as primary group. Fixes: cc332c9e271b ("* uinfo.cc [...] (pwdgrp::fetch_account_from_windows): Drop outdated comment. Fix code fetching primary group gid of group setting in SAM description field.") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-12-22Cygwin: uinfo: allow to override user account as primary groupCorinna Vinschen1-2/+6
Do not only allow to override the (localized) group "None" as primary group, but also the user account. The user account is used as primary group in the user token, if the user account is a Microsoft Account or an AzureAD account. Fixes: dc7b67316d01 ("Cygwin: uinfo: prefer token primary group") Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-12-22Cygwin: uinfo: correctly check and override primary groupCorinna Vinschen1-2/+5
Commit dc7b67316d01 ("Cygwin: uinfo: prefer token primary group") broke the code overriding the primary group in two different ways: - It changed the way myself->gid was set before checking its value. Prior to dc7b67316d01, myself->gid was always set to the primary group from the passwd entry (pw_gid). With the patch, it was set to the primary group from the Windows user token (token_gid) in the first place. The following condition checking if pw_gid is different from token_gid did so, by checking token_gid against myself->gid, rather than against pw_gid. After dc7b67316d01 this was always false and the code block overriding the primary group in Cygwin and the Windows user token with pw_gid was never called anymore. The solution is obvious: Do not check token_gid against myself->gid, but against the desires primary GID value in pw_gid instead. - The code block overriding the primary group simply assumed that myself->gid was already set to pw_gid, but, as outlined above, this was not true anymore after dc7b67316d01. This is a subtle error, because it leads to having the wrong primary GID in `id' output, while the primary group SID in the user token was correctly set. But as soon as you run this under strace or GDB, the problem disappears, because the second process tree under GDB or strace takes over from the already changed user token. The solution is to override myself->gid with pw_gid once more, after successfully changing the primary GID to pw_gid. Fixes: dc7b67316d01 ("Cygwin: uinfo: prefer token primary group") Addresses: https://cygwin.com/pipermail/cygwin/2025-December/259068.html Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2025-12-22Unicode table build: update data tables to Unicode 17.0Thomas Wolff4-153/+256
as done by either of the following script invocations: cd newlib/libc; make -f Makefile.unidata cd build/*/newlib; make unidata
2025-12-22Unicode table build: update scripts for generation of width dataThomas Wolff2-25/+26
needed to handle recent changes in Unicode.org data file layout
2025-12-22Cygwin: pty: Refactor workaround code for pseudo console outputTakashi Yano1-154/+148
Currently, there are four separate workarounds for pseudo console output in pty_master_fwd_thread. Each workaround has its own 'for' loop that iterates over the entire output buffer, which is not efficient. This patch consolidates these loops and introduces a single state machine to handle all workarounds at once. In addition, the workarounds are moved into a dedicated function, 'workarounds_for_pseudo_console_output()' to improve readability. Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de> Reviewed-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>, Corinna Vinschen <corinna@vinschen.de> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
2025-12-22Cygwin: utils: refresh tzmap.hCorinna Vinschen1-7/+3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>