Commit Graph

18769 Commits

Author SHA1 Message Date
Ken Brown ac8cf0681c Cygwin: document the last bug fix 2019-07-24 14:52:55 -04:00
Ken Brown 87b8a4cdea Cygwin: fhandler_termios::tcsetpgrp: check that argument is non-negative
Return -1 with EINVAL if pgid < 0.

Previously tcsetpgrp() would blindly go ahead and set the pgid of the
controlling terminal to a negative value, causing later calls to
various functions to fail.

For example, gdb has code like the following:

  tcsetpgrp (0, getpgid (inf->pid));

If getpgid (inf->pid) fails (returns -1), then this code would set the
pgid of fd 0 to -1, so that some later calls to getpgid() would also
return -1.  This caused the problem reported here:

  https://cygwin.com/ml/cygwin/2019-07/msg00166.html.
2019-07-24 14:44:33 -04:00
Ken Brown d9d9c28a90 Cygwin: document the last bug fix 2019-07-20 21:57:14 -04:00
Ken Brown 0ea62854b4 Cygwin: socket files are not lnk special files
Change path_conv::is_lnk_special() so that it returns false on socket
files.

is_lnk_special() is called by rename2() in order to deal with special
files (FIFOs and symlinks, for example) whose Win32 names usually have
a ".lnk" suffix.  Socket files do not fall into this category, and
this change prevents ".lnk" from being appended erroneously when such
files are renamed.

Remove a now redundant !pc.issocket() from fhandler_disk_file::link().
2019-07-20 18:45:39 -04:00
Ken Brown 585370924b Cygwin: remove path_conv::is_fs_device()
It is used only once.
2019-07-20 18:39:11 -04:00
Ken Brown 24b695a447 Cygwin: remove path_conv::is_auto_device()
It is used only once, and the name is supposed to suggest "device that
is not based on the filesystem".  This intended meaning is clearer if
we just replace is_auto_device() by its definition at the place where
it's used.
2019-07-20 18:25:18 -04:00
Ken Brown 669dbc9996 Cygwin: fhandler_*: remove isdevice() and is_auto_device()
isdevice() is used only in the definition of is_auto_device().  And
the latter is used only once, in a context where isdevice() always
returns true.
2019-07-20 18:22:57 -04:00
Ken Brown c4d5b61f16 Cygwin: honor the O_PATH flag when opening a FIFO
Previously fhandler_fifo::open would treat the FIFO as a reader and
would block, waiting for a writer.
2019-06-26 20:51:42 -04:00
Corinna Vinschen fddcd84fd4 Cygwin: bump version to 3.0.8
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-30 19:56:58 +02:00
Corinna Vinschen 01c253a4c5 Cygwin: Add release info for 3.0.7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-30 18:48:58 +02:00
Corinna Vinschen 2f5cc45829 Cygwin: update era and message locale data
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
(cherry picked from commit a4e62e3a4c)
2019-04-30 18:35:42 +02:00
Erik M. Bray debad46cfe Minor improvements to socket error handling:
* Change default fallback for failed winsock error -> POSIX error
  mappings to EACCES, which is a valid errno for more socket-related
  syscalls.

* Added a few previously missing entries to the wsock_errmap table
  that have obvious POSIX errno.h analogues.

(cherry picked from commit 489e7e2048)
2019-04-23 17:21:38 +02:00
Corinna Vinschen ca4dd0b35c Cygwin: bump version to 3.0.7
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-06 18:03:42 +02:00
Corinna Vinschen 51dc93a98b Cygwin: add latest signal handling fixes to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-06 18:03:42 +02:00
Corinna Vinschen 54923ed173 Cygwin: signals: setcontext: fix setting sigmask
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-05 12:17:38 +02:00
Corinna Vinschen 367d588e59 Cygwin: signals: make setcontext work from signal handlers
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-05 11:26:18 +02:00
Corinna Vinschen a5da9128eb Cygwin: signals: restore sigmask from context given to signal handler
In case SA_SIGINFO flag is given, the signal handler may change
the context and the application is supposed to pick up from the
changed context.  So far we don't do that, so the context given
to the signal handler is basically read-only, unless the signal
handler calls setcontext or swapcontext.

For a start, restore the thread's signal mask from the uc_sigmask
value of the context given to the signal handler.

If that's feasible for Cygwin, we restore the entire context from
the context changed by the signal handler in a followup patch.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-05 11:26:18 +02:00
Corinna Vinschen b9009a5880 Cygwin: winpids: Fix getting process multiple times, take 2
commit d1be0a59d4,
"Cygwin: winpids: Fix getting process multiple times"
fixed duplicate processes in ps -W output, but it fixed
the symptom, not the cause.  It also didn't fix the problem
that the `ps' process itself may show up twice in its own
output.

This patch fixes it.  The spawn worker only deleted the
"winpid.PID" symlink of the current process if the child is
a non-Cygwin process, under the assumption that the exec'ing
process exits anyway.  However, the Window in which both
winpid.PID symlinks point to the same cygpid.PID area is just
too long.  The spawn worker now also deletes its own winpid.PID
symlink if the exec'ed process is a Cygwin process.

Additionally the fix from d1be0a59d4
is now performed on the calling process, too.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-04-02 13:00:44 +02:00
Corinna Vinschen 4fb8d091f2 Cygwin: bump version to 3.0.6
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-31 13:10:56 +02:00
Corinna Vinschen 328ee5c820 Cygwin: document ps -W duplication bug fix
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-31 12:49:26 +02:00
J.H. van de Water 7b06893f93 Cygwin: fix: seteuid32() must return EPERM if privileges are not held.
Starting w/ the intro of S4U, seteuid32() calls lsaprivkeyauth(), then
s4uauth(). s4uauth calls LsaRegisterLogonProcess().
LsaRegisterLogonProcess fails w/ STATUS_PORT_CONNECTION_REFUSED, if the
proper privileges are not held.
Because of RtlNtStatusToDosError(), this status would be mapped to
ERROR_ACCESS_DENIED, which in turn would map to EACCES. Therefore it is
useless to add this status to errmap[] (errno.cc), as s4auauth() should
return EPERM as errno here (i.e. if process is not privileged).

Hence the kludge.

Before the intro of S4U, seteuid32() called lsaprivkeyauth(), then
lsaauth(), then create_token(). Before the intro of Vista, the latter
would have called NtCreateToken().
NtCreateToken() would have failed w/ STATUS_PRIVILEGE_NOT_HELD for a
process w/o the proper privileges. In that case, calling seteuid32()
would have returned EPERM (as required).

Since the intro of Vista, and if the process had been started from an
UNelevated shell, create_token() does NOT reach NtCreateToken()!
As create_token() failed to properly set errno in that case, calling
seteuid32() would return errno as set by lsaauth(), i.e. EACCES, not
in agreement w/ Posix (a bug which was present for years).
(lsaauth() called LsaRegisterLogonProcess() which would fail)
2019-03-27 17:12:43 +01:00
Corinna Vinschen d1be0a59d4 Cygwin: winpids: Fix getting process multiple times
Switching to Cywin-only PIDs introduced a new problem when collecting
Cygwin processes for `ps -W': A process can show up multiple times
again, if the Cygwin procinfo has been opened for a just execing
process.  The execed process then shows up twice, once as Cygwin
process, but with the wrong Windows PID of the execing process,
once as Windows-only process.

The mechanism used to exclude these stray processes didn't work with
the new Cygwin pid handling anymore.  To fix this

* check if the incoming Windows PID is the same as the PID in the
  procinfo.  If not, we have the PID of the execing process while
  procinfo was already changed,
* always check if the process has already been handled, not only
  for processes we got a procinfo for,
* simplify adding pid to pidlist since pid is now always correct.

While at it, fix comments and comment formatting.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-27 13:54:36 +01:00
Andrew Stubbs e8b23909e4 Add missing includes.
These missing includes were causing build warnings, but also a real bug in
which the "size" parameter to "write" was being passed in 32-bit, whereas it
ought to be 64-bit.  This led to intermittent bad behaviour.
2019-03-25 16:44:10 +01:00
Brian Inglis 23bb2f6608 get and convert boot time once and use as needed 2019-03-25 11:26:17 +01:00
Brian Inglis ee1ad64234 default ps -W process start time to system boot time when inaccessible, 0, -1 2019-03-25 11:26:17 +01:00
Corinna Vinschen 5737045c00 Cygwin: ctrl_c_handler: Use 64 bit timer
Just don't use GetTickCount for obvious reasons

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-24 22:13:00 +01:00
Corinna Vinschen 4afc52d57c Cygwin: sys/cygwin.h: fix formatting
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-23 17:50:47 +01:00
Corinna Vinschen ae3370bb9d Cygwin: strace: print windows and cygwin pid in event output
strace only printed the Windows PID in event output so far.

Especially now that Windows and Cygwin PID are decoupled, the
strace user might like to see the Cygwin pid in event output as
well.  However, at process startup, the process might not have
a Cygwin PID yet.

To mitigate this, always print the Windows PID and only add the
Cygwin pid if it exists.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-23 17:50:00 +01:00
Corinna Vinschen 10900b98d1 Cygwin: wcsxfrm_l: Only byte swap if dest size is > 0
commit c0d7d3e1a2 removed the usage of the
LCMAP_BYTEREV flag in the call to LCMapStringW to workaround a strange
bug in LCMapStringW.  This patch didn't take a userspace call of
wcsxfrm{_l} with NULL buffer and 0 size to evaluate the required buffer
size into account.  This introduced a crash trying to byte swap the
NULL buffer.  This patch fixes that problem.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-19 21:03:06 +01:00
Andrew Stubbs 62c66a39bd AMD GCN: Implement circular buffering.
The GCN port outputs stdout and stderr via a shared-memory interface.
Previously the buffer was limited to 1000 write operations, which was enough
for testing purposes, but easy to exhaust.

This patch implements a new circular buffering system allowing a greater
amount of output.  The interface must allow hundreds of hardware threads to
output simultaneously.  The new limit is UINT32_MAX write operations.

Unfortunately, there's no way to tell if the host side has also been updated.
This code will misbehave unless the gcn-run from GCC is also updated (although
it's fine the other way around), but that patch has already been committed.

OK?

Andrew Stubbs
Mentor Graphics / CodeSourcery
2019-03-18 17:38:25 +01:00
Corinna Vinschen 38322b9bf6 Cygwin: proc: fix /proc/version output after uname change
3.0.0 changed uname but missed to align /proc/version
which then used the old uname function on the new uname
struct.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-18 11:34:00 +01:00
Corinna Vinschen df960cb954 Cygwin: bump version to 3.0.5
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-18 11:29:00 +01:00
Jeff Johnston 1cff36cdd7 Add semihosting docs for nios2 and m68k
Author: Sandra Loosemore <sandra@codesourcery.com>
Date:   Wed Mar 13 20:22:16 2019 -0700

    Add semihosting documentation for nios2 and m68k.

    QEMU maintainers have asked for a specification of the nios2
    semihosting interface.  Since it's essentially a copy of the m68k
    implementation, this patch adds a document for that target as well.
2019-03-14 10:23:25 -04:00
Corinna Vinschen 004d8adfa2 Cygwin: acls: allow converting empty acl to text
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-13 12:09:11 +01:00
Corinna Vinschen 111b34bb1b Cygwin: proc: add missing LF to /proc/<PID>/stat output
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-13 11:26:58 +01:00
Corinna Vinschen 1def2148d2 Cygwin: ps: simplify code
Always use NtQuerySystemInformation(SystemProcessIdInformation).
This drops two code paths calling NtQueryInformationProcess or
GetModuleFileNameExW and only requires to open the process
to fetch system time info.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 21:21:13 +01:00
Corinna Vinschen 37a046181e Cygwin: ps: show *all* processes in ps -W output
There's a long-standing bug in ps -W.  It only shows processes which ps
can open with PROCESS_QUERY_LIMITED_INFORMATION permissions.  However,
that fails for a lot of system processes. Due to that, output is
basically restricted to processes in the same session, as well as Cygwin
processes... which isn't *quite* what ps -W was supposed to do.

Basically we only need to open the process to fetch the image name.  If
that fails, utilize the undocumented SystemProcessIdInformation info
class introduced with Windows Vista, which allows to fetch the image
name by specifying the PID.  Restructure the code a bit.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 20:55:29 +01:00
Corinna Vinschen a2693428b9 Cygwin: ntdll.h: Add SystemProcessIdInformation
Add SystemProcessIdInformation to SYSTEM_INFORMATION_CLASS
and define struct _SYSTEM_PROCESS_ID_INFORMATION.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 20:11:38 +01:00
Corinna Vinschen de7f13aa9a Cygwin: loadavg: improve debugging of load_init
When logging in via ssh with an unprivileged account,
PdhAddEnglishCounter returns with status 0x800007D0,
PDH_CSTATUS_NO_MACHINE.  We didn't find any workaround
but the changes to improve debugging output may help
in future.  Using UNICODE instead of ANSI functions is
a result of trying to fix this problem.

Also drop the prototype workaround for PdhAddEnglishCounterA.
It's not required anymore since Mingw-w64's pdh.h catched up.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 17:09:42 +01:00
Corinna Vinschen 673a3daa84 Cygwin: add /proc changes to release notes
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:47:31 +01:00
Corinna Vinschen 24f9cb015e Cygwin: fork/exec: Allow all users PROCESS_QUERY_LIMITED_INFORMATION
Create process with standard rights, plus
PROCESS_QUERY_LIMITED_INFORMATION for authenticated users.  This
allows to fetch basic process information and thus /proc/<PID>/stat
to succeed on foreign processes.

While at it, fix formatting in CreateProcess calls.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:41:35 +01:00
Corinna Vinschen 57f1c81fb3 Cygwin: proc: let stat info always succeed
There's no good reason to return blank if some of the info
couldn't be collected.  Drop useless call collecting
SystemProcessorPerformanceInformation.  Always return some
valid start_time, even if we couldn't collect ProcessTimes.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:34:50 +01:00
Corinna Vinschen 4ce7e1bbaa Cygwin: proc: don't request PROCESS_VM_READ perms for stat
The OpenProcess call to generate /proc/<PID>/stat info requests
PROCESS_VM_READ, but that's not required.  Drop it.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:20:42 +01:00
Corinna Vinschen 048f28bfe4 Cygwin: proc: return more useful cmdline
Creating /proc/<PID>/cmdline requires permissions to communicate
with the target process via its signal pipe.  If that fails, the
output is "<defunct>" which doesn't make sense most of the time.
Rather, call format_process_exename in this case to get more useful
process name info, albeit not the full cmdline.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-12 11:17:11 +01:00
Corinna Vinschen d9f934c9e9 Cygwin: fix permissions of winpid symlinks
The winpid symlinks got created with no query permissions, so
only admins could see all Cygwin processes.  Create symlinks
so everyone has query permissions instead.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-11 21:40:04 +01:00
Corinna Vinschen 7cbe4b59d6 Cygwin: bump version to 3.0.4
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-09 20:13:50 +01:00
Corinna Vinschen 4ec5ffc198 Cygwin: posix timers: fix a deadlock
Canceling the timer thread runs under lock.  The thread uses the same
lock to guard its timer_tracker struct access.  If the timing is bad,
timer_settime or timer_delete grab the lock at the same time, the timer
expires.  In the end, cancel waits for the thread sync while the thread
waits for ther lock to be released.

Fix this by not waiting for the thread sync under lock.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-08 12:57:42 +01:00
Corinna Vinschen 094a2a17ad Cygwin: posix timers: fix resource leak
On setting the timer, the thread is accidentally only canceled when
disarming the timer.  This leaks one thread per timer_settimer call.
Move the thread cancellation where it belongs.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-06 22:19:16 +01:00
Corinna Vinschen 633278b877 Cygwin: bump version to 3.0.3
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-05 20:00:30 +01:00
Corinna Vinschen 8551226961 Cygwin: seteuid: do not verify lsaprivkeyauth token
We don't support setting groups via /etc/groups anymore.  Also, the
initgroups group list is created via S4U, so we have "Interactive" vs.
"Network" token, an artificial and entirely irrelevant difference.

So,  "verifying" the lsaprivkeyauth token may lead to rejecting a prefectly
valid token.  Just remove the verify_token call.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
2019-03-04 20:36:26 +01:00