[newlib-cygwin] Fix documentation of cygwin_internal()'s return type.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=adbc3d4bb19771950a0c471cf5303f9f55dc9b4d commit adbc3d4bb19771950a0c471cf5303f9f55dc9b4d Author: Jon TURNEY Date: Tue Mar 31 18:32:41 2015 +0100 Fix documentation of cygwin_internal()'s return type. * misc-funcs.xml (cygwin_internal): Correct return type. Signed-off-by: Jon TURNEY Diff: --- winsup/doc/ChangeLog | 4 winsup/doc/misc-funcs.xml | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index b90e6c1..30d9fdc 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,7 @@ +2015-03-31 Jon TURNEY + + * misc-funcs.xml (cygwin_internal): Correct return type. + 2015-03-31 Corinna Vinschen * new-features.xml (ov-new1.7.36): Add new section. Document GNU diff --git a/winsup/doc/misc-funcs.xml b/winsup/doc/misc-funcs.xml index 06776d9..b164341 100644 --- a/winsup/doc/misc-funcs.xml +++ b/winsup/doc/misc-funcs.xml @@ -34,7 +34,7 @@ much. cygwin_internal -extern "C" DWORD +extern "C" uintptr_t cygwin_internal cygwin_getinfo_types t ...
[newlib-cygwin] Rename struct ucontext to struct __mcontext
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9afde4dff449f9fac207de548fff34a44f5eb6ea commit 9afde4dff449f9fac207de548fff34a44f5eb6ea Author: Jon TURNEY Date: Mon Mar 30 18:05:51 2015 +0100 Rename struct ucontext to struct __mcontext * include/cygwin/signal.h : Rename struct ucontext to struct __mcontext. Fix layout differences from the Win32 API CONTEXT type. Remove unused member _internal. Rename member which corresponds to ContextFlags. Add cr2 member. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/include/cygwin/signal.h | 28 +++- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 58bfa23..3b86991 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-04-01 Jon TURNEY + + * include/cygwin/signal.h : Rename struct ucontext to struct + __mcontext. Fix layout differences from the Win32 API CONTEXT + type. Remove unused member _internal. Rename member which + corresponds to ContextFlags. Add cr2 member. + 2015-04-01 Corinna Vinschen * grp.cc (internal_getgroups): Handle negative domain index to avoid diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 58bbff0..04e65aa 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -18,6 +18,10 @@ extern "C" { #endif +/* + Define a struct __mcontext, which should be identical in layout to the Win32 + API type CONTEXT with the addition of oldmask and cr2 fields at the end. +*/ #ifdef __x86_64__ struct _uc_fpxreg { @@ -45,7 +49,7 @@ struct _fpstate __uint32_t padding[24]; }; -struct ucontext +struct __mcontext { __uint64_t p1home; __uint64_t p2home; @@ -53,7 +57,7 @@ struct ucontext __uint64_t p4home; __uint64_t p5home; __uint64_t p6home; - __uint32_t cr2; + __uint32_t ctxflags; __uint32_t mxcsr; __uint16_t cs; __uint16_t ds; @@ -86,14 +90,15 @@ struct ucontext __uint64_t r15; __uint64_t rip; struct _fpstate fpregs; + __uint64_t vregs[52]; __uint64_t vcx; __uint64_t dbc; __uint64_t btr; __uint64_t bfr; __uint64_t etr; __uint64_t efr; - __uint8_t _internal; __uint64_t oldmask; + __uint64_t cr2; }; #else /* !x86_64 */ @@ -117,9 +122,9 @@ struct _fpstate __uint32_t nxst; }; -struct ucontext +struct __mcontext { - __uint32_t cr2; + __uint32_t ctxflags; __uint32_t dr0; __uint32_t dr1; __uint32_t dr2; @@ -143,15 +148,20 @@ struct ucontext __uint32_t eflags; __uint32_t esp; __uint32_t ss; - __uint8_t _internal; + __uint32_t reserved[128]; __uint32_t oldmask; + __uint32_t cr2; }; #endif /* !x86_64 */ -/* Needed for GDB. It only compiles in the context copy code if this - macro s defined. */ -#define __COPY_CONTEXT_SIZE ((size_t) (uintptr_t) &((struct ucontext *) 0)->_internal) +/* Needed for GDB. It only compiles in the context copy code if this macro is + defined. This is not sizeof(CONTEXT) due to historical accidents. */ +#ifdef __x86_64__ +#define __COPY_CONTEXT_SIZE 816 +#else +#define __COPY_CONTEXT_SIZE 204 +#endif typedef union sigval {
[newlib-cygwin] Add cygwin_internal() operation to retrieve the EXCEPTION_RECORD from a siginfo_t *
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d89cc269039817729020bb6092efccd5bf520cd4 commit d89cc269039817729020bb6092efccd5bf520cd4 Author: Jon TURNEY Date: Mon Mar 30 20:56:03 2015 +0100 Add cygwin_internal() operation to retrieve the EXCEPTION_RECORD from a siginfo_t * * external.cc (cygwin_internal): Add operation to retrieve a copy of the EXCEPTION_RECORD from a siginfo_t *. * include/sys/cygwin.h (cygwin_getinfo_types): Ditto. * exception.h (cygwin_exception): Add exception_record accessor. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog| 7 +++ winsup/cygwin/exception.h | 1 + winsup/cygwin/external.cc | 14 ++ winsup/cygwin/include/sys/cygwin.h | 5 - 4 files changed, 26 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3b86991..b858a9c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2015-04-01 Jon TURNEY + * external.cc (cygwin_internal): Add operation to retrieve a copy + of the EXCEPTION_RECORD from a siginfo_t *. + * include/sys/cygwin.h (cygwin_getinfo_types): Ditto. + * exception.h (cygwin_exception): Add exception_record accessor. + +2015-04-01 Jon TURNEY + * include/cygwin/signal.h : Rename struct ucontext to struct __mcontext. Fix layout differences from the Win32 API CONTEXT type. Remove unused member _internal. Rename member which diff --git a/winsup/cygwin/exception.h b/winsup/cygwin/exception.h index 3686bb0..0478daf 100644 --- a/winsup/cygwin/exception.h +++ b/winsup/cygwin/exception.h @@ -175,4 +175,5 @@ public: framep (in_framep), ctx (in_ctx), e (in_e), h (NULL) {} void dumpstack (); PCONTEXT context () const {return ctx;} + EXCEPTION_RECORD *exception_record () const {return e;} }; diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 5fac4bb..e379df1 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -27,6 +27,7 @@ details. */ #include "environ.h" #include "cygserver_setpwd.h" #include "pwdgrp.h" +#include "exception.h" #include #include #include @@ -688,6 +689,19 @@ cygwin_internal (cygwin_getinfo_types t, ...) res = 0; break; + case CW_EXCEPTION_RECORD_FROM_SIGINFO_T: + { + siginfo_t *si = va_arg(arg, siginfo_t *); + EXCEPTION_RECORD *er = va_arg(arg, EXCEPTION_RECORD *); + if (si && si->si_cyg && er) + { + memcpy(er, ((cygwin_exception *)si->si_cyg)->exception_record(), +sizeof(EXCEPTION_RECORD)); + res = 0; + } + } + break; + default: set_errno (ENOSYS); } diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index edfcc56..2ec6086 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -1,3 +1,4 @@ + /* sys/cygwin.h Copyright 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, @@ -153,7 +154,8 @@ typedef enum CW_CYGNAME_FROM_WINNAME, CW_FIXED_ATEXIT, CW_GETNSS_PWD_SRC, -CW_GETNSS_GRP_SRC +CW_GETNSS_GRP_SRC, +CW_EXCEPTION_RECORD_FROM_SIGINFO_T, } cygwin_getinfo_types; #define CW_LOCK_PINFO CW_LOCK_PINFO @@ -214,6 +216,7 @@ typedef enum #define CW_FIXED_ATEXIT CW_FIXED_ATEXIT #define CW_GETNSS_PWD_SRC CW_GETNSS_PWD_SRC #define CW_GETNSS_GRP_SRC CW_GETNSS_GRP_SRC +#define CW_EXCEPTION_RECORD_FROM_SIGINFO_T CW_EXCEPTION_RECORD_FROM_SIGINFO_T /* Token type for CW_SET_EXTERNAL_TOKEN */ enum
[newlib-cygwin] Fix buffer size error handling in gethostname.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f7ddc49f40172ede26747c100b4132eb8680cf24 commit f7ddc49f40172ede26747c100b4132eb8680cf24 Author: Renato Silva Date: Tue Mar 31 21:18:46 2015 +0200 Fix buffer size error handling in gethostname. * net.cc (cygwin_gethostname): Fix buffer size error handling. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/net.cc| 5 - 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 68171f6..c4be231 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-03-31 Renato Silva + + * net.cc (cygwin_gethostname): Fix buffer size error handling. + 2015-03-31 Corinna Vinschen * uinfo.cc (pwdgrp::fetch_account_from_windows): Don't allow fully diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index f9b317c..eaf6eb8 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1076,7 +1076,10 @@ cygwin_gethostname (char *name, size_t len) if (!GetComputerNameExA (ComputerNameDnsFullyQualified, name, &local_len)) { - set_winsock_errno (); + if (GetLastError () == ERROR_MORE_DATA) + set_errno (ENAMETOOLONG); + else + set_winsock_errno (); __leave; } }
[newlib-cygwin] Drop local stdint.h and inttypes.h in favor of newlib files
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bbf1475e020dc9e2c5aca14b241fac109450b593 commit bbf1475e020dc9e2c5aca14b241fac109450b593 Author: Corinna Vinschen Date: Wed Apr 1 20:37:58 2015 +0200 Drop local stdint.h and inttypes.h in favor of newlib files * include/cygwin/types.h: Include sys/_stdint.h rather than stdint.h. * include/stdint.h: Drop in favor of newlib version. * include/inttypes.h: Ditto. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 + winsup/cygwin/include/cygwin/types.h | 2 +- winsup/cygwin/include/inttypes.h | 267 - winsup/cygwin/include/stdint.h | 276 --- 4 files changed, 7 insertions(+), 544 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8e0f66f..72dfa66 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-04-01 Corinna Vinschen + + * include/cygwin/types.h: Include sys/_stdint.h rather than stdint.h. + * include/stdint.h: Drop in favor of newlib version. + * include/inttypes.h: Ditto. + 2015-04-01 Jon TURNEY * include/sys/ucontext.h : New header. diff --git a/winsup/cygwin/include/cygwin/types.h b/winsup/cygwin/include/cygwin/types.h index b2974c4..85ee7c7 100644 --- a/winsup/cygwin/include/cygwin/types.h +++ b/winsup/cygwin/include/cygwin/types.h @@ -17,7 +17,7 @@ extern "C" { #endif -#include +#include #include #include #include diff --git a/winsup/cygwin/include/inttypes.h b/winsup/cygwin/include/inttypes.h deleted file mode 100644 index 5a64681..000 --- a/winsup/cygwin/include/inttypes.h +++ /dev/null @@ -1,267 +0,0 @@ -/* inttypes.h - fixed size integer types - - Copyright 2003, 2005, 2009, 2010, 2012, 2015 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _INTTYPES_H -#define _INTTYPES_H - -#include -#define __need_wchar_t -#include -#include - -#if __WORDSIZE == 64 -#define __PRI64 "l" -#define __PRIFAST "l" -#define __PRIPTR "l" -#else -#define __PRI64 "ll" -#define __PRIFAST -#define __PRIPTR -#endif - -/* fprintf() macros for signed integers */ - -#define PRId8 "d" -#define PRId16 "d" -#define PRId32 "d" -#define PRId64 __PRI64 "d" - -#define PRIdLEAST8 "d" -#define PRIdLEAST16 "d" -#define PRIdLEAST32 "d" -#define PRIdLEAST64 __PRI64 "d" - -#define PRIdFAST8 "d" -#define PRIdFAST16 __PRIFAST "d" -#define PRIdFAST32 __PRIFAST "d" -#define PRIdFAST64 __PRI64 "d" - -#define PRIdMAX __PRI64 "d" -#define PRIdPTR __PRIPTR "d" - -#define PRIi8 "i" -#define PRIi16 "i" -#define PRIi32 "i" -#define PRIi64 __PRI64 "i" - -#define PRIiLEAST8 "i" -#define PRIiLEAST16 "i" -#define PRIiLEAST32 "i" -#define PRIiLEAST64 __PRI64 "i" - -#define PRIiFAST8 "i" -#define PRIiFAST16 __PRIFAST "i" -#define PRIiFAST32 __PRIFAST "i" -#define PRIiFAST64 __PRI64 "i" - -#define PRIiMAX __PRI64 "i" -#define PRIiPTR __PRIPTR "i" - -/* fprintf() macros for unsigned integers */ - -#define PRIo8 "o" -#define PRIo16 "o" -#define PRIo32 "o" -#define PRIo64 __PRI64 "o" - -#define PRIoLEAST8 "o" -#define PRIoLEAST16 "o" -#define PRIoLEAST32 "o" -#define PRIoLEAST64 __PRI64 "o" - -#define PRIoFAST8 "o" -#define PRIoFAST16 __PRIFAST "o" -#define PRIoFAST32 __PRIFAST "o" -#define PRIoFAST64 __PRI64 "o" - -#define PRIoMAX __PRI64 "o" -#define PRIoPTR __PRIPTR "o" - -#define PRIu8 "u" -#define PRIu16 "u" -#define PRIu32 "u" -#define PRIu64 __PRI64 "u" - -#define PRIuLEAST8 "u" -#define PRIuLEAST16 "u" -#define PRIuLEAST32 "u" -#define PRIuLEAST64 __PRI64 "u" - -#define PRIuFAST8 "u" -#define PRIuFAST16 __PRIFAST "u" -#define PRIuFAST32 __PRIFAST "u" -#define PRIuFAST64 __PRI64 "u" - -#define PRIuMAX __PRI64 "u" -#define PRIuPTR __PRIPTR "u" - -#define PRIx8 "x" -#define PRIx16 "x" -#define PRIx32 "x" -#define PRIx64 __PRI64 "x" - -#define PRIxLEAST8 "x" -#define PRIxLEAST16 "x" -#define PRIxLEAST32 "x" -#define PRIxLEAST64 __PRI64 "x" - -#define PRIxFAST8 "x" -#define PRIxFAST16 __PRIFAST "x" -#define PRIxFAST32 __PRIFAST "x" -#define PRIxFAST6
[newlib-cygwin] Cygwin hangs up if several keys are typed during outputting a lot of texts.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=252a07b0ad3353abcd0fcd9b1b65ff977acd679e commit 252a07b0ad3353abcd0fcd9b1b65ff977acd679e Author: Takashi Yano Date: Fri Apr 3 13:07:35 2015 +0900 Cygwin hangs up if several keys are typed during outputting a lot of texts. * fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of "readlen" not to use "bytes_in_pipe" value directly. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/fhandler_tty.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bcc7df8..a36b5c2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-03 Takashi Yano + + * fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of + "readlen" not to use "bytes_in_pipe" value directly. + 2015-04-02 Jon TURNEY * include/cygwin/signal.h (struct __mcontext): 16-byte align. diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 89cc9e5..daa24eb 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -742,7 +742,7 @@ fhandler_pty_slave::read (void *ptr, size_t& len) return; } - readlen = MIN (bytes_in_pipe, MIN (len, sizeof (buf))); + readlen = bytes_in_pipe ? MIN (len, sizeof (buf)) : 0; #if 0 /* Why on earth is the read length reduced to vmin, even if more bytes
[newlib-cygwin] Provide ucontext to signal handlers
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9e8932d6dac0d0acdedaf363adbf2265111ed27c commit 9e8932d6dac0d0acdedaf363adbf2265111ed27c Author: Jon TURNEY Date: Mon Mar 30 20:31:13 2015 +0100 Provide ucontext to signal handlers Add ucontext.h header, defining ucontext_t and mcontext_t types. Provide sigaction sighandlers with a ucontext_t parameter, containing stack and context information. * include/sys/ucontext.h : New header. * include/ucontext.h : Ditto. * exceptions.cc (call_signal_handler): Provide ucontext_t parameter to signal handler function. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/exceptions.cc | 23 +-- winsup/cygwin/include/sys/ucontext.h | 26 ++ winsup/cygwin/include/ucontext.h | 16 4 files changed, 70 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b858a9c..8e0f66f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2015-04-01 Jon TURNEY + * include/sys/ucontext.h : New header. + * include/ucontext.h : Ditto. + * exceptions.cc (call_signal_handler): Provide ucontext_t + parameter to signal handler function. + +2015-04-01 Jon TURNEY + * external.cc (cygwin_internal): Add operation to retrieve a copy of the EXCEPTION_RECORD from a siginfo_t *. * include/sys/cygwin.h (cygwin_getinfo_types): Ditto. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index af53457..0d1f36d 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -16,6 +16,7 @@ details. */ #include #include #include +#include #include "cygtls.h" #include "pinfo.h" @@ -1489,15 +1490,33 @@ _cygtls::call_signal_handler () siginfo_t thissi = infodata; void (*thisfunc) (int, siginfo_t *, void *) = func; + ucontext_t thiscontext; + thiscontext.uc_link = 0; + thiscontext.uc_flags = 0; + if (thissi.si_cyg) +memcpy (&thiscontext.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT)); + else +RtlCaptureContext ((CONTEXT *)&thiscontext.uc_mcontext); +/* FIXME: Really this should be the context which the signal interrupted? */ + + /* FIXME: If/when sigaltstack is implemented, this will need to do + something more complicated */ + thiscontext.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; + thiscontext.uc_stack.ss_flags = 0; + if (!NtCurrentTeb ()->DeallocationStack) +thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; + else +thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; + sigset_t this_oldmask = set_process_mask_delta (); + thiscontext.uc_sigmask = this_oldmask; int this_errno = saved_errno; reset_signal_arrived (); incyg = false; sig = 0; /* Flag that we can accept another signal */ unlock (); /* unlock signal stack */ - /* no ucontext_t information provided yet, so third arg is NULL */ - thisfunc (thissig, &thissi, NULL); + thisfunc (thissig, &thissi, &thiscontext); incyg = true; set_signal_mask (_my_tls.sigmask, this_oldmask); diff --git a/winsup/cygwin/include/sys/ucontext.h b/winsup/cygwin/include/sys/ucontext.h new file mode 100644 index 000..9362d90 --- /dev/null +++ b/winsup/cygwin/include/sys/ucontext.h @@ -0,0 +1,26 @@ +/* ucontext.h + + Copyright 2015 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#ifndef _SYS_UCONTEXT_H_ +#define _SYS_UCONTEXT_H_ + +#include + +typedef struct __mcontext mcontext_t; + +typedef struct __ucontext { + struct __ucontext *uc_link; + sigset_tuc_sigmask; + stack_t uc_stack; + mcontext_t uc_mcontext; + unsigned long int uc_flags; +} ucontext_t; + +#endif /* !_SYS_UCONTEXT_H_ */ diff --git a/winsup/cygwin/include/ucontext.h b/winsup/cygwin/include/ucontext.h new file mode 100644 index 000..4240597 --- /dev/null +++ b/winsup/cygwin/include/ucontext.h @@ -0,0 +1,16 @@ +/* ucontext.h + + Copyright 2015 Red Hat, Inc. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +#ifndef _UCONTEXT_H +#define _UCONTEXT_H + +#include + +#endif /* _UCONTEXT_H */
[newlib-cygwin] Compile exceptions.cc with -fno-omit-frame-pointer on x86
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4f28e8a0e50003b8406ae3d80b7a542748bfb0c5 commit 4f28e8a0e50003b8406ae3d80b7a542748bfb0c5 Author: Jon TURNEY Date: Sat Apr 4 23:31:03 2015 +0100 Compile exceptions.cc with -fno-omit-frame-pointer on x86 Selectively using -fomit-frame-pointer when -O is used doesn't make sense anymore, apparently since gcc 4.6, -O implies -fomit-frame-pointer. exceptions.cc must be compiled with -fno-omit-frame-pointer on x86, as it uses RtlCaptureContext, which requires a frame pointer. * Makefile.in : Remove setting -fomit-frame-pointer for compiling various files, it is already the default. Set -fno-omit-frame-pointer for exceptions.cc on x86. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 6 + winsup/cygwin/Makefile.in | 59 ++- 2 files changed, 13 insertions(+), 52 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a36b5c2..e4e94da 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-04-04 Jon TURNEY + + * Makefile.in : Remove setting -fomit-frame-pointer for compiling + various files, it is already the default. Set + -fno-omit-frame-pointer for exceptions.cc on x86. + 2015-04-03 Takashi Yano * fhandler_tty.cc (fhandler_pty_slave::read): Change calculation of diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index 9b82f0a..d827754 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -449,59 +449,14 @@ INSTOBJS:=automode.o binmode.o textmode.o textreadmode.o TARGET_LIBS:=$(LIB_NAME) $(CYGWIN_START) $(GMON_START) $(LIBGMON_A) $(SUBLIBS) $(INSTOBJS) $(EXTRALIBS) ifneq "${filter -O%,$(CFLAGS)}" "" -cygheap_CFLAGS:=-fomit-frame-pointer -cygthread_CFLAGS:=-fomit-frame-pointer -cygtls_CFLAGS:=-fomit-frame-pointer -cygwait_CFLAGS=-fomit-frame-pointer -delqueue_CFLAGS:=-fomit-frame-pointer -devices_CFLAGS:=-fomit-frame-pointer -dir_CFLAGS:=-fomit-frame-pointer -dlfcn_CFLAGS:=-fomit-frame-pointer -dll_init_CFLAGS:=-fomit-frame-pointer -dtable_CFLAGS:=-fomit-frame-pointer -fcheck-new -fcntl_CFLAGS:=-fomit-frame-pointer -fenv_CFLAGS:=-fomit-frame-pointer -fhandler_CFLAGS:=-fomit-frame-pointer -fhandler_clipboard_CFLAGS:=-fomit-frame-pointer -fhandler_console_CFLAGS:=-fomit-frame-pointer -fhandler_disk_file_CFLAGS:=-fomit-frame-pointer -fhandler_dsp_CFLAGS:=-fomit-frame-pointer -fhandler_floppy_CFLAGS:=-fomit-frame-pointer -fhandler_netdrive_CFLAGS:=-fomit-frame-pointer -fhandler_proc_CFLAGS:=-fomit-frame-pointer -fhandler_process_CFLAGS:=-fomit-frame-pointer -fhandler_random_CFLAGS:=-fomit-frame-pointer -fhandler_raw_CFLAGS:=-fomit-frame-pointer -fhandler_registry_CFLAGS:=-fomit-frame-pointer -fhandler_serial_CFLAGS:=-fomit-frame-pointer -fhandler_socket_CFLAGS:=-fomit-frame-pointer -fhandler_syslog_CFLAGS:=-fomit-frame-pointer -fhandler_tape_CFLAGS:=-fomit-frame-pointer -fhandler_termios_CFLAGS:=-fomit-frame-pointer -fhandler_tty_CFLAGS:=-fomit-frame-pointer -fhandler_virtual_CFLAGS:=-fomit-frame-pointer -fhandler_windows_CFLAGS:=-fomit-frame-pointer -fhandler_zero_CFLAGS:=-fomit-frame-pointer -flock_CFLAGS:=-fomit-frame-pointer -grp_CFLAGS:=-fomit-frame-pointer -libstdcxx_wrapper_CFLAGS:=-fomit-frame-pointer +dtable_CFLAGS:=-fcheck-new localtime_CFLAGS:=-fwrapv -malloc_CFLAGS:=-fomit-frame-pointer -O3 -malloc_wrapper_CFLAGS:=-fomit-frame-pointer -miscfuncs_CFLAGS:=-fomit-frame-pointer -net_CFLAGS:=-fomit-frame-pointer -passwd_CFLAGS:=-fomit-frame-pointer -path_CFLAGS=-fomit-frame-pointer -regcomp_CFLAGS=-fomit-frame-pointer -regerror_CFLAGS=-fomit-frame-pointer -regexec_CFLAGS=-fomit-frame-pointer -regfree_CFLAGS=-fomit-frame-pointer -shared_CFLAGS:=-fomit-frame-pointer -sync_CFLAGS:=-fomit-frame-pointer -O3 -smallprint_CFLAGS:=-fomit-frame-pointer -syscalls_CFLAGS:=-fomit-frame-pointer -sysconf_CFLAGS:=-fomit-frame-pointer -uinfo_CFLAGS:=-fomit-frame-pointer +malloc_CFLAGS:=-O3 +sync_CFLAGS:=-O3 +ifeq ($(target_cpu),i686) +# on x86, exceptions.cc must be compiled with a frame-pointer as it uses RtlCaptureContext() +exceptions_CFLAGS:=-fno-omit-frame-pointer +endif endif fhandler_proc_CFLAGS+=-DUSERNAME="\"$(USER)\"" -DHOSTNAME="\"$(HOSTNAME)\""
[newlib-cygwin] Remove __acl16 from official header
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=651bb62ae24cf5081f244085a652261abce92696 commit 651bb62ae24cf5081f244085a652261abce92696 Author: Corinna Vinschen Date: Wed Apr 8 10:01:59 2015 +0200 Remove __acl16 from official header * include/cyggwin/acl.h (struct __acl16): Move from here... * sec_acl.cc: ...to here. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 5 + winsup/cygwin/include/cygwin/acl.h | 10 -- winsup/cygwin/sec_acl.cc | 6 ++ 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8065e73..659f568 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-08 Corinna Vinschen + + * include/cyggwin/acl.h (struct __acl16): Move from here... + * sec_acl.cc: ...to here. + 2015-04-07 Corinna Vinschen * tty.h (class tty): Remove unused 32/64 bit interoperability diff --git a/winsup/cygwin/include/cygwin/acl.h b/winsup/cygwin/include/cygwin/acl.h index 8fa5a65..34f1c0c 100644 --- a/winsup/cygwin/include/cygwin/acl.h +++ b/winsup/cygwin/include/cygwin/acl.h @@ -58,16 +58,6 @@ extern "C" { #define MASKCLASS_OBJ #define OTHER OTHER_OBJ -#ifdef __INSIDE_CYGWIN__ -#ifndef __x86_64__ -typedef struct __acl16 { -int a_type; -__uid16_ta_id; -mode_t a_perm; -} __aclent16_t; -#endif -#endif - typedef struct acl { int a_type;/* entry type */ uid_ta_id; /* UID | GID */ diff --git a/winsup/cygwin/sec_acl.cc b/winsup/cygwin/sec_acl.cc index e5019cb..5a2048c 100644 --- a/winsup/cygwin/sec_acl.cc +++ b/winsup/cygwin/sec_acl.cc @@ -1102,6 +1102,12 @@ EXPORT_ALIAS (aclfrompbits32, aclfrompbits) EXPORT_ALIAS (acltotext32, acltotext) EXPORT_ALIAS (aclfromtext32, aclfromtext) #else +typedef struct __acl16 { +int a_type; +__uid16_ta_id; +mode_t a_perm; +} __aclent16_t; + /* __aclent16_t and aclent_t have same size and same member offsets */ static aclent_t * acl16to32 (__aclent16_t *aclbufp, int nentries)
[newlib-cygwin] Raise # of ptys to 128.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=19c6889c371e1766856040d9e981c944cee4f179 commit 19c6889c371e1766856040d9e981c944cee4f179 Author: Corinna Vinschen Date: Tue Apr 7 12:11:52 2015 +0200 Raise # of ptys to 128. * tty.h (NTTYS): Raise to 128. * devices.in: Change pty, ptym, and cons expressions accordingly. * devices.cc: Regenerate. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog |6 + winsup/cygwin/devices.cc | 9818 -- winsup/cygwin/devices.in |6 +- winsup/cygwin/release/1.7.36 |2 + winsup/cygwin/tty.h |2 +- 5 files changed, 6502 insertions(+), 3332 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e4e94da..f329a76 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-04-07 Corinna Vinschen + + * tty.h (NTTYS): Raise to 128. + * devices.in: Change pty, ptym, and cons expressions accordingly. + * devices.cc: Regenerate. + 2015-04-04 Jon TURNEY * Makefile.in : Remove setting -fomit-frame-pointer for compiling diff --git a/winsup/cygwin/devices.cc b/winsup/cygwin/devices.cc index 8aba6d8..fa022ea 100644 --- a/winsup/cygwin/devices.cc +++ b/winsup/cygwin/devices.cc @@ -225,6 +225,70 @@ const _RDATA device dev_storage[] = {"/dev/cons61", BRACK(FHDEV(DEV_CONS_MAJOR, 61)), "/dev/cons61", exists_console, S_IFCHR, true}, {"/dev/cons62", BRACK(FHDEV(DEV_CONS_MAJOR, 62)), "/dev/cons62", exists_console, S_IFCHR, true}, {"/dev/cons63", BRACK(FHDEV(DEV_CONS_MAJOR, 63)), "/dev/cons63", exists_console, S_IFCHR, true}, + {"/dev/cons64", BRACK(FHDEV(DEV_CONS_MAJOR, 64)), "/dev/cons64", exists_console, S_IFCHR, true}, + {"/dev/cons65", BRACK(FHDEV(DEV_CONS_MAJOR, 65)), "/dev/cons65", exists_console, S_IFCHR, true}, + {"/dev/cons66", BRACK(FHDEV(DEV_CONS_MAJOR, 66)), "/dev/cons66", exists_console, S_IFCHR, true}, + {"/dev/cons67", BRACK(FHDEV(DEV_CONS_MAJOR, 67)), "/dev/cons67", exists_console, S_IFCHR, true}, + {"/dev/cons68", BRACK(FHDEV(DEV_CONS_MAJOR, 68)), "/dev/cons68", exists_console, S_IFCHR, true}, + {"/dev/cons69", BRACK(FHDEV(DEV_CONS_MAJOR, 69)), "/dev/cons69", exists_console, S_IFCHR, true}, + {"/dev/cons70", BRACK(FHDEV(DEV_CONS_MAJOR, 70)), "/dev/cons70", exists_console, S_IFCHR, true}, + {"/dev/cons71", BRACK(FHDEV(DEV_CONS_MAJOR, 71)), "/dev/cons71", exists_console, S_IFCHR, true}, + {"/dev/cons72", BRACK(FHDEV(DEV_CONS_MAJOR, 72)), "/dev/cons72", exists_console, S_IFCHR, true}, + {"/dev/cons73", BRACK(FHDEV(DEV_CONS_MAJOR, 73)), "/dev/cons73", exists_console, S_IFCHR, true}, + {"/dev/cons74", BRACK(FHDEV(DEV_CONS_MAJOR, 74)), "/dev/cons74", exists_console, S_IFCHR, true}, + {"/dev/cons75", BRACK(FHDEV(DEV_CONS_MAJOR, 75)), "/dev/cons75", exists_console, S_IFCHR, true}, + {"/dev/cons76", BRACK(FHDEV(DEV_CONS_MAJOR, 76)), "/dev/cons76", exists_console, S_IFCHR, true}, + {"/dev/cons77", BRACK(FHDEV(DEV_CONS_MAJOR, 77)), "/dev/cons77", exists_console, S_IFCHR, true}, + {"/dev/cons78", BRACK(FHDEV(DEV_CONS_MAJOR, 78)), "/dev/cons78", exists_console, S_IFCHR, true}, + {"/dev/cons79", BRACK(FHDEV(DEV_CONS_MAJOR, 79)), "/dev/cons79", exists_console, S_IFCHR, true}, + {"/dev/cons80", BRACK(FHDEV(DEV_CONS_MAJOR, 80)), "/dev/cons80", exists_console, S_IFCHR, true}, + {"/dev/cons81", BRACK(FHDEV(DEV_CONS_MAJOR, 81)), "/dev/cons81", exists_console, S_IFCHR, true}, + {"/dev/cons82", BRACK(FHDEV(DEV_CONS_MAJOR, 82)), "/dev/cons82", exists_console, S_IFCHR, true}, + {"/dev/cons83", BRACK(FHDEV(DEV_CONS_MAJOR, 83)), "/dev/cons83", exists_console, S_IFCHR, true}, + {"/dev/cons84", BRACK(FHDEV(DEV_CONS_MAJOR, 84)), "/dev/cons84", exists_console, S_IFCHR, true}, + {"/dev/cons85", BRACK(FHDEV(DEV_CONS_MAJOR, 85)), "/dev/cons85", exists_console, S_IFCHR, true}, + {"/dev/cons86", BRACK(FHDEV(DEV_CONS_MAJOR, 86)), "/dev/cons86", exists_console, S_IFCHR, true}, + {"/dev/cons87", BRACK(FHDEV(DEV_CONS_MAJOR, 87)), "/dev/cons87", exists_console, S_IFCHR, true}, + {"/dev/cons88", BRACK(FHDEV(DEV_CONS_MAJOR, 88)), "/dev/cons88", exists_console, S_IFCHR, true}, + {"/dev/cons89", BRACK(FHDEV(DEV_CONS_MAJOR, 89)), "/dev/cons89", exists_console, S_IFCHR, true}, + {"/dev/cons90", BRACK(FHDEV(DEV_CONS_MAJOR, 90)), "/dev/c
[newlib-cygwin] Add FAQ entry on how Cygwin counters install and update MITM attacks
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f33e34f333ca67cb932c3829acf6b6d427b78e99 commit f33e34f333ca67cb932c3829acf6b6d427b78e99 Author: David A. Wheeler Date: Thu Apr 2 14:04:55 2015 -0400 Add FAQ entry on how Cygwin counters install and update MITM attacks * faq-setup.xml: Document how Cygwin secures installation and update against man-in-the-middle (MITM) attacks. Note that setup embeds a public key to check the signature of setup.ini, and that setup.ini includes SHA-512 cryptographic hashes. Signed-off-by: David A. Wheeler Diff: --- winsup/doc/ChangeLog | 7 +++ winsup/doc/faq-setup.xml | 121 ++- 2 files changed, 127 insertions(+), 1 deletion(-) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 30d9fdc..4163900 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,10 @@ +2015-04-02 David A. Wheeler + + * faq-setup.xml: Document how Cygwin secures installation and + update against man-in-the-middle (MITM) attacks. Note that + setup embeds a public key to check the signature of setup.ini, + and that setup.ini includes SHA-512 cryptographic hashes. + 2015-03-31 Jon TURNEY * misc-funcs.xml (cygwin_internal): Correct return type. diff --git a/winsup/doc/faq-setup.xml b/winsup/doc/faq-setup.xml index 614d4a9..2a4c507 100644 --- a/winsup/doc/faq-setup.xml +++ b/winsup/doc/faq-setup.xml @@ -156,6 +156,120 @@ and that installing the older version will not help improve Cygwin. + +How does Cygwin secure the installation and update process? + + + +Here is how Cygwin secures the installation and update process to counter +https://en.wikipedia.org/wiki/Man-in-the-middle_attack";>man-in-the-middle (MITM) attacks: + + + +The Cygwin website provides the setup program +(setup-x86.exe or setup-x86_64.exe) +using HTTPS (SSL/TLS). +This authenticates that the setup program +came from the Cygwin website +(users simply use their web browsers to download the setup program). +You can use tools like Qualsys' SSL Server Test, +https://www.ssllabs.com/ssltest/"/>, +to check the HTTPS configuration of Cygwin. +The cygwin.com site supports HTTP Strict Transport Security (HSTS), +which forces the browser to keep using HTTPS once the browser has seen +it before (this counters many downgrade attacks). + +The setup program has the +Cygwin public key embedded in it. +The Cygwin public key is protected from attacker subversion +during transmission by the previous step, and this public +key is then used to protect all later steps. +You can confirm that the key is in setup by looking at the setup project +(http://sourceware.org/cygwin-apps/setup.html"/>) +source code file cyg-pubkey.h +(the key is automatically generated from file cygwin.pub). + +The setup program downloads +the package list setup.ini from a mirror +and checks its digital signature. +The package list is in the file +setup.bz2 (compressed) or +setup.ini (uncompressed) on the selected mirror. +The package list includes for every official Cygwin package +the package name, cryptographic hash, and length (in bytes). +The setup program also gets the relevant .sig +(signature) file for that package list, and checks that the package list +is properly signed with the Cygwin public key embedded in the setup program. +A mirror could corrupt the package list and/or signature, but this +would be detected by setup program's signature detection +(unless you use the -X option to disable signature checking). +The setup program also checks the package list +timestamp/version and reports to the user if the file +goes backwards in time; that process detects downgrade attacks +(e.g., where an attacker subverts a mirror to send a signed package list +that is older than the currently-downloaded version). + +The packages to be installed +(which may be updates) are downloaded and both their +lengths and cryptographic hashes +(from the signed setup.{bz2,ini} file) are checked. +Non-matching packages are rejected, countering any attacker's +attempt to subvert the files on a mirror. +Cygwin currently uses the cryptographic hash function SHA-512 +for the setup.ini files. + + + + +Cygwin uses the cryptographic hash algorithm SHA-512 as of 2015-03-23. +The earlier 2015-02-06 update of the setup program added support for SHA-512 +(Cygwin previously used MD5). +There are no known practical exploits of SHA-512 (SHA-512 is part of the +widely-used SHA-2 suite of cryptographic hashes). + + + + + +What else can I do to ensure that my installation and updates are secure? + + + +To best secure your installation and update process, download +the setup program setup-x86.exe (32-bit) or +setup-x86_64.exe (64-bit), and then +check its signature (using a signature-checking tool you trust) +using the Cygwin public key +(https://cygwin.com/key/pubring.asc"/>). +This was noted on the front page for installin
[newlib-cygwin] Try to make sure struct _mcontext is 16-byte aligned
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=383ff5fc47123ab2914cffc9517df1071eb1dc6a commit 383ff5fc47123ab2914cffc9517df1071eb1dc6a Author: Jon TURNEY Date: Thu Apr 2 18:05:32 2015 +0100 Try to make sure struct _mcontext is 16-byte aligned On x86_64, RtlCaptureContext() uses fxsave to save FPU/MMX/SSE state. fxsave requires that the destination address is 16-byte aligned, or it will fault. CONTEXT is already annotated __attribute__ ((aligned (16))), do the same with struct _mcontext. Rearrange ucontext_t so that it's struct _mcontext element is also correctly aligned. * include/cygwin/signal.h (struct __mcontext): 16-byte align. * include/sys/ucontext.h (ucontext_t): Ditto. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/include/cygwin/signal.h | 2 +- winsup/cygwin/include/sys/ucontext.h | 4 ++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 72dfa66..bcc7df8 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-02 Jon TURNEY + + * include/cygwin/signal.h (struct __mcontext): 16-byte align. + * include/sys/ucontext.h (ucontext_t): Ditto. + 2015-04-01 Corinna Vinschen * include/cygwin/types.h: Include sys/_stdint.h rather than stdint.h. diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 04e65aa..ef29baf 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -49,7 +49,7 @@ struct _fpstate __uint32_t padding[24]; }; -struct __mcontext +struct __attribute__ ((aligned (16))) __mcontext { __uint64_t p1home; __uint64_t p2home; diff --git a/winsup/cygwin/include/sys/ucontext.h b/winsup/cygwin/include/sys/ucontext.h index 9362d90..65485fb 100644 --- a/winsup/cygwin/include/sys/ucontext.h +++ b/winsup/cygwin/include/sys/ucontext.h @@ -15,11 +15,11 @@ details. */ typedef struct __mcontext mcontext_t; -typedef struct __ucontext { +typedef __attribute__ ((aligned (16))) struct __ucontext { + mcontext_t uc_mcontext; struct __ucontext *uc_link; sigset_tuc_sigmask; stack_t uc_stack; - mcontext_t uc_mcontext; unsigned long int uc_flags; } ucontext_t;
[newlib-cygwin] Call open_null to open fake handle
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=19dc6ee82cafa7acbbc4aee8db7a6b511025a805 commit 19dc6ee82cafa7acbbc4aee8db7a6b511025a805 Author: Corinna Vinschen Date: Thu Apr 9 21:49:36 2015 +0200 Call open_null to open fake handle * fhandler_dsp.cc (fhandler_dev_dsp::open): Call open_null. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/fhandler_dsp.cc | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index aa60192..50fc01e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-04-09 Corinna Vinschen + + * fhandler_dsp.cc (fhandler_dev_dsp::open): Call open_null. + 2015-04-08 Corinna Vinschen * pwdgrp.h (sidfromuid): New inline function. diff --git a/winsup/cygwin/fhandler_dsp.cc b/winsup/cygwin/fhandler_dsp.cc index b5eaba7..9fa2c6e 100644 --- a/winsup/cygwin/fhandler_dsp.cc +++ b/winsup/cygwin/fhandler_dsp.cc @@ -1037,7 +1037,7 @@ fhandler_dev_dsp::fixup_after_exec () int -fhandler_dev_dsp::open (int flags, mode_t mode) +fhandler_dev_dsp::open (int flags, mode_t) { int ret = 0, err = 0; UINT num_in = 0, num_out = 0; @@ -1068,7 +1068,7 @@ fhandler_dev_dsp::open (int flags, mode_t mode) if (err) set_errno (err); else -ret = fhandler_base::open (flags, mode); +ret = open_null (flags); debug_printf ("ACCMODE=%y audio_in=%d audio_out=%d, err=%d, ret=%d", flags & O_ACCMODE, num_in, num_out, err, ret);
[newlib-cygwin] Only construct ucontext for SA_SIGINFO signal handlers
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9043956ce8594855ae5cfe66e8334e51c6969f59 commit 9043956ce8594855ae5cfe66e8334e51c6969f59 Author: Jon TURNEY Date: Thu Apr 2 18:15:07 2015 +0100 Only construct ucontext for SA_SIGINFO signal handlers * exceptions.cc (call_signal_handler): Only bother to construct the ucontext for signal handlers with SA_SIGINFO set. Set mcontext.oldmask. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 6 + winsup/cygwin/exceptions.cc | 54 +++-- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6d772c2..a3a0026 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-04-02 Jon TURNEY + + * exceptions.cc (call_signal_handler): Only bother to construct + the ucontext for signal handlers with SA_SIGINFO set. Set + mcontext.oldmask. + 2015-04-04 Jon TURNEY * exceptions.cc (call_signal_handler): Zero initialize context and set diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index fe543ae..0c9ee14 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1485,42 +1485,52 @@ _cygtls::call_signal_handler () debug_only_printf ("dealing with signal %d", sig); this_sa_flags = sa_flags; + sigset_t this_oldmask = set_process_mask_delta (); + /* Save information locally on stack to pass to handler. */ int thissig = sig; siginfo_t thissi = infodata; void (*thisfunc) (int, siginfo_t *, void *) = func; - ucontext_t thiscontext; - thiscontext.uc_link = 0; - thiscontext.uc_flags = 0; - if (thissi.si_cyg) -memcpy (&thiscontext.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT)); - else + ucontext_t context; + ucontext_t *thiscontext = NULL; + + /* Only make a context for SA_SIGINFO handlers */ + if (this_sa_flags & SA_SIGINFO) { - /* FIXME: Really this should be the context which the signal interrupted? */ - memset(&thiscontext.uc_mcontext, 0, sizeof(struct __mcontext)); - thiscontext.uc_mcontext.ctxflags = CONTEXT_FULL; - RtlCaptureContext ((CONTEXT *)&thiscontext.uc_mcontext); - } + context.uc_link = 0; + context.uc_flags = 0; + if (thissi.si_cyg) + memcpy (&context.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT)); + else + { + /* FIXME: Really this should be the context which the signal interrupted? */ + memset(&context.uc_mcontext, 0, sizeof(struct __mcontext)); + context.uc_mcontext.ctxflags = CONTEXT_FULL; + RtlCaptureContext ((CONTEXT *)&context.uc_mcontext); + } - /* FIXME: If/when sigaltstack is implemented, this will need to do - something more complicated */ - thiscontext.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; - thiscontext.uc_stack.ss_flags = 0; - if (!NtCurrentTeb ()->DeallocationStack) -thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; - else -thiscontext.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; + /* FIXME: If/when sigaltstack is implemented, this will need to do +something more complicated */ + context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; + context.uc_stack.ss_flags = 0; + if (!NtCurrentTeb ()->DeallocationStack) + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->Tib.StackLimit - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; + else + context.uc_stack.ss_size = (uintptr_t)NtCurrentTeb ()->DeallocationStack - (uintptr_t)NtCurrentTeb ()->Tib.StackBase; + + context.uc_sigmask = context.uc_mcontext.oldmask = this_oldmask; + + thiscontext = &context; + } - sigset_t this_oldmask = set_process_mask_delta (); - thiscontext.uc_sigmask = this_oldmask; int this_errno = saved_errno; reset_signal_arrived (); incyg = false; sig = 0; /* Flag that we can accept another signal */ unlock (); /* unlock signal stack */ - thisfunc (thissig, &thissi, &thiscontext); + thisfunc (thissig, &thissi, thiscontext); incyg = true; set_signal_mask (_my_tls.sigmask, this_oldmask);
[newlib-cygwin] Initialize context before RtlContextCapture
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=65c071bc4d4622af861b63066cd8cdb9d0ece467 commit 65c071bc4d4622af861b63066cd8cdb9d0ece467 Author: Jon TURNEY Date: Sat Apr 4 16:19:31 2015 +0100 Initialize context before RtlContextCapture * exceptions.cc (call_signal_handler): Zero initialize context and set context flags, as RlCaptureContext doesn't. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/exceptions.cc | 8 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 50fc01e..6d772c2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-04 Jon TURNEY + + * exceptions.cc (call_signal_handler): Zero initialize context and set + context flags, as RlCaptureContext doesn't. + 2015-04-09 Corinna Vinschen * fhandler_dsp.cc (fhandler_dev_dsp::open): Call open_null. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 0d1f36d..fe543ae 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1496,8 +1496,12 @@ _cygtls::call_signal_handler () if (thissi.si_cyg) memcpy (&thiscontext.uc_mcontext, ((cygwin_exception *)thissi.si_cyg)->context(), sizeof(CONTEXT)); else -RtlCaptureContext ((CONTEXT *)&thiscontext.uc_mcontext); -/* FIXME: Really this should be the context which the signal interrupted? */ + { + /* FIXME: Really this should be the context which the signal interrupted? */ + memset(&thiscontext.uc_mcontext, 0, sizeof(struct __mcontext)); + thiscontext.uc_mcontext.ctxflags = CONTEXT_FULL; + RtlCaptureContext ((CONTEXT *)&thiscontext.uc_mcontext); + } /* FIXME: If/when sigaltstack is implemented, this will need to do something more complicated */
[newlib-cygwin] Don't rely on size argument in shmget call
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=023be4aedbd5bfb0a56164a2803c9c24a0d546f5 commit 023be4aedbd5bfb0a56164a2803c9c24a0d546f5 Author: Corinna Vinschen Date: Sun Apr 12 14:05:12 2015 +0200 Don't rely on size argument in shmget call * shm.cc (shmget): Fetch segment size from server rather than using size argument to accommodate existing segments. Add comment to explain why. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 ++ winsup/cygwin/release/2.0.0 | 3 +++ winsup/cygwin/shm.cc| 9 - 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9a48131..a75810f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-04-12 Corinna Vinschen + + * shm.cc (shmget): Fetch segment size from server rather than using + size argument to accommodate existing segments. Add comment to explain + why. + 2015-04-10 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000. diff --git a/winsup/cygwin/release/2.0.0 b/winsup/cygwin/release/2.0.0 index f01e497..6c89819 100644 --- a/winsup/cygwin/release/2.0.0 +++ b/winsup/cygwin/release/2.0.0 @@ -40,3 +40,6 @@ Bug Fixes - Fix UTF-16 surrogate handling in wctomb and friends. Addresses: https://cygwin.com/ml/cygwin/2015-03/msg00452.html + +- Fix shmget usage of size parameter for already existing segments. + Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00105.html diff --git a/winsup/cygwin/shm.cc b/winsup/cygwin/shm.cc index c5ab708..e209346 100644 --- a/winsup/cygwin/shm.cc +++ b/winsup/cygwin/shm.cc @@ -377,7 +377,14 @@ shmget (key_t key, size_t size, int shmflg) shmid and hdl value to the list. */ ssh_new_entry->shmid = shmid; ssh_new_entry->hdl = hdl; - ssh_new_entry->size = size; + /* Fetch segment size from server. If this is an already existing segment, + the size value in this shmget call is supposed to be meaningless. */ + struct shmid_ds stat; + client_request_shm stat_req (shmid, IPC_STAT, &stat); + if (stat_req.make_request () == -1 || stat_req.retval () == -1) +ssh_new_entry->size = size; + else +ssh_new_entry->size = stat.shm_segsz; ssh_new_entry->ref_count = 0; SLIST_INSERT_HEAD (&ssh_list, ssh_new_entry, ssh_next); SLIST_UNLOCK ();
[newlib-cygwin] Remove unused 32/64 bit tty code
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=84b8db8e7ac60ad8e08c7013fc8cc4f03d37f262 commit 84b8db8e7ac60ad8e08c7013fc8cc4f03d37f262 Author: Corinna Vinschen Date: Tue Apr 7 12:16:07 2015 +0200 Remove unused 32/64 bit tty code * tty.h (class tty): Remove unused 32/64 bit interoperability considerations. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/tty.h | 21 +++-- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f329a76..8065e73 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2015-04-07 Corinna Vinschen + * tty.h (class tty): Remove unused 32/64 bit interoperability + considerations. + +2015-04-07 Corinna Vinschen + * tty.h (NTTYS): Raise to 128. * devices.in: Change pty, ptym, and cons expressions accordingly. * devices.cc: Regenerate. diff --git a/winsup/cygwin/tty.h b/winsup/cygwin/tty.h index f3b6578..27d43f7 100644 --- a/winsup/cygwin/tty.h +++ b/winsup/cygwin/tty.h @@ -90,29 +90,14 @@ public: pid_t master_pid;/* PID of tty master process */ private: - /* Since tty is shared, the HANDLEs must be 32 and 64 bit clean. The below - code makes sure of that by setting the upper 4 byte of the union to 0 - when writing the handle value from a 32 bit process. Fortunately the - actual values are 32 bit on both platforms, so the HANDLES can be - used on both platforms. */ - union { -HANDLE _from_master; -LARGE_INTEGER _fm_dummy; - }; - union { -HANDLE _to_master; -LARGE_INTEGER _tm_dummy; - }; + HANDLE _from_master; + HANDLE _to_master; + public: HANDLE from_master() const { return _from_master; } HANDLE to_master() const { return _to_master; } -#ifdef __x86_64__ void set_from_master (HANDLE h) { _from_master = h; } void set_to_master (HANDLE h) { _to_master = h; } -#else - void set_from_master (HANDLE h) { _fm_dummy.HighPart = 0; _from_master = h; } - void set_to_master (HANDLE h) { _tm_dummy.HighPart = 0; _to_master = h; } -#endif int read_retval; bool was_opened; /* True if opened at least once. */
[newlib-cygwin] Bump Cygwin version to 2.0.0.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5778304f168a0ce4d1b6cd048a5e499436f0f6d0 commit 5778304f168a0ce4d1b6cd048a5e499436f0f6d0 Author: Corinna Vinschen Date: Fri Apr 10 20:41:00 2015 +0200 Bump Cygwin version to 2.0.0. * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000. (CYGWIN_VERSION_DLL_MINOR): Set to 0. * new-features.xml (ov-new2.0): Rename from ov-new1.7.36 and change version number to 2.0. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/include/cygwin/version.h | 4 ++-- winsup/cygwin/release/{1.7.36 => 2.0.0} | 0 winsup/doc/ChangeLog| 5 + winsup/doc/new-features.xml | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1b3003a..9a48131 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-10 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2000. + (CYGWIN_VERSION_DLL_MINOR): Set to 0. + 2015-04-04 Jon TURNEY * exceptions.cc (call_signal_handler): Set mcontext.cr2 to the diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 71d118e..7734b12 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -42,8 +42,8 @@ details. */ the Cygwin shared library". This version is used to track important changes to the DLL and is mainly informative in nature. */ -#define CYGWIN_VERSION_DLL_MAJOR 1007 -#define CYGWIN_VERSION_DLL_MINOR 36 +#define CYGWIN_VERSION_DLL_MAJOR 2000 +#define CYGWIN_VERSION_DLL_MINOR 0 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */ diff --git a/winsup/cygwin/release/1.7.36 b/winsup/cygwin/release/2.0.0 similarity index 100% rename from winsup/cygwin/release/1.7.36 rename to winsup/cygwin/release/2.0.0 diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 4163900..a0507a4 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-04-10 Corinna Vinschen + + * new-features.xml (ov-new2.0): Rename from ov-new1.7.36 and change + version number to 2.0. + 2015-04-02 David A. Wheeler * faq-setup.xml: Document how Cygwin secures installation and diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml index 3f8b967..2d0ed0b 100644 --- a/winsup/doc/new-features.xml +++ b/winsup/doc/new-features.xml @@ -4,7 +4,7 @@ What's new and what changed in Cygwin -What's new and what changed in 1.7.36 +What's new and what changed in 2.0
[newlib-cygwin] Fix broken PSID problem on cygheap in account handling
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=83b3f891c4f6cb46162ddec41ace787aa11929b3 commit 83b3f891c4f6cb46162ddec41ace787aa11929b3 Author: Corinna Vinschen Date: Fri Apr 17 11:56:15 2015 +0200 Fix broken PSID problem on cygheap in account handling * pwdgrp.h: Add comment to explain below change. (struct pg_pwd): Convert sid member to BYTE array. (struct pg_grp): Ditto. * grp.cc (pwdgrp::parse_group): Accommodate above change. * passwd.cc (pwdgrp::parse_passwd): Ditto. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 8 winsup/cygwin/grp.cc| 4 +++- winsup/cygwin/passwd.cc | 4 +++- winsup/cygwin/pwdgrp.h | 8 ++-- 4 files changed, 20 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a75810f..e1a61fc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2015-04-17 Corinna Vinschen + + * pwdgrp.h: Add comment to explain below change. + (struct pg_pwd): Convert sid member to BYTE array. + (struct pg_grp): Ditto. + * grp.cc (pwdgrp::parse_group): Accommodate above change. + * passwd.cc (pwdgrp::parse_passwd): Ditto. + 2015-04-12 Corinna Vinschen * shm.cc (shmget): Fetch segment size from server rather than using diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc index 40e1ca7..f850210 100644 --- a/winsup/cygwin/grp.cc +++ b/winsup/cygwin/grp.cc @@ -47,7 +47,9 @@ pwdgrp::parse_group () return false; /* Don't generate gr_mem entries. */ grp.g.gr_mem = &null_ptr; - grp.sid.getfromgr_passwd (&grp.g); + cygsid csid; + csid.getfromgr_passwd (&grp.g); + RtlCopySid (SECURITY_MAX_SID_SIZE, grp.sid, csid); return true; } diff --git a/winsup/cygwin/passwd.cc b/winsup/cygwin/passwd.cc index 7493aa4..54e429c 100644 --- a/winsup/cygwin/passwd.cc +++ b/winsup/cygwin/passwd.cc @@ -40,7 +40,9 @@ pwdgrp::parse_passwd () res.p.pw_gecos = next_str (':'); res.p.pw_dir = next_str (':'); res.p.pw_shell = next_str (':'); - res.sid.getfrompw_gecos (&res.p); + cygsid csid; + csid.getfrompw_gecos (&res.p); + RtlCopySid (SECURITY_MAX_SID_SIZE, res.sid, csid); /* lptr points to the \0 after pw_shell. Increment by one to get the correct required buffer len in getpw_cp. */ res.len = lptr - res.p.pw_name + 1; diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index a64cb0f..80c54c7 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -38,17 +38,21 @@ void *setgrent_filtered (int enums, PCWSTR enum_tdoms); void *getgrent_filtered (void *gr); void endgrent_filtered (void *gr); +/* NOTE: The below sid members were cygsid's originally. Don't do that. + cygsid's are pointer based. When adding new entries to the passwd or + group caches, a crealloc call potenitally moves the entries and then + the cygsid pointers point into neverneverland. */ struct pg_pwd { struct passwd p; - cygsid sid; + BYTE sid[SECURITY_MAX_SID_SIZE]; size_t len; }; struct pg_grp { struct group g; - cygsid sid; + BYTE sid[SECURITY_MAX_SID_SIZE]; size_t len; };
[newlib-cygwin] Set mcontext.cr2 to the faulting address
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bccc0e83e82af2e74e4a813bf551cad0b2305814 commit bccc0e83e82af2e74e4a813bf551cad0b2305814 Author: Jon TURNEY Date: Sat Apr 4 16:12:27 2015 +0100 Set mcontext.cr2 to the faulting address * exceptions.cc (call_signal_handler): Set mcontext.cr2 to the faulting address. Signed-off-by: Jon TURNEY Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/exceptions.cc | 4 2 files changed, 9 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a3a0026..1b3003a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-04 Jon TURNEY + + * exceptions.cc (call_signal_handler): Set mcontext.cr2 to the + faulting address. + 2015-04-02 Jon TURNEY * exceptions.cc (call_signal_handler): Only bother to construct diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 0c9ee14..4a6c21e 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1521,6 +1521,10 @@ _cygtls::call_signal_handler () context.uc_sigmask = context.uc_mcontext.oldmask = this_oldmask; + context.uc_mcontext.cr2 = (thissi.si_signo == SIGSEGV +|| thissi.si_signo == SIGBUS) + ? (uintptr_t) thissi.si_addr : 0; + thiscontext = &context; }
[newlib-cygwin] Undef basename before defining function.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6d099d5bae856af2b92ab3f7812632f0ea8ae7ea commit 6d099d5bae856af2b92ab3f7812632f0ea8ae7ea Author: Corinna Vinschen Date: Wed Apr 22 10:55:26 2015 +0200 Undef basename before defining function. * path.cc (basename): Undefine basename before defining function to avoid type collision with prototype in string.h. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/path.cc | 2 ++ 2 files changed, 7 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a190c24..eb79fcc 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-22 Corinna Vinschen + + * path.cc (basename): Undefine basename before defining function to + avoid type collision with prototype in string.h. + 2015-04-21 Corinna Vinschen * include/libgen.h: Remove in favor of newlib version. diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index b05333f..1dd96cf 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -4727,6 +4727,8 @@ out: return buf; } +#undef basename + /* No need to be reentrant or thread-safe according to SUSv3. / and \\ are treated equally. Leading drive specifiers are kept intact as far as it makes sense. Everything else is
[newlib-cygwin] Fix OPOST for non-Cygwin pty slaves
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c846bca9921f577956499aa0d8463c04e5694d46 commit c846bca9921f577956499aa0d8463c04e5694d46 Author: Takashi Yano Date: Wed Apr 22 13:22:59 2015 +0200 Fix OPOST for non-Cygwin pty slaves * fhandler.h (class fhandler_base): Add virtual function get_io_handle_cyg() to get handle from which OPOST-processed output is read on PTY master. (class fhandler_pty_slave): Add variable output_handle_cyg to store a handle to which OPOST-processed output is written. Add two functions, i.e., set_output_handle_cyg() and get_output_handle_cyg(), regarding variable output_handle_cyg. Now, output_handle is used only by native windows program. The data before OPOST-processing is written to output_handle and OPOST-processing is applied in the master-side. For a cygwin process, OPOST-processing is applied in the slave-side, and the data after OPOST-processing is written to output_handle_cyg. (class fhandler_pty_master): Add two variables, i.e., io_handle_cyg and to_master_cyg, to store handles of a pipe through which OPOST-processed output passes. Add pty_master_fwd_thread and function pty_master_fwd_thread() for a thread which applies OPOST-processing and forwards data from io_handle to to_master_cyg. Add function get_io_handle_cyg() regarding variable io_handle_cyg. Now, the pipe between io_handle and to_master are used only by native windows program for applying OPOST-processing in the master-side. For a cygwin process, the pipe between io_handle_cyg and to_master_cyg is used for passing through the data which is applied OPOST-processing in the slave-side. * fhandler_tty.cc (struct pipe_reply): Add member to_master_cyg. (fhandler_pty_master::process_slave_output): Read slave output from io_handle_cyg rather than io_handle. (fhandler_pty_slave::fhandler_pty_salve): Initialize output_handle_cyg. (fhandler_pty_slave::open): Set output_handle_cyg by duplicating handle to_master_cyg on PTY master. (fhandler_pty_slave::close): Close handle output_handle_cyg. (fhandler_pty_slave::write): Write data to output_handle_cyg rather than output_handle. (fhandler_pty_slave::fch_close_handles): Close handle output_handle_cyg. (fhandler_pty_master::fhandler_pty_master): Initialize io_handle_cyg, to_master_cyg and master_fwd_thread. (fhandler_pty_master::cleanup): Clean up to_master_cyg as well. (fhandler_pty_master::close): Print to_master_cyg as well in debug message. Terminate master forwarding thread. Close handles to_master_cyg and io_handle_cyg. (fhandler_pty_master::ioctl): Use io_handle_cyg rather than to_master. (fhandler_pty_master::pty_master_thread): Add code for duplicating handle to_master_cyg. (fhandler_pty_master::pty_master_fwd_thread): New function for a thread to forward OPOST-processed data from io_handle to to_master_cyg. This thread applies OPOST-processing to the output of native windows program. (::pty_master_fwd_thread): Ditto. (fhandler_pty_master::setup): Create a new pipe to pass thruegh OPOST- processed output. Create new thread to forward data from io_handle to to_master_cyg. Set handle to_master_cyg to tty. Print io_handle_cyg as well in debug message. Close handles io_handle_cyg and to_master_cyg in case of error. (fhandler_pty_master::fixup_after_fork): Set handle to_master_cyg to tty. Copy handle to_master_cyg from arch->to_master_cyg. (fhandler_pty_master::fixup_after_exec): Clean up to_master_cyg. * select.cc: Check handle returned by get_io_handle_cyg() rather than get_handle(). * tty.h (class tty): Add variable _to_master_cyg to store a handle to which OPOST-processed data is written. Add two functions, to_master_cyg() and set_to_master_cyg(), regarding _to_master_cyg. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 60 + winsup/cygwin/fhandler.h | 9 winsup/cygwin/fhandler_tty.cc | 121 -- winsup/cygwin/select.cc | 4 +- winsup/cygwin/tty.h | 3 ++ 5 files changed, 178 insertions(+), 19 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index eb79fcc..7e9de3f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,63 @@ +2015-04-22 Takashi Yano + + * fhandler.h (class fhandler_base): Add virtual function + get_io_handle_cyg() to get handle from which OPOST-processed output is + read on PTY master. + (class fhandler_pty_slave): Add variable output_handle_cyg to store a + handle
[newlib-cygwin] Fix closing too many handles in pty fchown/fchmod
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4e99630cfdfa582feb6deeb12f6fbee92d15d44e commit 4e99630cfdfa582feb6deeb12f6fbee92d15d44e Author: Corinna Vinschen Date: Wed Apr 22 13:26:37 2015 +0200 Fix closing too many handles in pty fchown/fchmod * fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close handles not opened via fhandler_pty_slave::fch_open_handles. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/fhandler_tty.cc | 3 --- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7e9de3f..0c9478e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-22 Corinna Vinschen + + * fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close + handles not opened via fhandler_pty_slave::fch_open_handles. + 2015-04-22 Takashi Yano * fhandler.h (class fhandler_base): Add virtual function diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index d3fbcee..f9205f6 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -1084,9 +1084,6 @@ fhandler_pty_slave::fch_set_sd (security_descriptor &sd, bool chown) void fhandler_pty_slave::fch_close_handles () { - close_maybe (get_io_handle ()); - close_maybe (get_output_handle ()); - close_maybe (get_output_handle_cyg ()); close_maybe (input_available_event); close_maybe (output_mutex); close_maybe (input_mutex);
[newlib-cygwin] Fix inconsistencies in docs regarding fstab and executable file detection
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bbc87a02fdf3df19ca5a42f844e4ca74ddded293 commit bbc87a02fdf3df19ca5a42f844e4ca74ddded293 Author: David Macek Date: Sat Apr 18 23:25:15 2015 +0200 Fix inconsistencies in docs regarding fstab and executable file detection The inline list of mount options seemed redundant, so the paragraph now points to the list below it. List of executable extensions updated according to fhandler_disk_file.cc. List of executable magic numbers updated according to path.h (has_exec_chars). * pathnames.xml: Fix inconsistencies in docs regarding fstab and executable file detection Signed-off-by: Corinna Vinschen Diff: --- winsup/doc/pathnames.xml | 13 ++--- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/winsup/doc/pathnames.xml b/winsup/doc/pathnames.xml index 00eb133..cdbf9fa 100644 --- a/winsup/doc/pathnames.xml +++ b/winsup/doc/pathnames.xml @@ -81,9 +81,8 @@ see The fourth field describes the mount options associated with the filesystem. It is formatted as a comma separated list of options. It contains at least the type of mount (binary or text) plus -any additional options appropriate to the filesystem type. Recognized -options are binary, text, nouser, user, exec, notexec, cygexec, nosuid, -posix=[0|1]. The meaning of the options is as follows. +any additional options appropriate to the filesystem type. The list of +the options, including their meaning, follows. acl - Cygwin uses the filesystem's access control lists (ACLs) to @@ -136,14 +135,14 @@ executability, this is not possible on filesystems which don't support permissions at all (like FAT/FAT32), or if ACLs are ignored on filesystems supporting them (see the aforementioned acl mount option). In these cases, the following heuristic is used to evaluate if a file is -executable: Files ending in certain extensions (.exe, .com, .bat, .btm, -.cmd) are assumed to be executable. Files whose first two characters begin -with '#!' are also considered to be executable. +executable: Files ending in certain extensions (.exe, .com, .lnk) are +assumed to be executable. Files whose first two characters are "#!", "MZ", +or ":\n" are also considered to be executable. The exec option is used to instruct Cygwin that the mounted file is "executable". If the exec option is used with a directory then all files in the directory are executable. This option allows other files to be marked as executable and avoids the -overhead of opening each file to check for a '#!'. The +overhead of opening each file to check for "magic" bytes. The cygexec option is very similar to exec, but also prevents Cygwin from setting up commands and environment variables for a normal Windows program, adding another small performance gain. The
[newlib-cygwin] Asia/Calcutta -> Asia/Kolkata (not on unicode.org)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=68994d682802cf18e71ec3d9e811c232ded47225 commit 68994d682802cf18e71ec3d9e811c232ded47225 Author: Corinna Vinschen Date: Tue Apr 21 14:29:01 2015 +0200 Asia/Calcutta -> Asia/Kolkata (not on unicode.org) * tzmap-from-unicode.org: Convert Calcutta to Kolkata. * tzmap.h: Regenerate. Signed-off-by: Corinna Vinschen Diff: --- winsup/utils/ChangeLog | 5 + winsup/utils/tzmap-from-unicode.org | 1 + winsup/utils/tzmap.h| 11 +++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index ef6d32e..bfdb42a 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2015-04-21 Corinna Vinschen + + * tzmap-from-unicode.org: Convert Calcutta to Kolkata. + * tzmap.h: Regenerate. + 2015-02-28 Corinna Vinschen * getfacl.c (usage): Change --all to --access, --dir to --default. diff --git a/winsup/utils/tzmap-from-unicode.org b/winsup/utils/tzmap-from-unicode.org index a155312..e169ee7 100755 --- a/winsup/utils/tzmap-from-unicode.org +++ b/winsup/utils/tzmap-from-unicode.org @@ -64,6 +64,7 @@ echo "{" wget -O - "${ZONES_FILE}" | \ { sed -n -e 's#territory="001"#territory=""# +s#Asia/Calcutta#Asia/Kolkata# s#.*mapZone other=\("[^"]*"\) territory=\("[^"]*"\) type=\("[^"]*"\).*# { L\1, L\2, L\3 },#p' echo ' { L"Armenian Standard Time", L"AM", L"Asia/Yerevan" },' echo ' { L"Central Europe Standard Time", L"CS", L"Europe/Belgrade" },' diff --git a/winsup/utils/tzmap.h b/winsup/utils/tzmap.h index dd4f8c0..31a83c9 100644 --- a/winsup/utils/tzmap.h +++ b/winsup/utils/tzmap.h @@ -134,6 +134,7 @@ struct { L"Central Pacific Standard Time", L"AU", L"Antarctica/Macquarie" }, { L"Central Pacific Standard Time", L"FM", L"Pacific/Ponape Pacific/Kosrae" }, { L"Central Pacific Standard Time", L"NC", L"Pacific/Noumea" }, + { L"Central Pacific Standard Time", L"PG", L"Pacific/Bougainville" }, { L"Central Pacific Standard Time", L"SB", L"Pacific/Guadalcanal" }, { L"Central Pacific Standard Time", L"VU", L"Pacific/Efate" }, { L"Central Pacific Standard Time", L"ZZ", L"Etc/GMT-11" }, @@ -143,7 +144,7 @@ struct { L"Central Standard Time", L"US", L"America/Chicago America/Indiana/Knox America/Indiana/Tell_City America/Menominee America/North_Dakota/Beulah America/North_Dakota/Center America/North_Dakota/New_Salem" }, { L"Central Standard Time", L"ZZ", L"CST6CDT" }, { L"Central Standard Time (Mexico)", L"", L"America/Mexico_City" }, - { L"Central Standard Time (Mexico)", L"MX", L"America/Mexico_City America/Bahia_Banderas America/Cancun America/Merida America/Monterrey" }, + { L"Central Standard Time (Mexico)", L"MX", L"America/Mexico_City America/Bahia_Banderas America/Merida America/Monterrey" }, { L"China Standard Time", L"", L"Asia/Shanghai" }, { L"China Standard Time", L"CN", L"Asia/Shanghai" }, { L"China Standard Time", L"HK", L"Asia/Hong_Kong" }, @@ -179,6 +180,8 @@ struct { L"Eastern Standard Time", L"TC", L"America/Grand_Turk" }, { L"Eastern Standard Time", L"US", L"America/New_York America/Detroit America/Indiana/Petersburg America/Indiana/Vincennes America/Indiana/Winamac America/Kentucky/Monticello America/Louisville" }, { L"Eastern Standard Time", L"ZZ", L"EST5EDT" }, + { L"Eastern Standard Time (Mexico)", L"", L"America/Cancun" }, + { L"Eastern Standard Time (Mexico)", L"MX", L"America/Cancun" }, { L"Egypt Standard Time", L"", L"Africa/Cairo" }, { L"Egypt Standard Time", L"EG", L"Africa/Cairo" }, { L"Egypt Standard Time", L"PS", L"Asia/Gaza Asia/Hebron" }, @@ -236,8 +239,8 @@ struct { L"Hawaiian Standard Time", L"UM", L"Pacific/Johnston" }, { L"Hawaiian Standard Time", L"US", L"Pacific/Honolulu" }, { L"Hawaiian Standard Time", L"ZZ", L"Etc/GMT+10" }, - { L"India Standard Time", L"", L"Asia/Calcutta" }, - { L"India Standard Time", L"IN", L"Asia/Calcutta" }, + { L"India Standard Time", L"", L"Asia/Kolkata" }, + { L"India Standard Time", L"IN", L"Asia/Kolkata" }, { L"Iran Standard Time", L"", L"Asia/Tehran" }, { L"Iran Standard Time", L"IR", L"Asia/Tehran" }, { L"Israel Standard Time", L"", L"Asia/Jerusalem" }, @@ -507,7 +510,7 @@ struct { L"West Pacific Standard Time", L"FM", L"Pacific/Truk" }, { L"West Pacific Standard Time", L"GU", L"Pacific/Guam" }, { L"West Pacific Standard Time", L"MP", L"Pacific/Saipan" }, - { L"West Pacific Standard Time", L"PG", L"Pacific/Port_Moresby Pacific/Bougainville" }, + { L"West Pacific Standard Time", L"PG", L"Pacific/Port_Moresby" }, { L"West Pacific Standard Time", L"ZZ", L"Etc/GMT-10" }, { L"Yakutsk Standard Time", L"", L"Asia/Yakutsk" }, { L"Yakutsk Standard Time", L"RU", L"Asia/Yakutsk Asia/Khandyga" },
[newlib-cygwin] Remove Cygwin's libgen.h
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e0aa6d23fbae7dd54a7d5652b60f0b9e15f2c52b commit e0aa6d23fbae7dd54a7d5652b60f0b9e15f2c52b Author: Corinna Vinschen Date: Tue Apr 21 14:51:30 2015 +0200 Remove Cygwin's libgen.h * include/libgen.h: Remove in favor of newlib version. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/libgen.h | 23 --- 2 files changed, 4 insertions(+), 23 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f60dbb9..a190c24 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-04-21 Corinna Vinschen + + * include/libgen.h: Remove in favor of newlib version. + 2015-04-17 Corinna Vinschen * uinfo.cc (pwdgrp::fetch_account_from_windows): Always revert SID diff --git a/winsup/cygwin/include/libgen.h b/winsup/cygwin/include/libgen.h deleted file mode 100644 index f5c24a8..000 --- a/winsup/cygwin/include/libgen.h +++ /dev/null @@ -1,23 +0,0 @@ -/* libgen.h - - Copyright 2005 Red Hat, Inc. - -This file is part of Cygwin. - -This software is a copyrighted work licensed under the terms of the -Cygwin license. Please consult the file "CYGWIN_LICENSE" for -details. */ - -#ifndef _LIBGEN_H -#define _LIBGEN_H - -#include - -__BEGIN_DECLS - -extern char *basename (char *path); -extern char *dirname (char *path); - -__END_DECLS - -#endif /* _LIBGEN_H */
[newlib-cygwin] Document previous unlink patch
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f21c9bface547a444027ecb7e29c57631ab296aa commit f21c9bface547a444027ecb7e29c57631ab296aa Author: Corinna Vinschen Date: Thu Apr 23 15:22:37 2015 +0200 Document previous unlink patch Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.0.0 | 6 ++ 1 file changed, 6 insertions(+) diff --git a/winsup/cygwin/release/2.0.0 b/winsup/cygwin/release/2.0.0 index 6c89819..08d4450 100644 --- a/winsup/cygwin/release/2.0.0 +++ b/winsup/cygwin/release/2.0.0 @@ -43,3 +43,9 @@ Bug Fixes - Fix shmget usage of size parameter for already existing segments. Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00105.html + +- Fix how in-use files on virtual drives created via subst are moved to + the recycler in unlink(2). + Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00527.html + +- Fix how in-use files on Samba drives are renamed in unlink(2).
[newlib-cygwin] Handle unlinking in-use files on virtual drives
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5abb0ed13c09a1ce68d3134c7a9369ccbb1a739b commit 5abb0ed13c09a1ce68d3134c7a9369ccbb1a739b Author: Corinna Vinschen Date: Thu Apr 23 15:02:32 2015 +0200 Handle unlinking in-use files on virtual drives * path.cc (path_conv::set_nt_native_path): New function. * path.h (path_conv::set_nt_native_path): Add prototype. * syscall.cc (try_to_bin): Handle moving files to the recycler accessed via a local virtual drive (subst). Fix a problem renaming the file to the unique replacement name on Samba. Align comment. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 8 winsup/cygwin/path.cc | 12 winsup/cygwin/path.h | 1 + winsup/cygwin/syscalls.cc | 28 +--- 4 files changed, 46 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0c9478e..5923442 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2015-04-23 Corinna Vinschen + + * path.cc (path_conv::set_nt_native_path): New function. + * path.h (path_conv::set_nt_native_path): Add prototype. + * syscall.cc (try_to_bin): Handle moving files to the recycler + accessed via a local virtual drive (subst). Fix a problem renaming + the file to the unique replacement name on Samba. Align comment. + 2015-04-22 Corinna Vinschen * fhandler_tty.cc (fhandler_pty_slave::fch_close_handles): Don't close diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 1dd96cf..446d746 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -486,6 +486,18 @@ get_nt_native_path (const char *path, UNICODE_STRING& upath, bool dos) return &upath; } +/* Handle with extrem care! Only used in a certain instance in try_to_bin. + Every other usage needs a careful check. */ +void +path_conv::set_nt_native_path (PUNICODE_STRING new_path) +{ + wide_path = (PWCHAR) crealloc_abort (wide_path, new_path->MaximumLength); + memcpy (wide_path, new_path->Buffer, new_path->Length); + uni_path.Length = new_path->Length; + uni_path.MaximumLength = new_path->MaximumLength; + uni_path.Buffer = wide_path; +} + PUNICODE_STRING path_conv::get_nt_native_path () { diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index a668eae..5c464dc 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -270,6 +270,7 @@ class path_conv ~path_conv (); inline const char *get_win32 () const { return path; } + void set_nt_native_path (PUNICODE_STRING); PUNICODE_STRING get_nt_native_path (); inline POBJECT_ATTRIBUTES get_object_attr (OBJECT_ATTRIBUTES &attr, SECURITY_ATTRIBUTES &sa) diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index d2fb353..c08d12f 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -314,15 +314,35 @@ try_to_bin (path_conv &pc, HANDLE &fh, ACCESS_MASK access, ULONG flags) RtlAppendUnicodeToString (&recycler, L"\\Recycled\\"); else goto out; - /* Is the file a subdir of the recycler? */ RtlInitCountedUnicodeString(&fname, pfni->FileName, pfni->FileNameLength); + /* Is the file a subdir of the recycler? */ if (RtlEqualUnicodePathPrefix (&fname, &recycler, TRUE)) goto out; /* Is fname the recycler? Temporarily hide trailing backslash. */ recycler.Length -= sizeof (WCHAR); if (RtlEqualUnicodeString (&fname, &recycler, TRUE)) goto out; + /* Is fname really a subcomponent of the full path? If not, there's +a high probability we're acessing the file via a virtual drive +created with "subst". Check and accommodate it. Note that we +ony get here if the virtual drive is really pointing to a local +drive. Otherwise pc.isremote () returns "true". */ + if (!RtlEqualUnicodePathSuffix (pc.get_nt_native_path (), &fname, TRUE)) + { + WCHAR drive[3] = { pc.get_nt_native_path ()->Buffer[4], ':', '\0' }; + PWCHAR tgt = tp.w_get (); + if (QueryDosDeviceW (drive, tgt, NT_MAX_PATH) + && !wcsncmp (tgt, L"\\??\\", 4)) + { + UNICODE_STRING new_path; + + wcsncpy (tgt + 6, fname.Buffer, fname.Length / sizeof (WCHAR)); + RtlInitCountedUnicodeString(&new_path, tgt, + 6 * sizeof (WCHAR) + fname.Length); + pc.set_nt_native_path (&new_path); + } + } /* Create root dir path from file name information. */ RtlSplitUnicodePath (&fname, &fname, NULL); RtlSplitUnicodePath (pc.get_nt_
[newlib-cygwin] Define __s64 and __u64
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=49c051c13352cd2fd2131a379d51a4a63c09283e commit 49c051c13352cd2fd2131a379d51a4a63c09283e Author: Corinna Vinschen Date: Mon Apr 27 14:39:57 2015 +0200 Define __s64 and __u64 * include/asm/types.h: Add __s64 and __u64 types. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/include/asm/types.h | 6 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5923442..43bbbc1 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-04-27 Corinna Vinschen + + * include/asm/types.h: Add __s64 and __u64 types. + 2015-04-23 Corinna Vinschen * path.cc (path_conv::set_nt_native_path): New function. diff --git a/winsup/cygwin/include/asm/types.h b/winsup/cygwin/include/asm/types.h index 19cc2ca..dc51af6 100644 --- a/winsup/cygwin/include/asm/types.h +++ b/winsup/cygwin/include/asm/types.h @@ -1,6 +1,6 @@ /* asm/types.h - Copyright 1998, 2000, 2001 Red Hat, Inc. + Copyright 1998, 2000, 2001, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -20,4 +20,8 @@ typedef unsigned short __u16; typedef __signed__ int __s32; typedef unsigned int __u32; +/* As on Linux. Works for both platforms, i686 and x86_64. */ +typedef __signed__ long long __s64; +typedef unsigned long long __u64; + #endif /* _ASM_TYPES_H */
[newlib-cygwin] Fix more typos in ntsec.xml
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=37ab32da30a8bed7339fb1e9968bae53390a4622 commit 37ab32da30a8bed7339fb1e9968bae53390a4622 Author: Yaakov Selkowitz Date: Wed Apr 29 11:20:21 2015 -0500 Fix more typos in ntsec.xml Signed-off-by: Yaakov Selkowitz Diff: --- winsup/doc/ntsec.xml | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winsup/doc/ntsec.xml b/winsup/doc/ntsec.xml index b731cd0..d982867 100644 --- a/winsup/doc/ntsec.xml +++ b/winsup/doc/ntsec.xml @@ -863,7 +863,7 @@ the old information. So, what settings can we perform with /etc/nsswitch.conf? Let's start with an example /etc/nsswitch.conf file -file set up to all default values: +set up to all default values: @@ -1749,7 +1749,7 @@ The unix schema utilizes the posixAccount attribute extension. This is one of two schema extensions which are connected to AD accounts, available by default starting with Windows Server 2003 R2. They are usually -not set, unless used by the Active Directory +not set, unless used by the Active Directory Server for NIS feature (deprecated since Server 2012 R2). Two schemata are interesting for Cygwin, posixAccount, @@ -2031,7 +2031,7 @@ by child processes. A fully set up Samba file server with domain integration is running winbindd to -map Window SIDs to artificially created UNIX uids and gids, and this mapping is +map Windows SIDs to artificially created UNIX uids and gids, and this mapping is transparent within the domain, so Cygwin doesn't have to do anything special. @@ -2134,7 +2134,7 @@ met. Later ACEs are not taken into account. All access denied ACEs should precede any access allowed ACE. ACLs -following this rule are called "canonical" +following this rule are called "canonical". Note that the last rule is a preference or a definition of
[newlib-cygwin] cygserver.xml: Add new section. How to install Cygserver.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a3e0771edaeefe88a97258c610e4405f01c28cd4 commit a3e0771edaeefe88a97258c610e4405f01c28cd4 Author: Mike DePaulo Date: Mon Apr 27 04:46:18 2015 -0400 cygserver.xml: Add new section. How to install Cygserver. * cygserver.xml (install-cygserver): Add new section. How to install Cygserver. Signed-off-by: Corinna Vinschen Diff: --- winsup/doc/ChangeLog | 5 + winsup/doc/cygserver.xml | 13 + 2 files changed, 18 insertions(+) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index a0507a4..10f2958 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-04-27 Mike DePaulo + + * cygserver.xml (install-cygserver): Add new section. How to install + Cygserver. + 2015-04-10 Corinna Vinschen * new-features.xml (ov-new2.0): Rename from ov-new1.7.36 and change diff --git a/winsup/doc/cygserver.xml b/winsup/doc/cygserver.xml index 6a4ec4e..2367a60 100644 --- a/winsup/doc/cygserver.xml +++ b/winsup/doc/cygserver.xml @@ -179,6 +179,19 @@ +How to install Cygserver + + + Cygserver is part of the base cygwin package. + Therefore, whenever Cygwin is installed, so is Cygserver. + + + You may want to install Cygserver as a service. See + . + + + + How to start Cygserver
[newlib-cygwin] Use all ACEs from original ACL on Samba share
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b07326d29e0df7a8f21aaadefebecbec8da20144 commit b07326d29e0df7a8f21aaadefebecbec8da20144 Author: Corinna Vinschen Date: Thu Apr 30 17:26:55 2015 +0200 Use all ACEs from original ACL on Samba share * security.cc (convert_samba_sd): Fix accidental dropping of all non-Unix User, non-Unix Group accounts. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/security.cc | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 43bbbc1..414e148 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-04-30 Corinna Vinschen + + * security.cc (convert_samba_sd): Fix accidental dropping of all + non-Unix User, non-Unix Group accounts. + 2015-04-27 Corinna Vinschen * include/asm/types.h: Add __s64 and __u64 types. diff --git a/winsup/cygwin/security.cc b/winsup/cygwin/security.cc index 1bc0c50..86ebe2c 100644 --- a/winsup/cygwin/security.cc +++ b/winsup/cygwin/security.cc @@ -1145,10 +1145,10 @@ convert_samba_sd (security_descriptor &sd_ret) if (gid < UNIX_POSIX_OFFSET && (grp = internal_getgrgid (gid))) ace_sid.getfromgr (grp); } - if (!add_access_allowed_ace (acl, i, ace->Mask, ace_sid, acl_len, -ace->Header.AceFlags)) - return; } + if (!add_access_allowed_ace (acl, i, ace->Mask, ace_sid, acl_len, +ace->Header.AceFlags)) + return; } acl->AclSize = acl_len;
[newlib-cygwin] Bump minor DLL version to 1
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d4058c6686fe4b59988d7b642627308b4622d90d commit d4058c6686fe4b59988d7b642627308b4622d90d Author: Corinna Vinschen Date: Thu Apr 30 17:53:15 2015 +0200 Bump minor DLL version to 1 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/cygwin/version.h | 2 +- winsup/cygwin/release/2.0.1| 8 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 414e148..b21e107 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,9 @@ 2015-04-30 Corinna Vinschen + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 1. + +2015-04-30 Corinna Vinschen + * security.cc (convert_samba_sd): Fix accidental dropping of all non-Unix User, non-Unix Group accounts. diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 7734b12..1ac9e6e 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -43,7 +43,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 0 +#define CYGWIN_VERSION_DLL_MINOR 1 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */ diff --git a/winsup/cygwin/release/2.0.1 b/winsup/cygwin/release/2.0.1 new file mode 100644 index 000..3d10d8d --- /dev/null +++ b/winsup/cygwin/release/2.0.1 @@ -0,0 +1,8 @@ +Bug Fixes +- + +- Fix type check for base type of int32_t/uint32_t. + Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00602.html + +- Fix a bug in SID conversion per RFC2307 on Samba shares. + Addresses: https://cygwin.com/ml/cygwin/2015-04/msg00636.html
[newlib-cygwin] Bump minor DLL version to 2
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=761a123a4f9de9f06b3cb8f348a5ec7d6c9a70a2 commit 761a123a4f9de9f06b3cb8f348a5ec7d6c9a70a2 Author: Corinna Vinschen Date: Sun May 3 12:28:39 2015 +0200 Bump minor DLL version to 2 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/cygwin/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b21e107..abcc85f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-05-03 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 2. + 2015-04-30 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 1. diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 1ac9e6e..b9a09f5 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -43,7 +43,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 1 +#define CYGWIN_VERSION_DLL_MINOR 2 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */
[newlib-cygwin] * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=3afe8808b9412a79be781ccfc9a40604bab237d0 commit 3afe8808b9412a79be781ccfc9a40604bab237d0 Author: Takashi Yano Date: Wed May 27 12:56:31 2015 +0200 * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/net.cc| 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index abcc85f..86913f3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-05-27 Takashi Yano + + * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api. + 2015-05-03 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 2. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index eaf6eb8..e94eb50 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -18,7 +18,8 @@ details. */ if_indextoname functions in iphlpapi.h since Vista. TODO: Convert if_nametoindex to cygwin_if_nametoindex and call system functions on Vista and later. */ -#define _INC_NETIOAPI +#define _INC_NETIOAPI /* w32api < 4.0 */ +#define _NETIOAPI_H_ #include "winsup.h" #ifdef __x86_64__ /* 2014-04-24: Current Mingw headers define sockaddr_in6 using u_long (8 byte)
[newlib-cygwin] Use NtQueryObject to detect closing the last master handle
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=712811e9bb53564fe27631c0cdaf0e7adb521396 commit 712811e9bb53564fe27631c0cdaf0e7adb521396 Author: Corinna Vinschen Date: Thu May 28 16:06:49 2015 +0200 Use NtQueryObject to detect closing the last master handle Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 8 winsup/cygwin/fhandler_tty.cc | 29 + 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 86913f3..e2ada77 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2015-05-28 Takashi Yano + Corinna Vinschen + + * fhandler_tty.cc (fhandler_pty_common::close): Don't close output_mutex + here. Move into callers. + (fhandler_pty_master::close): Use NtQueryObject instead of PeekNamedPipe + to detect closing the last master handle. + 2015-05-27 Takashi Yano * net.cc: Define _NETIOAPI_H_ to accomodate newer w32api. diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index f9205f6..1b5c18b 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -552,7 +552,10 @@ fhandler_pty_slave::close () get_output_handle_cyg ()); if ((unsigned) myself->ctty == FHDEV (DEV_PTYS_MAJOR, get_minor ())) fhandler_console::free_console (); /* assumes that we are the last pty closer */ - return fhandler_pty_common::close (); + fhandler_pty_common::close (); + if (!ForceCloseHandle (output_mutex)) +termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex); + return 0; } int @@ -1201,8 +1204,6 @@ fhandler_pty_common::close () termios_printf ("pty%d <%p,%p> closing", get_minor (), get_handle (), get_output_handle ()); if (!ForceCloseHandle (input_mutex)) termios_printf ("CloseHandle (input_mutex<%p>), %E", input_mutex); - if (!ForceCloseHandle (output_mutex)) -termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex); if (!ForceCloseHandle1 (get_handle (), from_pty)) termios_printf ("CloseHandle (get_handle ()<%p>), %E", get_handle ()); if (!ForceCloseHandle1 (get_output_handle (), to_pty)) @@ -1223,6 +1224,9 @@ fhandler_pty_master::cleanup () int fhandler_pty_master::close () { + OBJECT_BASIC_INFORMATION obi; + NTSTATUS status; + termios_printf ("closing from_master(%p)/to_master(%p)/to_master_cyg(%p) since we own them(%u)", from_master, to_master, to_master_cyg, dwProcessId); if (cygwin_finished_initializing) @@ -1251,13 +1255,22 @@ fhandler_pty_master::close () } } - fhandler_pty_common::close (); - /* Check if the last master handle has been closed. If so, set input_available_event to wake up potentially waiting slaves. */ - if (!PeekNamedPipe (from_master, NULL, 0, NULL, NULL, NULL) - && GetLastError () == ERROR_BROKEN_PIPE) -SetEvent (input_available_event); + acquire_output_mutex (INFINITE); + status = NtQueryObject (get_output_handle (), ObjectBasicInformation, + &obi, sizeof obi, NULL); + fhandler_pty_common::close (); + release_output_mutex (); + if (!ForceCloseHandle (output_mutex)) +termios_printf ("CloseHandle (output_mutex<%p>), %E", output_mutex); + if (!NT_SUCCESS (status)) +debug_printf ("NtQueryObject: %y", status); + else if (obi.HandleCount == 1) +{ + termios_printf("Closing last master of pty%d", get_minor ()); + SetEvent (input_available_event); +} if (!ForceCloseHandle (from_master)) termios_printf ("error closing from_master %p, %E", from_master);
[newlib-cygwin] Fold branch cygwin-2.0 into master
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=30cffa234b092f3b17aeff63347c5f2ffd481bc3 commit 30cffa234b092f3b17aeff63347c5f2ffd481bc3 Merge: 1aeda8a 714507f Author: Corinna Vinschen Date: Thu May 28 17:20:39 2015 +0200 Fold branch cygwin-2.0 into master Make master equivalent to cygwin-2.0 without losing history of both branches. Diff:
[newlib-cygwin] Fix broken SID in passwd/group entry for unkown account
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5dc398f1d9ea628809c56b3aedfe282e68b978f3 commit 5dc398f1d9ea628809c56b3aedfe282e68b978f3 Author: Corinna Vinschen Date: Fri Apr 17 11:57:57 2015 +0200 Fix broken SID in passwd/group entry for unkown account * uinfo.cc (pwdgrp::fetch_account_from_windows): Always revert SID subauth count after checking for known domain. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/uinfo.cc | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e1a61fc..f60dbb9 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2015-04-17 Corinna Vinschen + * uinfo.cc (pwdgrp::fetch_account_from_windows): Always revert SID + subauth count after checking for known domain. + +2015-04-17 Corinna Vinschen + * pwdgrp.h: Add comment to explain below change. (struct pg_pwd): Convert sid member to BYTE array. (struct pg_grp): Ditto. diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 6186327..bc5f814 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -2475,10 +2475,10 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) posix_offset = fetch_posix_offset (td, &loc_ldap); break; } + sid_sub_auth_count (sid) = sid_sub_auth_count (sid) + 1; } if (domain) { - sid_sub_auth_count (sid) = sid_sub_auth_count (sid) + 1; wcscpy (dom, domain); __small_swprintf (name = namebuf, L"%W(%u)", is_group () ? L"Group" : L"User",
[newlib-cygwin] Introduce sidfromuid and sidfromgid
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=853fcd8936b5ffdc465e4ce31af51b8ae223d247 commit 853fcd8936b5ffdc465e4ce31af51b8ae223d247 Author: Corinna Vinschen Date: Wed Apr 8 11:00:08 2015 +0200 Introduce sidfromuid and sidfromgid * pwdgrp.h (sidfromuid): New inline function. (sidfromgid): Ditto. * fhandler_disk_file.cc (fhandler_disk_file::fchown): Use sidfromuid. * quotactl.cc (quotactl): Use sidfromuid and sidfromgid. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/fhandler_disk_file.cc | 4 ++-- winsup/cygwin/pwdgrp.h | 16 winsup/cygwin/quotactl.cc | 17 + 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 659f568..aa60192 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2015-04-08 Corinna Vinschen + * pwdgrp.h (sidfromuid): New inline function. + (sidfromgid): Ditto. + * fhandler_disk_file.cc (fhandler_disk_file::fchown): Use sidfromuid. + * quotactl.cc (quotactl): Use sidfromuid and sidfromgid. + +2015-04-08 Corinna Vinschen + * include/cyggwin/acl.h (struct __acl16): Move from here... * sec_acl.cc: ...to here. diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 6a42567..f5edb03 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -989,10 +989,10 @@ fhandler_disk_file::fchown (uid_t uid, gid_t gid) the standard UNIX accounts, we're faking success. */ if (res == -1 && pc.fs_is_samba ()) { - cygsid sid; + PSID sid; if (old_uid == ILLEGAL_UID - || (sid.getfrompw (internal_getpwuid (old_uid)) + || ((sid = sidfromuid (old_uid, NULL)) != NO_SID && RtlEqualPrefixSid (sid, well_known_samba_unix_user_fake_sid))) { diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h index dc718c5..a64cb0f 100644 --- a/winsup/cygwin/pwdgrp.h +++ b/winsup/cygwin/pwdgrp.h @@ -254,3 +254,19 @@ inline BOOL cygsid::getfrompw (const struct passwd *pw) inline BOOL cygsid::getfromgr (const struct group *gr) { return (*this = gr ? (PSID) ((pg_grp *) gr)->sid : NO_SID) != NO_SID; } + +/* Use these functions if you just need the PSID. */ +inline PSID sidfromuid (uid_t uid, cyg_ldap *pldap) + { +struct passwd *pw = internal_getpwuid (uid, pldap); +if (pw) + return (PSID) ((pg_pwd *) pw)->sid; +return NO_SID; + } +inline PSID sidfromgid (gid_t gid, cyg_ldap *pldap) + { +struct group *gr = internal_getgrgid (gid, pldap); +if (gr) + return (PSID) ((pg_grp *) gr)->sid; +return NO_SID; + } diff --git a/winsup/cygwin/quotactl.cc b/winsup/cygwin/quotactl.cc index 96c6134..f4c325b 100644 --- a/winsup/cygwin/quotactl.cc +++ b/winsup/cygwin/quotactl.cc @@ -1,6 +1,6 @@ /* quotactl.cc: code for manipulating disk quotas - Copyright 2014 Red Hat, Inc. + Copyright 2014, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -28,7 +28,7 @@ extern "C" int quotactl (int cmd, const char *special, int id, caddr_t addr) { ACCESS_MASK access = FILE_READ_DATA; - cygsid sid; + PSID sid = NO_SID; path_conv pc; tmp_pathbuf tp; UNICODE_STRING path; @@ -75,18 +75,11 @@ quotactl (int cmd, const char *special, int id, caddr_t addr) /* Windows feature: Default limits. Get or set them with id == -1. */ if (id != -1) { - struct passwd *pw = NULL; - struct group *gr = NULL; - if (type == USRQUOTA) - pw = internal_getpwuid (id); - else - gr = internal_getgrgid (id); - if (pw) - sid.getfrompw (pw); - else if (gr) - sid.getfromgr (gr); + sid = sidfromuid (id, NULL); else + sid = sidfromgid (id, NULL); + if (sid == NO_SID) { set_errno (EINVAL); return -1;
[newlib-cygwin] Created branch 'cygwin-acl'
The branch 'cygwin-acl' was created pointing to: 30cffa2... Fold branch cygwin-2.0 into master
[newlib-cygwin/cygwin-acl] Reapply Cygwin POSIX ACL changes from master
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e9ca3fa538186be53c1448ddf671676172c9e54b commit e9ca3fa538186be53c1448ddf671676172c9e54b Author: Corinna Vinschen Date: Fri May 29 16:19:55 2015 +0200 Reapply Cygwin POSIX ACL changes from master Reapply POSIX ACL changes. * sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL. Apply umask, if so. Align comments. * security.cc (set_created_file_access): Fix permission masking by incoming requested file mode. * sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit for SYSTEM and Admins group. * sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and GROUP entries if they are the same as USER_OBJ or GROUP_OBJ. * fhandler.h (fhandler_pty_slave::facl): Add prototype. * fhandler_tty.cc (fhandler_pty_slave::facl): New method. (fhandler_pty_slave::fchown): Fix uid/gid handling. * sec_acl.cc (set_posix_access): Drop superfluous class_idx variable. Simplify and move around code in a few places. To improve ACL readability, add r/w permissions to Admins ACE appended to pty ACL. Add comment to explain Windows ACE Mask filtering being in the way of creating a real CLASS_OBJ. (get_posix_access): Fake CLASS_OBJ for ptys. Explain why. * security.cc (get_object_attribute): Add S_IFCHR flag to attributes when calling get_posix_access. * sec_acl.cc (set_posix_access): Move merging group perms into owner perms in case of owner == group after mask has been computed. Take mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE. * sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw the ACCESS_ALLOWED_ACE. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment to explain why. * security.cc (set_created_file_access): Ditto. * sec_acl.cc (set_posix_access): Replace previous patch. Return EINVAL if uid and/or guid is invalid and not backed by an actual Windows account. * sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL. * sec_acl.cc (set_posix_access): Handle files with owner == group. Rephrase switch statement checking against unfiltered a_type value. (get_posix_access): Handle files with owner == group. * sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up CLASS_OBJ mask on old-style ACLs. Fix a comment. * sec_acl.cc (set_posix_access): Always make sure Admins have WRITE_DAC and WRITE_OWNER permissions. * security.h (create_object_sd_from_attribute): Drop handle parameter from prototype. * security.cc (create_object_sd_from_attribute): Drop handle parameter. Just create the standard POSIXy security descriptor. (set_object_attribute): Accommodate dropped paramter in call to create_object_sd_from_attribute. * fhandler_tty.cc: Ditto, throughout. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in mask computation. * fhandler.cc (fhandler_base::open_with_arch): Call open with mode not umasked. (fhandler_base::open): Explicitely umask mode on NFS here. Call new set_created_file_access rather than set_file_attribute. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement setting permissions on filesystems supporting ACLs using the new set_posix_access call. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::mkdir): Call new set_created_file_access rather than set_file_attribute. * fhandler_socket.cc (fhandler_socket::bind): Don't umask here. Add WRITE_OWNER access to allow writing group in case of SGID bit set. Call new set_created_file_access rather than set_file_attribute. * path.cc (symlink_worker): Call new set_created_file_access rather than set_file_attribute. * sec_acl.cc (searchace): Un-staticize. (set_posix_access): New, complementary functionality to get_posix_access. (setacl): Implement in terms of get_posix_access/set_posix_access. (get_posix_access): Add handling for just created files requiring their first Cygwin ACL. Fix new_style recognition. Handle SGID bit. For old-style ACLs, ignore SYSTEM and Administrators when computing the {DEF_}CLASS_OBJ perms. * security.cc (get_file_sd): Revamp comment. Change and (hopefully) speed up inheritance processing for just created files. (alloc_sd): Remove. (set_security_attribute): Call set_posix_a
[newlib-cygwin(refs/meta/config)] Revert "Allow merge commits on master."
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=37b4b8fa5e1385e507726857d4b2a1c39189332f commit 37b4b8fa5e1385e507726857d4b2a1c39189332f Author: Corinna Vinschen Date: Fri May 29 17:07:48 2015 +0200 Revert "Allow merge commits on master." This reverts commit 8e1d67017068e348ee80942b851b32b765499d91, only required temporarily. Diff: --- project.config | 5 + 1 file changed, 5 insertions(+) diff --git a/project.config b/project.config index 805efa5..8fced75 100644 --- a/project.config +++ b/project.config @@ -7,6 +7,11 @@ # debugging session, error messages, logs, etc. max-rh-line-length = 0 +# Reject merge commits on master: We request that people rebase +# their changes #before pushing instead (merge commits tend +# to confuse git newcommers). +reject-merge-commits = refs/heads/master + # The style checker, applied to the contents of each file being # modified. style-checker = /git/newlib-cygwin.git/hooks-bin/style_checker
[newlib-cygwin] Bump minor DLL version to 3
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=da1611493ad6c2ee7953577093d8dccab72d8abd commit da1611493ad6c2ee7953577093d8dccab72d8abd Author: Corinna Vinschen Date: Tue Jun 2 14:10:30 2015 +0200 Bump minor DLL version to 3 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/cygwin/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e2ada77..e1ce921 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-02 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 3. + 2015-05-28 Takashi Yano Corinna Vinschen diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index b9a09f5..7e1e77a 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -43,7 +43,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 2 +#define CYGWIN_VERSION_DLL_MINOR 3 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */
[newlib-cygwin] Add Cygwin 2.0.3 release file
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=64848af0bf44aa2ec7a230b9e89a4326bbb6c469 commit 64848af0bf44aa2ec7a230b9e89a4326bbb6c469 Author: Corinna Vinschen Date: Wed Jun 3 13:38:19 2015 +0200 Add Cygwin 2.0.3 release file Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.0.3 | 8 1 file changed, 8 insertions(+) diff --git a/winsup/cygwin/release/2.0.3 b/winsup/cygwin/release/2.0.3 new file mode 100644 index 000..9105907 --- /dev/null +++ b/winsup/cygwin/release/2.0.3 @@ -0,0 +1,8 @@ +Bug Fixes +- + +- Fix potential memory leak in argz_replace. + Addresses: https://sourceware.org/ml/newlib/2015/msg00417.html + +- Fix potential hang when accessing pty's in a certain way. + Addresses: https://cygwin.com/ml/cygwin/2015-05/msg00221.html
[newlib-cygwin] Created tag cygwin-2_0_3-release
The signed tag 'cygwin-2_0_3-release' was created pointing to: 64848af... Add Cygwin 2.0.3 release file Tagger: Corinna Vinschen Date: Wed Jun 3 13:39:25 2015 +0200 Cygwin 2.0.3 release
[newlib-cygwin] Bump minor DLL version to 4
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4c3946c350aa74ab36c5eea3f49a888ac0662561 commit 4c3946c350aa74ab36c5eea3f49a888ac0662561 Author: Corinna Vinschen Date: Mon Jun 8 13:58:39 2015 +0200 Bump minor DLL version to 4 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/cygwin/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index e1ce921..4a663af 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-08 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 4. + 2015-06-02 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 3. diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 7e1e77a..51d7b05 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -43,7 +43,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 3 +#define CYGWIN_VERSION_DLL_MINOR 4 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */
[newlib-cygwin] Generate SIGHUP for terminal process group on tty master close
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=511eb2f264c582ac753650b4848edae5b6d8c968 commit 511eb2f264c582ac753650b4848edae5b6d8c968 Author: Takashi Yano Date: Mon Jun 8 14:07:42 2015 +0200 Generate SIGHUP for terminal process group on tty master close * fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP into fhandler_pty_master::close(). (fhandler_pty_slave::read): Ditto. (fhandler_pty_master::close): Ditto. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/fhandler_tty.cc | 24 ++-- 2 files changed, 25 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4a663af..894094c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-08 Takashi Yano + + * fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP + into fhandler_pty_master::close(). + (fhandler_pty_slave::read): Ditto. + (fhandler_pty_master::close): Ditto. + 2015-06-08 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 4. diff --git a/winsup/cygwin/fhandler_tty.cc b/winsup/cygwin/fhandler_tty.cc index 1b5c18b..f22998f 100644 --- a/winsup/cygwin/fhandler_tty.cc +++ b/winsup/cygwin/fhandler_tty.cc @@ -622,7 +622,6 @@ fhandler_pty_slave::write (const void *ptr, size_t len) default: __seterrno_from_win_error (err); } - raise (SIGHUP); /* FIXME: Should this be SIGTTOU? */ towrite = -1; } return towrite; @@ -749,7 +748,12 @@ fhandler_pty_slave::read (void *ptr, size_t& len) goto out; } if (!bytes_available (bytes_in_pipe)) - raise (SIGHUP); + { + ReleaseMutex (input_mutex); + set_errno (EIO); + totalread = -1; + goto out; + } /* On first peek determine no. of bytes to flush. */ if (!ptr && len == UINT_MAX) @@ -779,9 +783,10 @@ fhandler_pty_slave::read (void *ptr, size_t& len) if (!ReadFile (get_handle (), buf, readlen, &n, NULL)) { termios_printf ("read failed, %E"); - raise (SIGHUP); - bytes_in_pipe = 0; - ptr = NULL; + ReleaseMutex (input_mutex); + set_errno (EIO); + totalread = -1; + goto out; } else { @@ -790,7 +795,12 @@ fhandler_pty_slave::read (void *ptr, size_t& len) change after successful read. So we have to peek into the pipe again to see if input is still available */ if (!bytes_available (bytes_in_pipe)) - raise (SIGHUP); + { + ReleaseMutex (input_mutex); + set_errno (EIO); + totalread = -1; + goto out; + } if (n) { len -= n; @@ -1269,6 +1279,8 @@ fhandler_pty_master::close () else if (obi.HandleCount == 1) { termios_printf("Closing last master of pty%d", get_minor ()); + if (get_ttyp ()->getsid () > 0) + kill (get_ttyp ()->getsid (), SIGHUP); SetEvent (input_available_event); }
[newlib-cygwin] Avoid delays trying to fetch Cygwin info from non-Cygwin processes
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=95868172f39e972dbcfad3e69fee7854eafe20dd commit 95868172f39e972dbcfad3e69fee7854eafe20dd Author: Corinna Vinschen Date: Mon Jun 8 14:38:30 2015 +0200 Avoid delays trying to fetch Cygwin info from non-Cygwin processes * pinfo.cc (_pinfo::commune_request): Don't try to send commune requests to non-Cygwin processes. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/pinfo.cc | 7 ++- winsup/cygwin/release/2.0.4 | 11 +++ 3 files changed, 22 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 894094c..c399935 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-06-08 Corinna Vinschen + + * pinfo.cc (_pinfo::commune_request): Don't try to send commune + requests to non-Cygwin processes. + 2015-06-08 Takashi Yano * fhandler_tty.cc (fhandler_pty_slave::write): Move causing of SIGHUP diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 4518d6d..4bebbbc 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -1,7 +1,7 @@ /* pinfo.cc: process table support Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, - 2008, 2009, 2010, 2011, 2012, 2013, 2014 Red Hat, Inc. + 2008, 2009, 2010, 2011, 2012, 2013, 2014, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -690,6 +690,11 @@ _pinfo::commune_request (__uint32_t code, ...) set_errno (ESRCH); goto err; } + if (ISSTATE (this, PID_NOTCYGWIN)) +{ + set_errno (ENOTSUP); + goto err; +} va_start (args, code); si._si_commune._si_code = code; diff --git a/winsup/cygwin/release/2.0.4 b/winsup/cygwin/release/2.0.4 new file mode 100644 index 000..c60cdd9 --- /dev/null +++ b/winsup/cygwin/release/2.0.4 @@ -0,0 +1,11 @@ +Bug Fixes +- + +- Handle SIGHUP in pty master close. + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00133.html +https://cygwin.com/ml/cygwin/2011-07/msg00295.html + +- Avoid fetching /proc process info from non-Cygwin processes. + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00133.html +https://cygwin.com/ml/cygwin/2015-05/msg00331.html +https://cygwin.com/ml/cygwin/2015-05/msg00314.html
[newlib-cygwin] Bind mounts require POSIX paths
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=117ebc802fe35dcaa404d52dda3437c09c817bef commit 117ebc802fe35dcaa404d52dda3437c09c817bef Author: Corinna Vinschen Date: Mon Jun 8 17:37:55 2015 +0200 Bind mounts require POSIX paths * path.cc (from_fstab_line): Don't convert slashes to backslashes for bind mounts. Explain why. Signed-off-by: Corinna Vinschen Diff: --- winsup/utils/ChangeLog | 5 + winsup/utils/path.cc | 9 +++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index bfdb42a..70fef4a 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,8 @@ +2015-06-08 Corinna Vinschen + + * path.cc (from_fstab_line): Don't convert slashes to backslashes for + bind mounts. Explain why. + 2015-04-21 Corinna Vinschen * tzmap-from-unicode.org: Convert Calcutta to Kolkata. diff --git a/winsup/utils/path.cc b/winsup/utils/path.cc index d1d01e9..e34741f 100644 --- a/winsup/utils/path.cc +++ b/winsup/utils/path.cc @@ -1,7 +1,7 @@ /* path.cc Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009, 2010, 2011, 2012, - 2013 Red Hat, Inc. + 2013, 2015 Red Hat, Inc. This file is part of Cygwin. @@ -443,7 +443,12 @@ from_fstab_line (mnt_t *m, char *line, bool user) return false; } m->posix = strdup (posix_path); - unconvert_slashes (native_path); + /* Bind mounts require POSIX paths, otherwise the path is wrongly +prefixed with the Cygwin root dir when trying to convert it to +a Win32 path in mount(2). So don't convert slashes to backslashes + in this case. */ + if (!(mount_flags & MOUNT_BIND)) + unconvert_slashes (native_path); m->native = strdup (native_path); m->flags = mount_flags; }
[newlib-cygwin] add bind mount fix to release notes
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=79511853f788111efd975651f87eabbd4a8cbf6d commit 79511853f788111efd975651f87eabbd4a8cbf6d Author: Corinna Vinschen Date: Mon Jun 8 17:48:34 2015 +0200 add bind mount fix to release notes Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.0.4 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/winsup/cygwin/release/2.0.4 b/winsup/cygwin/release/2.0.4 index c60cdd9..6fdccf0 100644 --- a/winsup/cygwin/release/2.0.4 +++ b/winsup/cygwin/release/2.0.4 @@ -9,3 +9,6 @@ Bug Fixes Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00133.html https://cygwin.com/ml/cygwin/2015-05/msg00331.html https://cygwin.com/ml/cygwin/2015-05/msg00314.html + +- Fix installing newly added bind mounts with `mount -a'. + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00150.html
[newlib-cygwin] Evaluate /proc/$PID/{root, cwd, cmdline} for native processes
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=575ec00a43ae3bbc84d5dab1233c3f95fdad18d0 commit 575ec00a43ae3bbc84d5dab1233c3f95fdad18d0 Author: Corinna Vinschen Date: Mon Jun 8 21:48:13 2015 +0200 Evaluate /proc/$PID/{root,cwd,cmdline} for native processes * pinfo.cc (_pinfo::root): Fake default root for native processes. (open_commune_proc_parms): New helper function to access process parameter block. (_pinfo::cwd): Fetch missing cwd for native processes from processes parameter block. (_pinfo::cmdline): Ditto for command line. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 9 + winsup/cygwin/pinfo.cc | 84 +++-- winsup/cygwin/release/2.0.4 | 4 +++ 3 files changed, 94 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index c399935..10717e3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,14 @@ 2015-06-08 Corinna Vinschen + * pinfo.cc (_pinfo::root): Fake default root for native processes. + (open_commune_proc_parms): New helper function to access process + parameter block. + (_pinfo::cwd): Fetch missing cwd for native processes from processes + parameter block. + (_pinfo::cmdline): Ditto for command line. + +2015-06-08 Corinna Vinschen + * pinfo.cc (_pinfo::commune_request): Don't try to send commune requests to non-Cygwin processes. diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index 4bebbbc..f7fd9f0 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -850,7 +850,7 @@ _pinfo::root (size_t& n) char *s; if (!this || !pid) return NULL; - if (pid != myself->pid) + if (pid != myself->pid && !ISSTATE (this, PID_NOTCYGWIN)) { commune_result cr = commune_request (PICOM_ROOT); s = cr.s; @@ -867,13 +867,60 @@ _pinfo::root (size_t& n) return s; } +static HANDLE +open_commune_proc_parms (DWORD pid, PRTL_USER_PROCESS_PARAMETERS prupp) +{ + HANDLE proc; + NTSTATUS status; + PROCESS_BASIC_INFORMATION pbi; + PEB lpeb; + + proc = OpenProcess (PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, FALSE, pid); + if (!proc) +return NULL; + status = NtQueryInformationProcess (proc, ProcessBasicInformation, + &pbi, sizeof pbi, NULL); + if (NT_SUCCESS (status) + && ReadProcessMemory (proc, pbi.PebBaseAddress, &lpeb, sizeof lpeb, NULL) + && ReadProcessMemory (proc, lpeb.ProcessParameters, prupp, sizeof *prupp, + NULL)) + return proc; + NtClose (proc); + return NULL; +} + char * _pinfo::cwd (size_t& n) { char *s; if (!this || !pid) return NULL; - if (pid != myself->pid) + if (ISSTATE (this, PID_NOTCYGWIN)) +{ + RTL_USER_PROCESS_PARAMETERS rupp; + HANDLE proc = open_commune_proc_parms (dwProcessId, &rupp); + + n = 0; + if (!proc) + return NULL; + + tmp_pathbuf tp; + PWCHAR cwd = tp.w_get (); + + if (ReadProcessMemory (proc, rupp.CurrentDirectoryName.Buffer, +cwd, rupp.CurrentDirectoryName.Length, +NULL)) + { + /* Drop trailing backslash, add trailing \0 in passing. */ + cwd[rupp.CurrentDirectoryName.Length / sizeof (WCHAR) - 1] + = L'\0'; + s = (char *) cmalloc_abort (HEAP_COMMUNE, NT_MAX_PATH); + mount_table->conv_to_posix_path (cwd, s, 0); + n = strlen (s) + 1; + } + NtClose (proc); +} + else if (pid != myself->pid) { commune_result cr = commune_request (PICOM_CWD); s = cr.s; @@ -894,7 +941,38 @@ _pinfo::cmdline (size_t& n) char *s; if (!this || !pid) return NULL; - if (pid != myself->pid) + if (ISSTATE (this, PID_NOTCYGWIN)) +{ + RTL_USER_PROCESS_PARAMETERS rupp; + HANDLE proc = open_commune_proc_parms (dwProcessId, &rupp); + + n = 0; + if (!proc) + return NULL; + + tmp_pathbuf tp; + PWCHAR cmdline = tp.w_get (); + + if (ReadProcessMemory (proc, rupp.CommandLine.Buffer, cmdline, +rupp.CommandLine.Length, NULL)) + { + /* Add trailing \0. */ + cmdline[rupp.CommandLine.Length / sizeof (WCHAR)] + = L'\0'; + n = sys_wcstombs_alloc (&s, HEAP_COMMUNE, cmdline, + rupp.CommandLine.Length + / sizeof (WCHAR)); + /* Quotes & Spaces post-processing. */ + bool in_quote = false; + for (char *c = s; *c; ++c) + if (*c == '"') + in_quote = !in_quote; + else if (*c == ' ' && !in_quote) +*c = '\0'
[newlib-cygwin] Avoid compiler warning in latest patch
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6261fb30a9780fae87d631c1da4d77efa43fe329 commit 6261fb30a9780fae87d631c1da4d77efa43fe329 Author: Corinna Vinschen Date: Mon Jun 8 21:55:11 2015 +0200 Avoid compiler warning in latest patch * pinfo.cc (_pinfo::cwd): Initialize s to avoid comiler warning. (_pinfo::cmdline): Ditto. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/pinfo.cc | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 10717e3..091fa32 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,10 @@ 2015-06-08 Corinna Vinschen + * pinfo.cc (_pinfo::cwd): Initialize s to avoid comiler warning. + (_pinfo::cmdline): Ditto. + +2015-06-08 Corinna Vinschen + * pinfo.cc (_pinfo::root): Fake default root for native processes. (open_commune_proc_parms): New helper function to access process parameter block. diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc index f7fd9f0..038937e 100644 --- a/winsup/cygwin/pinfo.cc +++ b/winsup/cygwin/pinfo.cc @@ -892,7 +892,7 @@ open_commune_proc_parms (DWORD pid, PRTL_USER_PROCESS_PARAMETERS prupp) char * _pinfo::cwd (size_t& n) { - char *s; + char *s = NULL; if (!this || !pid) return NULL; if (ISSTATE (this, PID_NOTCYGWIN)) @@ -938,7 +938,7 @@ _pinfo::cwd (size_t& n) char * _pinfo::cmdline (size_t& n) { - char *s; + char *s = NULL; if (!this || !pid) return NULL; if (ISSTATE (this, PID_NOTCYGWIN))
[newlib-cygwin] Created tag cygwin-2_0_4-release
The signed tag 'cygwin-2_0_4-release' was created pointing to: 6261fb3... Avoid compiler warning in latest patch Tagger: Corinna Vinschen Date: Tue Jun 9 12:09:59 2015 +0200 Cygwin 2.0.4 release
[newlib-cygwin] Drop Windows 2000 considerations in ps, fix uid field length
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=7701a023ff6e5861b0d875551070fa4df3e2525c commit 7701a023ff6e5861b0d875551070fa4df3e2525c Author: Corinna Vinschen Date: Wed Jun 10 11:07:27 2015 +0200 Drop Windows 2000 considerations in ps, fix uid field length * ps.cc (main): Widen UID field in long format to accommodate longer UIDs since Cygwin 1.7.34. Remove Windows 2000 considerations. Fix comments accordingly. Signed-off-by: Corinna Vinschen Diff: --- winsup/utils/ChangeLog | 6 ++ winsup/utils/ps.cc | 47 --- 2 files changed, 22 insertions(+), 31 deletions(-) diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 70fef4a..f9a25b2 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,9 @@ +2015-06-10 Corinna Vinschen + + * ps.cc (main): Widen UID field in long format to accommodate longer + UIDs since Cygwin 1.7.34. Remove Windows 2000 considerations. Fix + comments accordingly. + 2015-06-08 Corinna Vinschen * path.cc (from_fstab_line): Don't convert slashes to backslashes for diff --git a/winsup/utils/ps.cc b/winsup/utils/ps.cc index 952b63e..081fd6e 100644 --- a/winsup/utils/ps.cc +++ b/winsup/utils/ps.cc @@ -158,8 +158,8 @@ main (int argc, char *argv[]) const char *dfmt = "%7d%4s%10s %s\n"; const char *ftitle = " UID PIDPPID TTYSTIME COMMAND\n"; const char *ffmt = "%8.8s%8d%8d%4s%10s %s\n"; - const char *ltitle = " PIDPPIDPGID WINPID TTY UID STIME COMMAND\n"; - const char *lfmt = "%c %7d %7d %7d %10u %4s %4u %8s %s\n"; + const char *ltitle = " PIDPPIDPGID WINPID TTY UID STIME COMMAND\n"; + const char *lfmt = "%c %7d %7d %7d %10u %4s %8u %8s %s\n"; char ch; PUNICODE_STRING uni = (PUNICODE_STRING) unicode_buf; void *drive_map = NULL; @@ -259,27 +259,15 @@ main (int argc, char *argv[]) version.dwOSVersionInfoSize = sizeof version; GetVersionEx (&version); if (version.dwMajorVersion <= 5) /* pre-Vista */ - { - proc_access = PROCESS_QUERY_INFORMATION; - if (version.dwMinorVersion < 1) /* Windows 2000 */ - proc_access |= PROCESS_VM_READ; - else - { - } - } - - /* Except on Windows 2000, fetch an opaque drive mapping object from the -Cygwin DLL. This is used to map NT device paths to Win32 paths. */ - if (!(proc_access & PROCESS_VM_READ)) - { - drive_map = (void *) cygwin_internal (CW_ALLOC_DRIVE_MAP); - /* Check old Cygwin version. */ - if (drive_map == (void *) -1) - drive_map = NULL; - /* Allow fallback to GetModuleFileNameEx for post-W2K. */ - if (!drive_map) - proc_access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; - } + proc_access = PROCESS_QUERY_INFORMATION; + + drive_map = (void *) cygwin_internal (CW_ALLOC_DRIVE_MAP); + /* Check old Cygwin version. */ + if (drive_map == (void *) -1) + drive_map = NULL; + /* Allow fallback to GetModuleFileNameEx. */ + if (!drive_map) + proc_access = PROCESS_QUERY_INFORMATION | PROCESS_VM_READ; } for (int pid = 0; @@ -332,9 +320,9 @@ main (int argc, char *argv[]) if (!h) continue; /* We use NtQueryInformationProcess in the first place, because -GetModuleFileNameEx does not work on 64 bit systems when trying +GetModuleFileNameEx does not work under WOW64 when trying to fetch module names of 64 bit processes. */ - if (!(proc_access & PROCESS_VM_READ)) /* Windows 2000 */ + if (!(proc_access & PROCESS_VM_READ)) { status = NtQueryInformationProcess (h, ProcessImageFileName, uni, sizeof unicode_buf, NULL); @@ -358,12 +346,9 @@ main (int argc, char *argv[]) } } } - else - { - if (GetModuleFileNameExW (h, NULL, (PWCHAR) unicode_buf, - NT_MAX_PATH)) - win32path = (wchar_t *) unicode_buf; - } + else if (GetModuleFileNameExW (h, NULL, (PWCHAR) unicode_buf, +NT_MAX_PATH)) + win32path = (wchar_t *) unicode_buf; if (win32path) wcstombs (pname, win32path, sizeof pname); else
[newlib-cygwin] Bump minor DLL version to 5
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=5979b17401205d9165f1f030c906ef97a29d7ff5 commit 5979b17401205d9165f1f030c906ef97a29d7ff5 Author: Corinna Vinschen Date: Thu Jun 11 12:59:00 2015 +0200 Bump minor DLL version to 5 Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 4 winsup/cygwin/include/cygwin/version.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 091fa32..86a5414 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-11 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 4. + 2015-06-08 Corinna Vinschen * pinfo.cc (_pinfo::cwd): Initialize s to avoid comiler warning. diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 51d7b05..8305b07 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -43,7 +43,7 @@ details. */ changes to the DLL and is mainly informative in nature. */ #define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 4 +#define CYGWIN_VERSION_DLL_MINOR 5 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */
[newlib-cygwin] Fix ChangeLog entry
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b81a830f1a3abba09aa6380141bd63200446ca8d commit b81a830f1a3abba09aa6380141bd63200446ca8d Author: Corinna Vinschen Date: Thu Jun 11 15:39:34 2015 +0200 Fix ChangeLog entry Diff: --- winsup/cygwin/ChangeLog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 86a5414..8b6ed6a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,6 +1,6 @@ 2015-06-11 Corinna Vinschen - * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 4. + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 5. 2015-06-08 Corinna Vinschen
[newlib-cygwin] Don't enforce SA_RESTART in non-main threads
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=95c5a3f6b7821366bec548844ab1bbd63737bf13 commit 95c5a3f6b7821366bec548844ab1bbd63737bf13 Author: Corinna Vinschen Date: Mon Jun 15 16:15:37 2015 +0200 Don't enforce SA_RESTART in non-main threads * exceptions.cc (_cygtls::call_signal_handler): Disable enforcing SA_RESTART in non-main threads to allow returning with EINTR from system calls. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 ++ winsup/cygwin/exceptions.cc | 7 ++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 8b6ed6a..1eafa28 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,9 @@ +2015-06-15 Corinna Vinschen + + * exceptions.cc (_cygtls::call_signal_handler): Disable enforcing + SA_RESTART in non-main threads to allow returning with EINTR from + system calls. + 2015-06-11 Corinna Vinschen * include/cygwin/version.h (CYGWIN_VERSION_DLL_MINOR): Bump to 5. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 4a6c21e..7ecac23 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1542,7 +1542,12 @@ _cygtls::call_signal_handler () set_errno (this_errno); } - return this_sa_flags & SA_RESTART || (this != _main_tls); + /* FIXME: Since 2011 this return statement always returned 1 (meaning + SA_RESTART is effective) if the thread we're running in is not the + main thread. We're disabling this check to enable EINTR behaviour + on system calls not running in the main thread. It's not quite clear + if that has undesired side-effects, therefore this comment. */ + return this_sa_flags & SA_RESTART; } void
[newlib-cygwin] Handle more Winsock error codes.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6f9e2f3ed5ee1364dab6a47c604a6d7d370aab5c commit 6f9e2f3ed5ee1364dab6a47c604a6d7d370aab5c Author: Corinna Vinschen Date: Mon Jun 15 16:17:16 2015 +0200 Handle more Winsock error codes. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/net.cc| 3 +++ 2 files changed, 7 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 1eafa28..bb6da15 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,9 @@ 2015-06-15 Corinna Vinschen + * net.cc (errmap): Handle more Winsock error codes. + +2015-06-15 Corinna Vinschen + * exceptions.cc (_cygtls::call_signal_handler): Disable enforcing SA_RESTART in non-main threads to allow returning with EINTR from system calls. diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index e94eb50..ae86129 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -169,6 +169,9 @@ struct tl }; static const struct tl errmap[] = { + {WSA_INVALID_HANDLE, "WSA_INVALID_HANDLE", EBADF}, + {WSA_NOT_ENOUGH_MEMORY, "WSA_NOT_ENOUGH_MEMORY", ENOMEM}, + {WSA_INVALID_PARAMETER, "WSA_INVALID_PARAMETER", EINVAL}, {WSAEINTR, "WSAEINTR", EINTR}, {WSAEWOULDBLOCK, "WSAEWOULDBLOCK", EWOULDBLOCK}, {WSAEINPROGRESS, "WSAEINPROGRESS", EINPROGRESS},
[newlib-cygwin] Try to handle concurrent close on socket more gracefully
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=79d65a1ed2eccd7c9c280895b8dc99ff7112b3c0 commit 79d65a1ed2eccd7c9c280895b8dc99ff7112b3c0 Author: Corinna Vinschen Date: Mon Jun 15 18:29:56 2015 +0200 Try to handle concurrent close on socket more gracefully * fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with invalid mutex handle since then socket has been closed. (UNLOCK_EVENTS): Close critical section. (fhandler_socket::evaluate_events): Handle calling connect on shutdown socket. (fhandler_socket::wait_for_events): Try for pthread_testcancel in case of WAIT_FAILED. Try to come up with a better errno in case we waited on an invalid handle. (fhandler_socket::release_events): Change wsock_mtx and wsock_evt to NULL under lock to avoid accessing invalid handle. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 13 ++ winsup/cygwin/fhandler_socket.cc | 54 +--- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index bb6da15..062b065 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,18 @@ 2015-06-15 Corinna Vinschen + * fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with + invalid mutex handle since then socket has been closed. + (UNLOCK_EVENTS): Close critical section. + (fhandler_socket::evaluate_events): Handle calling connect on shutdown + socket. + (fhandler_socket::wait_for_events): Try for pthread_testcancel in case + of WAIT_FAILED. Try to come up with a better errno in case we waited + on an invalid handle. + (fhandler_socket::release_events): Change wsock_mtx and wsock_evt to + NULL under lock to avoid accessing invalid handle. + +2015-06-15 Corinna Vinschen + * net.cc (errmap): Handle more Winsock error codes. 2015-06-15 Corinna Vinschen diff --git a/winsup/cygwin/fhandler_socket.cc b/winsup/cygwin/fhandler_socket.cc index 1b28e52..48f9aeb 100644 --- a/winsup/cygwin/fhandler_socket.cc +++ b/winsup/cygwin/fhandler_socket.cc @@ -501,8 +501,14 @@ fhandler_socket::af_local_set_secret (char *buf) counted as one socket. */ #define NUM_SOCKS (32768 / sizeof (wsa_event)) -#define LOCK_EVENTSWaitForSingleObject (wsock_mtx, INFINITE) -#define UNLOCK_EVENTS ReleaseMutex (wsock_mtx) +#define LOCK_EVENTS\ + if (wsock_mtx && \ + WaitForSingleObject (wsock_mtx, INFINITE) != WAIT_FAILED) \ +{ + +#define UNLOCK_EVENTS \ + ReleaseMutex (wsock_mtx); \ +} static wsa_event wsa_events[NUM_SOCKS] __attribute__((section (".cygwin_dll_common"), shared)); @@ -709,14 +715,21 @@ fhandler_socket::evaluate_events (const long event_mask, long &events, wsock_events->events &= ~FD_CONNECT; wsock_events->connect_errorcode = 0; } - /* This test makes the accept function behave as on Linux when -accept is called on a socket for which shutdown for the read side -has been called. The second half of this code is in the shutdown -method. See there for more info. */ - if ((event_mask & FD_ACCEPT) && (events & FD_CLOSE)) + /* This test makes accept/connect behave as on Linux when accept/connect + is called on a socket for which shutdown has been called. The second +half of this code is in the shutdown method. */ + if (events & FD_CLOSE) { - WSASetLastError (WSAEINVAL); - ret = SOCKET_ERROR; + if ((event_mask & FD_ACCEPT) && saw_shutdown_read ()) + { + WSASetLastError (WSAEINVAL); + ret = SOCKET_ERROR; + } + if (event_mask & FD_CONNECT) + { + WSASetLastError (WSAECONNRESET); + ret = SOCKET_ERROR; + } } if (erase) wsock_events->events &= ~(events & ~(FD_WRITE | FD_CLOSE)); @@ -750,7 +763,8 @@ fhandler_socket::wait_for_events (const long event_mask, const DWORD flags) { case WSA_WAIT_TIMEOUT: pthread_testcancel (); - /*FALLTHRU*/ + break; + case WSA_WAIT_EVENT_0: break; @@ -761,19 +775,31 @@ fhandler_socket::wait_for_events (const long event_mask, const DWORD flags) return SOCKET_ERROR; default: - WSASetLastError (WSAEFAULT); + pthread_testcancel (); + /* wsock_evt can be NULL. We're generating the same errno values + as for sockets on which shutdown has been called. */ + if (WSAGetLastError () != WSA_INVALID_HANDLE) + WSASetLastError (WSAEFAULT); + else + WSASetLastError ((event_mask &
[newlib-cygwin] Add release/2.0.5 file
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c7af199237810f2d6d626aa73446f4f4387212e8 commit c7af199237810f2d6d626aa73446f4f4387212e8 Author: Corinna Vinschen Date: Wed Jun 17 10:37:10 2015 +0200 Add release/2.0.5 file Diff: --- winsup/cygwin/release/2.0.5 | 16 1 file changed, 16 insertions(+) diff --git a/winsup/cygwin/release/2.0.5 b/winsup/cygwin/release/2.0.5 new file mode 100644 index 000..9f26a8a --- /dev/null +++ b/winsup/cygwin/release/2.0.5 @@ -0,0 +1,16 @@ +What's new: +--- + + +What changed: +- + + +Bug Fixes +- + +- Enable non-SA_RESTART behaviour on threads other than main thread. + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00260.html + +- Try to handle concurrent close on socket more gracefully + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00235.html
[newlib-cygwin] Add sethostname
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=50b00d2b936c937099c24d6fa1f0b6f642462900 commit 50b00d2b936c937099c24d6fa1f0b6f642462900 Author: Corinna Vinschen Date: Wed Jun 17 11:11:02 2015 +0200 Add sethostname * net.cc (sethostname): New function. * common.din (sethostname): Export * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001. (CYGWIN_VERSION_DLL_MINOR): Set to 0. * new-features.xml (ov-new): Rename from ov-new1.7. (ov-new2.1): Add new section. Document sethostname. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 7 +++ winsup/cygwin/common.din | 1 + winsup/cygwin/include/cygwin/version.h | 4 ++-- winsup/cygwin/net.cc | 14 ++ winsup/cygwin/release/{2.0.5 => 2.1.0} | 2 ++ winsup/doc/ChangeLog | 5 + winsup/doc/new-features.xml| 14 +- 7 files changed, 44 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 062b065..58a3821 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-17 Corinna Vinschen + + * net.cc (sethostname): New function. + * common.din (sethostname): Export + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2001. + (CYGWIN_VERSION_DLL_MINOR): Set to 0. + 2015-06-15 Corinna Vinschen * fhandler_socket.cc (LOCK_EVENTS): Don't enter critical section with diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index f14b331..dd9bb25 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -1054,6 +1054,7 @@ sendmsg = cygwin_sendmsg SIGFE sendto = cygwin_sendto SIGFE setbuf SIGFE setbuffer SIGFE +sethostname SIGFE setdtablesize SIGFE setegid SIGFE setenv SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 8305b07..3d5d4de 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -42,8 +42,8 @@ details. */ the Cygwin shared library". This version is used to track important changes to the DLL and is mainly informative in nature. */ -#define CYGWIN_VERSION_DLL_MAJOR 2000 -#define CYGWIN_VERSION_DLL_MINOR 5 +#define CYGWIN_VERSION_DLL_MAJOR 2001 +#define CYGWIN_VERSION_DLL_MINOR 0 /* Major numbers before CYGWIN_VERSION_DLL_EPOCH are incompatible. */ diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index ae86129..20b4d3c 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -1095,6 +1095,20 @@ cygwin_gethostname (char *name, size_t len) return res; } +extern "C" int +sethostname (const char *name, size_t len) +{ + WCHAR wname[MAX_COMPUTERNAME_LENGTH + 1]; + + sys_mbstowcs (wname, MAX_COMPUTERNAME_LENGTH + 1, name, len); + if (!SetComputerNameExW (ComputerNamePhysicalDnsHostname, wname)) +{ + __seterrno (); + return -1; +} + return 0; +} + /* exported as gethostbyname: standards? */ extern "C" struct hostent * cygwin_gethostbyname (const char *name) diff --git a/winsup/cygwin/release/2.0.5 b/winsup/cygwin/release/2.1.0 similarity index 93% rename from winsup/cygwin/release/2.0.5 rename to winsup/cygwin/release/2.1.0 index 9f26a8a..5680cb3 100644 --- a/winsup/cygwin/release/2.0.5 +++ b/winsup/cygwin/release/2.1.0 @@ -1,6 +1,8 @@ What's new: --- +- New API: sethostname. + What changed: - diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 6f1b01a..02bf22e 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-06-17 Corinna Vinschen + + * new-features.xml (ov-new): Rename from ov-new1.7. + (ov-new2.1): Add new section. Document sethostname. + 2015-06-12 Jon Turney * Makefile.in (install-man, utils2man.stamp): Add rules to build diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml index 2d0ed0b..6edde24 100644 --- a/winsup/doc/new-features.xml +++ b/winsup/doc/new-features.xml @@ -2,7 +2,19 @@ http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd";> -What's new and what changed in Cygwin +What's new and what changed in Cygwin + +What's new and what changed in 2.1 + + + + +New API: sethostname. + + + + + What's new and what changed in 2.0
[newlib-cygwin] Add sethostname to API list
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e4bdbca6ebf090e5d22803298356e31b3133a060 commit e4bdbca6ebf090e5d22803298356e31b3133a060 Author: Corinna Vinschen Date: Wed Jun 17 11:22:14 2015 +0200 Add sethostname to API list Signed-off-by: Corinna Vinschen Diff: --- winsup/doc/ChangeLog | 4 winsup/doc/posix.xml | 1 + 2 files changed, 5 insertions(+) diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 02bf22e..f350c48 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,5 +1,9 @@ 2015-06-17 Corinna Vinschen + * posix.xml (std-bsd): Add sethostname. + +2015-06-17 Corinna Vinschen + * new-features.xml (ov-new): Rename from ov-new1.7. (ov-new2.1): Add new section. Document sethostname. diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml index 95bc400..fa5b173 100644 --- a/winsup/doc/posix.xml +++ b/winsup/doc/posix.xml @@ -1091,6 +1091,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). sbrk setbuffer setgroups +sethostname setlinebuf setpassent setprogname
[newlib-cygwin] Disallow installing "man pages" from release subdir
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0d3304af3806a28d7756fba9d4eb714339c3eaf1 commit 0d3304af3806a28d7756fba9d4eb714339c3eaf1 Author: Corinna Vinschen Date: Thu Jun 18 22:04:58 2015 +0200 Disallow installing "man pages" from release subdir * Makefile.in (install-man): Exclude release subdir from search paths. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/Makefile.in | 8 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 58a3821..5229f0c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-18 Corinna Vinschen + + * Makefile.in (install-man): Exclude release subdir from search paths. + 2015-06-17 Corinna Vinschen * net.cc (sethostname): New function. diff --git a/winsup/cygwin/Makefile.in b/winsup/cygwin/Makefile.in index d827754..271a5be 100644 --- a/winsup/cygwin/Makefile.in +++ b/winsup/cygwin/Makefile.in @@ -505,16 +505,16 @@ install-headers: install-man: @$(MKDIRP) $(DESTDIR)$(mandir)/man2 $(DESTDIR)$(mandir)/man3 $(DESTDIR)$(mandir)/man5 $(DESTDIR)$(mandir)/man7 cd $(srcdir); \ - for i in `find . -type f -name '*.2'`; do \ + for i in `find . -type f ! -path './release/*' -name '*.2'`; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man2/`basename $$i` ; \ done; \ - for i in `find . -type f -name '*.3'`; do \ + for i in `find . -type f ! -path './release/*' -name '*.3'`; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man3/`basename $$i` ; \ done; \ - for i in `find . -type f -name '*.5'`; do \ + for i in `find . -type f ! -path './release/*' -name '*.5'`; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man5/`basename $$i` ; \ done; \ - for i in `find . -type f -name '*.7'`; do \ + for i in `find . -type f ! -path './release/*' -name '*.7'`; do \ $(INSTALL_DATA) $$i $(DESTDIR)$(mandir)/man7/`basename $$i` ; \ done
[newlib-cygwin] Formatting fixes in exceptions.cc
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=715ac1e872e495496f9a540a75e8b1f4cbcdf321 commit 715ac1e872e495496f9a540a75e8b1f4cbcdf321 Author: Corinna Vinschen Date: Fri Jun 19 16:12:10 2015 +0200 Formatting fixes in exceptions.cc * Makefile.in (install-man): Exclude release subdir from search paths. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 ++ winsup/cygwin/exceptions.cc | 100 2 files changed, 67 insertions(+), 37 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 5229f0c..464ca32 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-19 Corinna Vinschen + + * exceptions.cc: Minor formatting fixes. + 2015-06-18 Corinna Vinschen * Makefile.in (install-man): Exclude release subdir from search paths. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 7ecac23..27b571e 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -194,10 +194,14 @@ cygwin_exception::dump_exception () small_printf ("Exception: %s at rip=%011X\r\n", exception_name, ctx->Rip); else small_printf ("Signal %d at rip=%011X\r\n", e->ExceptionCode, ctx->Rip); - small_printf ("rax=%016X rbx=%016X rcx=%016X\r\n", ctx->Rax, ctx->Rbx, ctx->Rcx); - small_printf ("rdx=%016X rsi=%016X rdi=%016X\r\n", ctx->Rdx, ctx->Rsi, ctx->Rdi); - small_printf ("r8 =%016X r9 =%016X r10=%016X\r\n", ctx->R8, ctx->R9, ctx->R10); - small_printf ("r11=%016X r12=%016X r13=%016X\r\n", ctx->R11, ctx->R12, ctx->R13); + small_printf ("rax=%016X rbx=%016X rcx=%016X\r\n", + ctx->Rax, ctx->Rbx, ctx->Rcx); + small_printf ("rdx=%016X rsi=%016X rdi=%016X\r\n", + ctx->Rdx, ctx->Rsi, ctx->Rdi); + small_printf ("r8 =%016X r9 =%016X r10=%016X\r\n", + ctx->R8, ctx->R9, ctx->R10); + small_printf ("r11=%016X r12=%016X r13=%016X\r\n", + ctx->R11, ctx->R12, ctx->R13); small_printf ("r14=%016X r15=%016X\r\n", ctx->R14, ctx->R15); small_printf ("rbp=%016X rsp=%016X\r\n", ctx->Rbp, ctx->Rsp); small_printf ("program=%W, pid %u, thread %s\r\n", @@ -214,7 +218,8 @@ cygwin_exception::dump_exception () cygthread::name ()); #endif small_printf ("cs=%04x ds=%04x es=%04x fs=%04x gs=%04x ss=%04x\r\n", - ctx->SegCs, ctx->SegDs, ctx->SegEs, ctx->SegFs, ctx->SegGs, ctx->SegSs); + ctx->SegCs, ctx->SegDs, ctx->SegEs, ctx->SegFs, + ctx->SegGs, ctx->SegSs); } /* A class for manipulating the stack. */ @@ -417,7 +422,8 @@ _cygtls::inside_kernel (CONTEXT *cx) can hang */ else if (h == user_data->hmodule) res = false; - else if (!GetModuleFileNameW (h, checkdir, windows_system_directory_length + 6)) + else if (!GetModuleFileNameW (h, checkdir, + windows_system_directory_length + 6)) res = false; else { @@ -464,13 +470,15 @@ try_to_debug (bool waitloop) return 0; } - __small_sprintf (strchr (debugger_command, '\0'), " %u", GetCurrentProcessId ()); + __small_sprintf (strchr (debugger_command, '\0'), " %u", + GetCurrentProcessId ()); LONG prio = GetThreadPriority (GetCurrentThread ()); SetThreadPriority (GetCurrentThread (), THREAD_PRIORITY_HIGHEST); PROCESS_INFORMATION pi = {NULL, 0, 0, 0}; - STARTUPINFOW si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL}; + STARTUPINFOW si = {0, NULL, NULL, NULL, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +NULL, NULL, NULL, NULL}; si.lpReserved = NULL; si.lpDesktop = NULL; si.dwFlags = 0; @@ -544,7 +552,9 @@ try_to_debug (bool waitloop) exception handler. */ #define rtl_unwind(el,er) #else -static void __reg3 rtl_unwind (exception_list *, PEXCEPTION_RECORD) __attribute__ ((noinline, regparm (3))); +static void __reg3 rtl_unwind (exception_list *, PEXCEPTION_RECORD) + __attribute__ ((noinline, regparm (3))); + void __reg3 rtl_unwind (exception_list *frame, PEXCEPTION_RECORD e) { @@ -714,8 +724,10 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, return ExceptionContinueSearch; } - debug_printf ("In cygwin_except_handler exception %y at %p sp %p", e->ExceptionCode, in->_GR(ip), in->_GR(sp)); - debug_printf ("In cygwin_except_handler signal %d at %p", si.si_signo, in->_GR(ip)); + debug_printf ("In cygwin_except_handler exception %y at %p sp %p", +
[newlib-cygwin] Preliminary infrastructure to implement alternate stack
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=22465796edbfd6f156ca2930f56b3345cc54b164 commit 22465796edbfd6f156ca2930f56b3345cc54b164 Author: Corinna Vinschen Date: Fri Jun 19 15:58:23 2015 +0200 Preliminary infrastructure to implement alternate stack * libc/include/sys/signal.h: Define SS_ONSTACK and SS_DISABLE unconditionally. (sigaltstack): Enable prototype on Cygwin. * common.din (sigaltstack): Export. * cygtls.cc (_cygtls::init_thread): Initialize altstack. * cygtls.h (__tlsstack_t): Rename from __stack_t to distinguish more clearly from stack_t. Accommodate throughout. (_cygtls): Add altstack member. * exceptions.cc (exception::handle): Set SIGSEGV handler to SIG_DFL if we encounter a stack overflow, and no alternate stack has been defined. * include/cygwin/signal.h (MINSIGSTKSZ): Define (SIGSTKSZ): Define. (SA_ONSTACK): Define. * signal.cc (sigaltstack): New function. * tlsoffset.h: Regenerate. * tlsoffset64.h: Ditto. Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/include/sys/signal.h | 13 ++-- winsup/cygwin/common.din | 1 + winsup/cygwin/cygtls.cc | 1 + winsup/cygwin/cygtls.h| 13 ++-- winsup/cygwin/exceptions.cc | 14 +++- winsup/cygwin/include/cygwin/signal.h | 6 ++ winsup/cygwin/signal.cc | 40 +- winsup/cygwin/tlsoffsets.h| 140 +- winsup/cygwin/tlsoffsets64.h | 140 +- 9 files changed, 215 insertions(+), 153 deletions(-) diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h index 6ff758c..f2087fe 100644 --- a/newlib/libc/include/sys/signal.h +++ b/newlib/libc/include/sys/signal.h @@ -120,11 +120,6 @@ struct sigaction { #defineSIGSTKSZ8192 #endif -/* - * Possible values for ss_flags in stack_t below. - */ -#defineSS_ONSTACK 0x1 -#defineSS_DISABLE 0x2 #endif #elif defined(__CYGWIN__) @@ -143,6 +138,12 @@ struct sigaction #endif /* defined(__rtems__) */ /* + * Possible values for ss_flags in stack_t below. + */ +#defineSS_ONSTACK 0x1 +#defineSS_DISABLE 0x2 + +/* * Structure used in sigaltstack call. */ typedef struct sigaltstack { @@ -196,7 +197,7 @@ int _EXFUN(sigpending, (sigset_t *)); int _EXFUN(sigsuspend, (const sigset_t *)); int _EXFUN(sigpause, (int)); -#ifdef __rtems__ +#if defined(__CYGWIN__) || defined(__rtems__) #if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 int _EXFUN(sigaltstack, (const stack_t *__restrict, stack_t *__restrict)); #endif diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index dd9bb25..644eb2e 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -1099,6 +1099,7 @@ shmget SIGFE shutdown = cygwin_shutdown SIGFE sigaction SIGFE sigaddset SIGFE +sigaltstack SIGFE sigdelset SIGFE sigemptyset NOSIGFE sigfillset NOSIGFE diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index 84170ca..dc9a698 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -125,6 +125,7 @@ _cygtls::init_thread (void *x, DWORD (*func) (void *, void *)) memset (this, 0, sizeof (*this)); _REENT_INIT_PTR (&local_clib); stackptr = stack; + altstack.ss_flags = SS_DISABLE; if (_GLOBAL_REENT) { local_clib._stdin = _GLOBAL_REENT->_stdin; diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 97e403d..0944811 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -167,7 +167,7 @@ extern "C" int __ljfault (jmp_buf, int); /*gentls_offsets*/ -typedef uintptr_t __stack_t; +typedef uintptr_t __tlsstack_t; class _cygtls { @@ -188,6 +188,7 @@ public: int *errno_addr; sigset_t sigmask; sigset_t sigwait_mask; + stack_t altstack; siginfo_t *sigwait_info; HANDLE signal_arrived; bool will_wait_for_signal; @@ -202,17 +203,17 @@ public: unsigned incyg; unsigned spinning; unsigned stacklock; - __stack_t *stackptr; - __stack_t stack[TLS_STACK_SIZE]; + __tlsstack_t *stackptr; + __tlsstack_t stack[TLS_STACK_SIZE]; unsigned initialized; /*gentls_offsets*/ void init_thread (void *, DWORD (*) (void *, void *)); static void call (DWORD (*) (void *, void *), void *); void remove (DWORD); - void push (__stack_t addr) {*stackptr++ = (__stack_t) addr;} - __stack_t __reg1 pop (); - __stack_t retaddr () {return stackptr[-1];} + void push (__tlsstack_t addr) {*stackptr++ = (__tlsstack_t) addr;} + __tlsstack_t __reg1 pop (); + __tlsstack_t retaddr () {return stackptr[-1];} bool isinitialized () const { return initialized == CYGTLS_INITIALIZED; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/excepti
[newlib-cygwin] Handle exceptions in sigaltstack
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=74d272cc0272d89b9735d9a549102170fab37333 commit 74d272cc0272d89b9735d9a549102170fab37333 Author: Corinna Vinschen Date: Sat Jun 20 18:48:09 2015 +0200 Handle exceptions in sigaltstack * signal.cc (sigaltstack): Add fault handler. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/signal.cc | 56 ++--- 1 file changed, 35 insertions(+), 21 deletions(-) diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 7cb668c..94faaf3 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -630,35 +630,49 @@ sigaltstack (const stack_t *ss, stack_t *oss) { _cygtls& me = _my_tls; - if (ss) + __try { - if (me.altstack.ss_flags == SS_ONSTACK) - { - set_errno (EPERM); - return -1; - } - if (ss->ss_flags == SS_DISABLE) - { - me.altstack.ss_sp = NULL; - me.altstack.ss_flags = 0; - me.altstack.ss_size = 0; - } - else + if (ss) { - if (ss->ss_flags) + if (me.altstack.ss_flags == SS_ONSTACK) { - set_errno (EINVAL); + /* An attempt was made to modify an active stack. */ + set_errno (EPERM); return -1; } - if (ss->ss_size < MINSIGSTKSZ) + if (ss->ss_flags == SS_DISABLE) { - set_errno (ENOMEM); - return -1; + me.altstack.ss_sp = NULL; + me.altstack.ss_flags = 0; + me.altstack.ss_size = 0; + } + else + { + if (ss->ss_flags) + { + /* The ss argument is not a null pointer, and the ss_flags +member pointed to by ss contains flags other than +SS_DISABLE. */ + set_errno (EINVAL); + return -1; + } + if (ss->ss_size < MINSIGSTKSZ) + { + /* The size of the alternate stack area is less than +MINSIGSTKSZ. */ + set_errno (ENOMEM); + return -1; + } + memcpy (&me.altstack, ss, sizeof *ss); } - memcpy (&me.altstack, ss, sizeof *ss); } + if (oss) + memcpy (oss, &me.altstack, sizeof *oss); } - if (oss) -memcpy (oss, &me.altstack, sizeof *oss); + __except (EFAULT) +{ + return EFAULT; +} + __endtry return 0; }
[newlib-cygwin] Implement using alternate signal stack in Cygwin
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0cbf19283b1d82a6ad2bed51674cea56cea5c31c commit 0cbf19283b1d82a6ad2bed51674cea56cea5c31c Author: Corinna Vinschen Date: Sat Jun 20 20:21:02 2015 +0200 Implement using alternate signal stack in Cygwin * exceptions.cc (_cygtls::call_signal_handler): Implement alternate signal stack handling. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/exceptions.cc | 121 +++- 1 file changed, 108 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 112d792..895d57f 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1537,19 +1537,26 @@ _cygtls::call_signal_handler () RtlCaptureContext ((CONTEXT *) &context.uc_mcontext); } - /* FIXME: If/when sigaltstack is implemented, this will need to do -something more complicated */ - context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; - context.uc_stack.ss_flags = 0; - if (!NtCurrentTeb ()->DeallocationStack) - context.uc_stack.ss_size - = (uintptr_t) NtCurrentTeb ()->Tib.StackLimit - - (uintptr_t) NtCurrentTeb ()->Tib.StackBase; + if (this_sa_flags & SA_ONSTACK + && !_my_tls.altstack.ss_flags + && _my_tls.altstack.ss_sp) + { + context.uc_stack = _my_tls.altstack; + context.uc_stack.ss_flags = SS_ONSTACK; + } else - context.uc_stack.ss_size - = (uintptr_t) NtCurrentTeb ()->DeallocationStack - - (uintptr_t) NtCurrentTeb ()->Tib.StackBase; - + { + context.uc_stack.ss_sp = NtCurrentTeb ()->Tib.StackBase; + context.uc_stack.ss_flags = 0; + if (!NtCurrentTeb ()->DeallocationStack) + context.uc_stack.ss_size + = (uintptr_t) NtCurrentTeb ()->Tib.StackLimit + - (uintptr_t) NtCurrentTeb ()->Tib.StackBase; + else + context.uc_stack.ss_size + = (uintptr_t) NtCurrentTeb ()->DeallocationStack + - (uintptr_t) NtCurrentTeb ()->Tib.StackBase; + } context.uc_sigmask = context.uc_mcontext.oldmask = this_oldmask; context.uc_mcontext.cr2 = (thissi.si_signo == SIGSEGV @@ -1565,7 +1572,95 @@ _cygtls::call_signal_handler () sig = 0; /* Flag that we can accept another signal */ unlock (); /* unlock signal stack */ - thisfunc (thissig, &thissi, thiscontext); + /* Alternate signal stack requested for this signal and alternate signal +stack set up for this thread? */ + if (this_sa_flags & SA_ONSTACK + && !_my_tls.altstack.ss_flags + && _my_tls.altstack.ss_sp) + { + /* Yes, use alternate signal stack. + + NOTE: + + We DO NOT change the TEB's stack addresses and we DO NOT move the + _cygtls area to the alternate stack. This seems to work fine on + 32 and 64 bit, but there may be Windows functions not working + correctly under these circumstances. Especially 32 bit exception + handling may be broken. + + On the other hand, if a Windows function crashed and we're handling + this here, moving the TEB stack addresses may be fatal. + + If the current code does not work as expected in the "usual" + POSIX circumstances, this problem must be revisited. */ + + /* Compute new stackbase. We start from the high address, subtract +16 bytes (safe/sorry) and align to 16 byte. */ + uintptr_t new_sp = (uintptr_t) _my_tls.altstack.ss_sp ++ _my_tls.altstack.ss_size - 0x10; + new_sp &= ~0xf; + /* Mark alternate stack as used. */ + _my_tls.altstack.ss_flags = SS_ONSTACK; + /* Move to alternate stack, call thisfunc, revert stack regs. */ +#ifdef __x86_64__ + __asm__ ("\n\ + movq %[NEW_SP], %%r10 # Load alt stack into r10\n\ + movl %[SIG], %%ecx # thissig to 1st arg reg \n\ + movq %[SI], %%rdx # &thissi to 2nd arg reg \n\ + movq %[CTX], %%r8 # thiscontext to 3rd arg reg \n\ + movq %[FUNC], %%rax# thisfunc to rax\n\ + movq %%rbp, %%r12 # Save rbp in r12\n\ + movq %%rsp, %%r13 # Store rsp in r13 \n\ + movq %%r10, %%rsp # Move alt stack into rsp\n\ + xorq %%rbp, %%rbp # Set rbp to 0 \n\ + subq $32, %%r
[newlib-cygwin] Add alternate signal stack to docs
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b782f869bf35b7172c1d45f62e386085d99d5a9e commit b782f869bf35b7172c1d45f62e386085d99d5a9e Author: Corinna Vinschen Date: Sat Jun 20 20:30:17 2015 +0200 Add alternate signal stack to docs * new-features.xml (ov-new2.1): Add alterante signal stack info. * posix.xml (std-susv4): Move sigaltstack here. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.1.0 | 6 ++ winsup/doc/new-features.xml | 10 ++ winsup/doc/posix.xml| 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/release/2.1.0 b/winsup/cygwin/release/2.1.0 index 5680cb3..40aba8c 100644 --- a/winsup/cygwin/release/2.1.0 +++ b/winsup/cygwin/release/2.1.0 @@ -1,6 +1,12 @@ What's new: --- +- First cut of an implementation to allow signal handlers running on an + alternate signal stack. + +- New API sigaltstack, plus definitions for SA_ONSTACK, SS_ONSTACK, SS_DISABLE, + MINSIGSTKSZ, SIGSTKSZ. + - New API: sethostname. diff --git a/winsup/doc/new-features.xml b/winsup/doc/new-features.xml index 6edde24..be3e389 100644 --- a/winsup/doc/new-features.xml +++ b/winsup/doc/new-features.xml @@ -9,6 +9,16 @@ +First cut of an implementation to allow signal handlers running on an +alternate signal stack. + + + +New API sigaltstack, plus definitions for SA_ONSTACK, SS_ONSTACK, +SS_DISABLE, MINSIGSTKSZ, SIGSTKSZ. + + + New API: sethostname. diff --git a/winsup/doc/posix.xml b/winsup/doc/posix.xml index fa5b173..8a74f24 100644 --- a/winsup/doc/posix.xml +++ b/winsup/doc/posix.xml @@ -763,6 +763,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). shutdown sigaction sigaddset +sigaltstack sigdelset sigemptyset sigfillset @@ -1490,7 +1491,6 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). scalblnl scalbnl setnetent -sigaltstack sigtimedwait sinhl sinl
[newlib-cygwin] ChangeLog entries for Cygwin's alternate signal stack implementation
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a88afecce6ca7405df28f8ae162b56697c2601a2 commit a88afecce6ca7405df28f8ae162b56697c2601a2 Author: Corinna Vinschen Date: Sat Jun 20 20:36:16 2015 +0200 ChangeLog entries for Cygwin's alternate signal stack implementation Signed-off-by: Corinna Vinschen Diff: --- newlib/ChangeLog| 11 +++ winsup/cygwin/ChangeLog | 25 + winsup/doc/ChangeLog| 5 + 3 files changed, 41 insertions(+) diff --git a/newlib/ChangeLog b/newlib/ChangeLog index 7cfec6f..a59cc97 100644 --- a/newlib/ChangeLog +++ b/newlib/ChangeLog @@ -1,3 +1,14 @@ +2015-06-20 Corinna Vinschen + + * libc/include/sys/signal.h: Move altstack macros completely + outside of rtems block. + +2015-06-19 Corinna Vinschen + + * libc/include/sys/signal.h: Define SS_ONSTACK and SS_DISABLE + unconditionally. + (sigaltstack): Enable prototype on Cygwin. + 2015-06-15 Freddie Chopin * libc/time/gmtime_r.c (gmtime_r): use faster algorithm from diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 464ca32..4591d4a 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,28 @@ +2015-06-20 Corinna Vinschen + + * exceptions.cc (_cygtls::call_signal_handler): Implement alternate + signal stack handling. + * signal.cc (sigaltstack): Add fault handler. + * include/cygwin/signal.h: Remove definitions of MINSIGSTKSZ + and SIGSTKSZ here. + +2015-06-19 Corinna Vinschen + + * common.din (sigaltstack): Export. + * cygtls.cc (_cygtls::init_thread): Initialize altstack. + * cygtls.h (__tlsstack_t): Rename from __stack_t to distinguish + more clearly from stack_t. Accommodate throughout. + (_cygtls): Add altstack member. + * exceptions.cc (exception::handle): Set SIGSEGV handler to SIG_DFL + if we encounter a stack overflow, and no alternate stack has been + defined. + * include/cygwin/signal.h (MINSIGSTKSZ): Define + (SIGSTKSZ): Define. + (SA_ONSTACK): Define. + * signal.cc (sigaltstack): New function. + * tlsoffset.h: Regenerate. + * tlsoffset64.h: Ditto. + 2015-06-19 Corinna Vinschen * exceptions.cc: Minor formatting fixes. diff --git a/winsup/doc/ChangeLog b/winsup/doc/ChangeLog index 2d9e268..23bd06c 100644 --- a/winsup/doc/ChangeLog +++ b/winsup/doc/ChangeLog @@ -1,3 +1,8 @@ +2015-06-20 Corinna Vinschen + + * new-features.xml (ov-new2.1): Add alterante signal stack info. + * posix.xml (std-susv4): Move sigaltstack here. + 2015-06-19 Jon Turney * Makefile.in (install-man): Fix command to create man3 install
[newlib-cygwin] Use MINSIGSTKSZ and SIGSTKSZ from newlib for Cygwin as well
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=6442e914d9213a6d4fe9d58e9a33bc407e18a2aa commit 6442e914d9213a6d4fe9d58e9a33bc407e18a2aa Author: Corinna Vinschen Date: Sat Jun 20 19:05:51 2015 +0200 Use MINSIGSTKSZ and SIGSTKSZ from newlib for Cygwin as well * libc/include/sys/signal.h: Move altstack macros completely outside of rtems block. * include/cygwin/signal.h: Remove definitions of MINSIGSTKSZ and SIGSTKSZ here. Signed-off-by: Corinna Vinschen Diff: --- newlib/libc/include/sys/signal.h | 28 ++-- winsup/cygwin/include/cygwin/signal.h | 3 --- 2 files changed, 14 insertions(+), 17 deletions(-) diff --git a/newlib/libc/include/sys/signal.h b/newlib/libc/include/sys/signal.h index f2087fe..6283e89 100644 --- a/newlib/libc/include/sys/signal.h +++ b/newlib/libc/include/sys/signal.h @@ -108,20 +108,6 @@ struct sigaction { #define sa_sigaction _signal_handlers._sigaction #endif -#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 -/* - * Minimum and default signal stack constants. Allow for target overrides - * from . - */ -#ifndefMINSIGSTKSZ -#defineMINSIGSTKSZ 2048 -#endif -#ifndefSIGSTKSZ -#defineSIGSTKSZ8192 -#endif - -#endif - #elif defined(__CYGWIN__) #include #else @@ -137,12 +123,26 @@ struct sigaction }; #endif /* defined(__rtems__) */ +#if __BSD_VISIBLE || __XSI_VISIBLE || __POSIX_VISIBLE >= 200112 +/* + * Minimum and default signal stack constants. Allow for target overrides + * from . + */ +#ifndefMINSIGSTKSZ +#defineMINSIGSTKSZ 2048 +#endif +#ifndefSIGSTKSZ +#defineSIGSTKSZ8192 +#endif + /* * Possible values for ss_flags in stack_t below. */ #defineSS_ONSTACK 0x1 #defineSS_DISABLE 0x2 +#endif + /* * Structure used in sigaltstack call. */ diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 2db0a80..edd5681 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -332,9 +332,6 @@ struct sigaction int sa_flags; }; -#define MINSIGSTKSZ 32768 -#define SIGSTKSZ65536 - #define SA_NOCLDSTOP 1 /* Do not generate SIGCHLD when children stop */ #define SA_SIGINFO 2 /* Invoke the signal catching function
[newlib-cygwin] Fix comments
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=44745e3165e0b4049d7fddf217b307323911ec5d commit 44745e3165e0b4049d7fddf217b307323911ec5d Author: Corinna Vinschen Date: Sat Jun 20 20:56:55 2015 +0200 Fix comments Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/exceptions.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 895d57f..fb59c61 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1610,7 +1610,7 @@ _cygtls::call_signal_handler () movq %[CTX], %%r8 # thiscontext to 3rd arg reg \n\ movq %[FUNC], %%rax# thisfunc to rax\n\ movq %%rbp, %%r12 # Save rbp in r12\n\ - movq %%rsp, %%r13 # Store rsp in r13 \n\ + movq %%rsp, %%r13 # Save rsp in r13\n\ movq %%r10, %%rsp # Move alt stack into rsp\n\ xorq %%rbp, %%rbp # Set rbp to 0 \n\ subq $32, %%rsp# Setup shadow space \n\ @@ -1653,7 +1653,7 @@ _cygtls::call_signal_handler () [FUNC] "o" (thisfunc) : "memory"); #endif - /* Revert altstack info to normal. */ + /* Revert alternate stack to unused. */ _my_tls.altstack.ss_flags = 0; } else
[newlib-cygwin] Safe all clobbered volatile registers when using alternate stack
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b6c18f2a647ab6757f474bce4d011c592367d01f commit b6c18f2a647ab6757f474bce4d011c592367d01f Author: Corinna Vinschen Date: Sun Jun 21 13:58:57 2015 +0200 Safe all clobbered volatile registers when using alternate stack * exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16 bytes from the alternate stack, it's not necessary. Safe all clobbered registers. Safe one on the orignal stack, the others on the alternate stack on both platforms. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 + winsup/cygwin/exceptions.cc | 69 ++--- 2 files changed, 54 insertions(+), 22 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 4591d4a..6b01539 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-21 Corinna Vinschen + + * exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16 + bytes from the alternate stack, it's not necessary. Safe all clobbered + registers. Safe one on the orignal stack, the others on the alternate + stack on both platforms. + 2015-06-20 Corinna Vinschen * exceptions.cc (_cygtls::call_signal_handler): Implement alternate diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index fb59c61..8d34179 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1594,29 +1594,49 @@ _cygtls::call_signal_handler () If the current code does not work as expected in the "usual" POSIX circumstances, this problem must be revisited. */ - /* Compute new stackbase. We start from the high address, subtract -16 bytes (safe/sorry) and align to 16 byte. */ + /* Compute new stackbase. We start from the high address, aligned +to 16 byte. */ uintptr_t new_sp = (uintptr_t) _my_tls.altstack.ss_sp -+ _my_tls.altstack.ss_size - 0x10; ++ _my_tls.altstack.ss_size; new_sp &= ~0xf; /* Mark alternate stack as used. */ _my_tls.altstack.ss_flags = SS_ONSTACK; - /* Move to alternate stack, call thisfunc, revert stack regs. */ + /* In assembler: Save regs on new stack, move to alternate stack, +call thisfunc, revert stack regs. */ #ifdef __x86_64__ + /* Clobbered regs: rax, rcx, rdx, r8, r9, r10, r11, rbp, rsp */ __asm__ ("\n\ - movq %[NEW_SP], %%r10 # Load alt stack into r10\n\ + pushq %%r9 # Push r9 on orig stack \n\ + movq %[NEW_SP], %%r9 # Load alt stack into r9 \n\ + subq $0x40, %%r9 # Make room on alt stack to \n\ + # save clobbered regs\n\ + movq %%rax, (%%r9) # Save other clobbered regs \n\ + movq %%rcx, 0x8(%%r9) \n\ + movq %%rdx, 0x10(%%r9) \n\ + movq %%r8, 0x18(%%r9) \n\ + movq %%r10, 0x20(%%r9) \n\ + movq %%r11, 0x28(%%r9) \n\ + movq %%rbp, 0x30(%%r9) \n\ + movq %%rsp, 0x38(%%r9) \n\ movl %[SIG], %%ecx # thissig to 1st arg reg \n\ movq %[SI], %%rdx # &thissi to 2nd arg reg \n\ movq %[CTX], %%r8 # thiscontext to 3rd arg reg \n\ movq %[FUNC], %%rax# thisfunc to rax\n\ - movq %%rbp, %%r12 # Save rbp in r12\n\ - movq %%rsp, %%r13 # Save rsp in r13\n\ - movq %%r10, %%rsp # Move alt stack into rsp\n\ + movq %%r9, %%rsp # Move alt stack into rsp\n\ xorq %%rbp, %%rbp # Set rbp to 0 \n\ - subq $32, %%rsp# Setup shadow space \n\ + subq $0x20, %%rsp # Setup shadow space \n\ call *%%rax# Call thisfunc \n\ - movq %%r12, %%rbp # Restore rbp\n\ - movq %%r13, %%rsp # Restore rsp\n" + addq $0x20, %%rsp # Revert shadow space\n\ + movq %%rsp, %%r9 # Restore clobbered regs \n\ + movq 0x38(%%r9), %%rsp \n\ + movq 0x30(%%r9), %%rbp
[newlib-cygwin] Don't push on original stack during alternate signal stack setup
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f4abb28ea81bd5d7f651ec8f3ac944c3c82493ac commit f4abb28ea81bd5d7f651ec8f3ac944c3c82493ac Author: Corinna Vinschen Date: Mon Jun 22 13:09:55 2015 +0200 Don't push on original stack during alternate signal stack setup * exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register on the original stack, it confuses GCC. Rearrange the assembler code so that $rax/$eax is not used by GCC to prepare an argument value. Use $rax/$eax without saving. Drop clearing $rbp/$epb. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/exceptions.cc | 105 +--- 2 files changed, 56 insertions(+), 56 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 6b01539..9f99268 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-22 Corinna Vinschen + + * exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register + on the original stack, it confuses GCC. Rearrange the assembler code + so that $rax/$eax is not used by GCC to prepare an argument value. + Use $rax/$eax without saving. Drop clearing $rbp/$epb. + 2015-06-21 Corinna Vinschen * exceptions.cc (_cygtls::call_signal_handler): Drop subtracting 16 diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 8d34179..d493abb 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1604,76 +1604,69 @@ _cygtls::call_signal_handler () /* In assembler: Save regs on new stack, move to alternate stack, call thisfunc, revert stack regs. */ #ifdef __x86_64__ - /* Clobbered regs: rax, rcx, rdx, r8, r9, r10, r11, rbp, rsp */ + /* Clobbered regs: rcx, rdx, r8, r9, r10, r11, rbp, rsp */ __asm__ ("\n\ - pushq %%r9 # Push r9 on orig stack \n\ - movq %[NEW_SP], %%r9 # Load alt stack into r9 \n\ - subq $0x40, %%r9 # Make room on alt stack to \n\ - # save clobbered regs\n\ - movq %%rax, (%%r9) # Save other clobbered regs \n\ - movq %%rcx, 0x8(%%r9) \n\ - movq %%rdx, 0x10(%%r9) \n\ - movq %%r8, 0x18(%%r9) \n\ - movq %%r10, 0x20(%%r9) \n\ - movq %%r11, 0x28(%%r9) \n\ - movq %%rbp, 0x30(%%r9) \n\ - movq %%rsp, 0x38(%%r9) \n\ + movq %[NEW_SP], %%rax # Load alt stack into rax\n\ + subq $0x60, %%rax # Make room on alt stack \n\ + # for clobbered regs and \n\ + # required shadow space \n\ + movq %%rcx, 0x20(%%rax)# Save clobbered regs\n\ + movq %%rdx, 0x28(%%rax) \n\ + movq %%r8, 0x30(%%rax) \n\ + movq %%r9, 0x38(%%rax) \n\ + movq %%r10, 0x40(%%rax) \n\ + movq %%r11, 0x48(%%rax) \n\ + movq %%rbp, 0x50(%%rax) \n\ + movq %%rsp, 0x58(%%rax) \n\ movl %[SIG], %%ecx # thissig to 1st arg reg \n\ - movq %[SI], %%rdx # &thissi to 2nd arg reg \n\ + leaq %[SI], %%rdx # &thissi to 2nd arg reg \n\ movq %[CTX], %%r8 # thiscontext to 3rd arg reg \n\ - movq %[FUNC], %%rax# thisfunc to rax\n\ - movq %%r9, %%rsp # Move alt stack into rsp\n\ - xorq %%rbp, %%rbp # Set rbp to 0 \n\ - subq $0x20, %%rsp # Setup shadow space \n\ - call *%%rax# Call thisfunc \n\ - addq $0x20, %%rsp # Revert shadow space\n\ - movq %%rsp, %%r9 # Restore clobbered regs \n\ - movq 0x38(%%r9), %%rsp \n\ - movq 0x30(%%r9), %%rbp \n\ - movq 0x28(%%r9), %%r11 \n\ - movq 0x20(%%r9), %%r10 \n\ - movq
[newlib-cygwin] Complement SIGEV_* enums with macros
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=d04fd9d5f7d6989cc3ca99e7d49dafc098f27e51 commit d04fd9d5f7d6989cc3ca99e7d49dafc098f27e51 Author: Ken Brown Date: Tue Jun 23 10:39:06 2015 +0200 Complement SIGEV_* enums with macros * include/cygwin/signal.h (SIGEV_*): Add macros. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/include/cygwin/signal.h | 4 2 files changed, 8 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 9f99268..3b492e4 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-23 Ken Brown + + * include/cygwin/signal.h (SIGEV_*): Add macros. + 2015-06-22 Corinna Vinschen * exceptions.cc (_cygtls::call_signal_handler): Drop pushing a register diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index edd5681..19c8452 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -311,6 +311,10 @@ enum perform notification */ }; +#define SIGEV_SIGNAL SIGEV_SIGNAL +#define SIGEV_NONE SIGEV_NONE +#define SIGEV_THREAD SIGEV_THREAD + #if __WORDSIZE == 64 typedef __uint64_t sigset_t; #else
[newlib-cygwin] Deleted branch cygwin-acl
The branch 'cygwin-acl' was deleted. It previously pointed to: e9ca3fa... Reapply Cygwin POSIX ACL changes from master Diff: !!! WARNING: THE FOLLOWING COMMITS ARE NO LONGER ACCESSIBLE (LOST): --- e9ca3fa... Reapply Cygwin POSIX ACL changes from master commit e9ca3fa538186be53c1448ddf671676172c9e54b Author: Corinna Vinschen Date: Fri May 29 16:19:55 2015 +0200 Reapply Cygwin POSIX ACL changes from master Reapply POSIX ACL changes. * sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL. Apply umask, if so. Align comments. * security.cc (set_created_file_access): Fix permission masking by incoming requested file mode. * sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit for SYSTEM and Admins group. * sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and GROUP entries if they are the same as USER_OBJ or GROUP_OBJ. * fhandler.h (fhandler_pty_slave::facl): Add prototype. * fhandler_tty.cc (fhandler_pty_slave::facl): New method. (fhandler_pty_slave::fchown): Fix uid/gid handling. * sec_acl.cc (set_posix_access): Drop superfluous class_idx variable. Simplify and move around code in a few places. To improve ACL readability, add r/w permissions to Admins ACE appended to pty ACL. Add comment to explain Windows ACE Mask filtering being in the way of creating a real CLASS_OBJ. (get_posix_access): Fake CLASS_OBJ for ptys. Explain why. * security.cc (get_object_attribute): Add S_IFCHR flag to attributes when calling get_posix_access. * sec_acl.cc (set_posix_access): Move merging group perms into owner perms in case of owner == group after mask has been computed. Take mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE. * sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw the ACCESS_ALLOWED_ACE. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment to explain why. * security.cc (set_created_file_access): Ditto. * sec_acl.cc (set_posix_access): Replace previous patch. Return EINVAL if uid and/or guid is invalid and not backed by an actual Windows account. * sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL. * sec_acl.cc (set_posix_access): Handle files with owner == group. Rephrase switch statement checking against unfiltered a_type value. (get_posix_access): Handle files with owner == group. * sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up CLASS_OBJ mask on old-style ACLs. Fix a comment. * sec_acl.cc (set_posix_access): Always make sure Admins have WRITE_DAC and WRITE_OWNER permissions. * security.h (create_object_sd_from_attribute): Drop handle parameter from prototype. * security.cc (create_object_sd_from_attribute): Drop handle parameter. Just create the standard POSIXy security descriptor. (set_object_attribute): Accommodate dropped paramter in call to create_object_sd_from_attribute. * fhandler_tty.cc: Ditto, throughout. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in mask computation. * fhandler.cc (fhandler_base::open_with_arch): Call open with mode not umasked. (fhandler_base::open): Explicitely umask mode on NFS here. Call new set_created_file_access rather than set_file_attribute. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement setting permissions on filesystems supporting ACLs using the new set_posix_access call. (fhandler_disk_file::fchown): Ditto. (fhandler_disk_file::mkdir): Call new set_created_file_access rather than set_file_attribute. * fhandler_socket.cc (fhandler_socket::bind): Don't umask here. Add WRITE_OWNER access to allow writing group in case of SGID bit set. Call new set_created_file_access rather than set_file_attribute. * path.cc (symlink_worker): Call new set_created_file_access rather than set_file_attribute. * sec_acl.cc (searchace): Un-staticize. (set_posix_access): New, complementary functionality to get_posix_access. (setacl): Implement in terms of get_posix_access/set_posix_access. (get_posix_access): Add handling for just created files requiring their first Cygwin ACL. Fix new_style recognition. Handle SGID bit. For old-style ACLs, ignore SYSTEM and Administrators when computing the {DEF_}CLA
[newlib-cygwin] Created branch 'cygwin-acl'
The branch 'cygwin-acl' was created pointing to: bd0f211... Reapply POSIX ACL changes.
[newlib-cygwin/cygwin-acl] Reapply POSIX ACL changes.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=bd0f211ca0e97bafce9bb50a418294dda5ad7c14 commit bd0f211ca0e97bafce9bb50a418294dda5ad7c14 Author: Corinna Vinschen Date: Wed Jun 24 11:52:29 2015 +0200 Reapply POSIX ACL changes. - New, unified implementation of POSIX permission and ACL handling. The new ACLs now store the POSIX ACL MASK/CLASS_OBJ permission mask, and they allow to inherit the S_ISGID bit. ACL inheritance now really works as desired, in a limited, but theoretically equivalent fashion even for non-Cygwin processes. To accommodate Windows default ACLs, the new code ignores SYSTEM and Administrators group permissions when computing the MASK/CLASS_OBJ permission mask on old ACLs, and it doesn't deny access to SYSTEM and Administrators group based on the value of MASK/CLASS_OBJ when creating the new ACLs. The new code now handles the S_ISGID bit on directories as on Linux: Setting S_ISGID on a directory causes new files and subdirs created within to inherit its group, rather than the primary group of the user who created the file. This only works for files and directories created by Cygwin processes. 2015-05-29 Corinna Vinschen Reapply POSIX ACL changes. * utils.xml (setfacl): Show new option output. (getfacl): Show new option output. * sec_acl.cc (get_posix_access): Check for Cygwin "standard" ACL. Apply umask, if so. Align comments. * security.cc (set_created_file_access): Fix permission masking by incoming requested file mode. * sec_acl.cc (set_posix_access): Apply mask only in terms of execute bit for SYSTEM and Admins group. * sec_acl.cc (set_posix_access): Don't create DENY ACEs for USER and GROUP entries if they are the same as USER_OBJ or GROUP_OBJ. * fhandler.h (fhandler_pty_slave::facl): Add prototype. * fhandler_tty.cc (fhandler_pty_slave::facl): New method. (fhandler_pty_slave::fchown): Fix uid/gid handling. * sec_acl.cc (set_posix_access): Drop superfluous class_idx variable. Simplify and move around code in a few places. To improve ACL readability, add r/w permissions to Admins ACE appended to pty ACL. Add comment to explain Windows ACE Mask filtering being in the way of creating a real CLASS_OBJ. (get_posix_access): Fake CLASS_OBJ for ptys. Explain why. * security.cc (get_object_attribute): Add S_IFCHR flag to attributes when calling get_posix_access. * sec_acl.cc (set_posix_access): Move merging group perms into owner perms in case of owner == group after mask has been computed. Take mask into account when doing so to avoid unnecessary ACCESS_DENIED_ACE. * sec_acl.cc (get_posix_access): Only set saw_group_obj flag if we saw the ACCESS_ALLOWED_ACE. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Deliberatly set GROUP_OBJ and CLASS_OBJ perms to new group perms. Add comment to explain why. * security.cc (set_created_file_access): Ditto. * sec_acl.cc (set_posix_access): Replace previous patch. Return EINVAL if uid and/or guid is invalid and not backed by an actual Windows account. * sec_acl.cc (set_posix_access): Workaround owner/group SIDs being NULL. * sec_acl.cc (set_posix_access): Handle files with owner == group. Rephrase switch statement checking against unfiltered a_type value. (get_posix_access): Handle files with owner == group. * sec_acl.cc (get_posix_access): Don't use GROUP_OBJ access to fix up CLASS_OBJ mask on old-style ACLs. Fix a comment. * sec_acl.cc (set_posix_access): Always make sure Admins have WRITE_DAC and WRITE_OWNER permissions. * security.h (create_object_sd_from_attribute): Drop handle parameter from prototype. * security.cc (create_object_sd_from_attribute): Drop handle parameter. Just create the standard POSIXy security descriptor. (set_object_attribute): Accommodate dropped paramter in call to create_object_sd_from_attribute. * fhandler_tty.cc: Ditto, throughout. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Fix typo in mask computation. * fhandler.cc (fhandler_base::open_with_arch): Call open with mode not umasked. (fhandler_base::open): Explicitely umask mode on NFS here. Call new set_created_file_access rather than set_file_attribute. * fhandler_disk_file.cc (fhandler_disk_file::fchmod): Reimplement setting permissions on filesystems supporting ACLs using the new set_posix_access call. (fhandler_
[newlib-cygwin] Fix values returned by getrlimit(RLIMIT_STACK)
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2ecaa3c1769ce1bf2e42d30304903ac8c9a5fbc8 commit 2ecaa3c1769ce1bf2e42d30304903ac8c9a5fbc8 Author: Corinna Vinschen Date: Fri Jun 26 20:41:54 2015 +0200 Fix values returned by getrlimit(RLIMIT_STACK) * resource.cc (getrlimit): Fix values returned by RLIMIT_STACK. Explain why this had to be changed. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/resource.cc | 36 ++-- 2 files changed, 31 insertions(+), 10 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 3b492e4..060eb80 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-06-26 Corinna Vinschen + + * resource.cc (getrlimit): Fix values returned by RLIMIT_STACK. + Explain why this had to be changed. + 2015-06-23 Ken Brown * include/cygwin/signal.h (SIGEV_*): Add macros. diff --git a/winsup/cygwin/resource.cc b/winsup/cygwin/resource.cc index 27ba4d4..895ba7f 100644 --- a/winsup/cygwin/resource.cc +++ b/winsup/cygwin/resource.cc @@ -114,8 +114,6 @@ getrusage (int intwho, struct rusage *rusage_in) extern "C" int getrlimit (int resource, struct rlimit *rlp) { - MEMORY_BASIC_INFORMATION m; - __try { rlp->rlim_cur = RLIM_INFINITY; @@ -129,14 +127,32 @@ getrlimit (int resource, struct rlimit *rlp) case RLIMIT_AS: break; case RLIMIT_STACK: - if (!VirtualQuery ((LPCVOID) &m, &m, sizeof m)) - debug_printf ("couldn't get stack info, returning def.values. %E"); - else - { - rlp->rlim_cur = (rlim_t) &m - (rlim_t) m.AllocationBase; - rlp->rlim_max = (rlim_t) m.BaseAddress + m.RegionSize - - (rlim_t) m.AllocationBase; - } + PTEB teb; + /* 2015-06-26: Originally rlim_cur returned the size of the still +available stack area on the current stack, rlim_max the total size +of the current stack. Two problems: + +- Per POSIX, RLIMIT_STACK returns "the maximum size of the initial + thread's stack, in bytes. The implementation does not + automatically grow the stack beyond this limit". + +- With the implementation of sigaltstack, the current stack is not + necessarily the "initial thread's stack" anymore. Rather, when + called from a signal handler running on the alternate stack, + RLIMIT_STACK should return the size of the original stack. + +rlim_cur is now the size of the stack. For system-provided stacks +it's the size between DeallocationStack and StackBase. For +application-provided stacks (via pthread_attr_setstack), +DeallocationStack is NULL, but StackLimit points to the bottom +of the stack. + +rlim_max is set to RLIM_INFINITY since there's no hard limit +for stack sizes on Windows. */ + teb = NtCurrentTeb (); + rlp->rlim_cur = (rlim_t) teb->Tib.StackBase + - (rlim_t) (teb->DeallocationStack + ?: teb->Tib.StackLimit); break; case RLIMIT_NOFILE: rlp->rlim_cur = getdtablesize ();
[newlib-cygwin] Define larger MINSIGSTKSZ and SIGSTKSZ values for Cygwin
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=ba170254e6c2a81e847779f719ff61912437444e commit ba170254e6c2a81e847779f719ff61912437444e Author: Corinna Vinschen Date: Fri Jun 26 21:41:26 2015 +0200 Define larger MINSIGSTKSZ and SIGSTKSZ values for Cygwin * include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ here with bigger values to allow _cygtls to reside on signal stack, should it turn out to be required at one point. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 ++ winsup/cygwin/include/cygwin/signal.h | 7 +++ 2 files changed, 13 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 060eb80..7f33687 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2015-06-26 Corinna Vinschen + * include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ + here with bigger values to allow _cygtls to reside on signal stack, + should it turn out to be required at one point. + +2015-06-26 Corinna Vinschen + * resource.cc (getrlimit): Fix values returned by RLIMIT_STACK. Explain why this had to be changed. diff --git a/winsup/cygwin/include/cygwin/signal.h b/winsup/cygwin/include/cygwin/signal.h index 19c8452..cdf86b9 100644 --- a/winsup/cygwin/include/cygwin/signal.h +++ b/winsup/cygwin/include/cygwin/signal.h @@ -355,6 +355,13 @@ struct sigaction Do not use. */ #define _SA_INTERNAL_MASK 0xf000 /* bits in this range are internal */ +#ifndefMINSIGSTKSZ +#defineMINSIGSTKSZ 32768 +#endif +#ifndefSIGSTKSZ +#defineSIGSTKSZ65536 +#endif + #defineSIGHUP 1 /* hangup */ #defineSIGINT 2 /* interrupt */ #defineSIGQUIT 3 /* quit */
[newlib-cygwin] Handle ss_flags value longjmp safe.
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=c2c1b843092768bd922f587bba9107c97f2a7ade commit c2c1b843092768bd922f587bba9107c97f2a7ade Author: Corinna Vinschen Date: Sat Jun 27 12:08:07 2015 +0200 Handle ss_flags value longjmp safe. * exceptions.cc (_cygtls::call_signal_handler): Drop manipulating thread's ss_flags here. It's not safe against longjmp. * signal.cc (sigaltstack): Check if we're running on the alternate stack and set ss_flags returned in oss to SS_ONSTACK. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/exceptions.cc | 4 winsup/cygwin/signal.cc | 12 +++- 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 7f33687..31b429b 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2015-06-27 Corinna Vinschen + + * exceptions.cc (_cygtls::call_signal_handler): Drop manipulating + thread's ss_flags here. It's not safe against longjmp. + * signal.cc (sigaltstack): Check if we're running on the alternate + stack and set ss_flags returned in oss to SS_ONSTACK. + 2015-06-26 Corinna Vinschen * include/cygwin/signal.h: Revert to define MINSIGSTKSZ and SIGSTKSZ diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index d493abb..90a8ff2 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1599,8 +1599,6 @@ _cygtls::call_signal_handler () uintptr_t new_sp = (uintptr_t) _my_tls.altstack.ss_sp + _my_tls.altstack.ss_size; new_sp &= ~0xf; - /* Mark alternate stack as used. */ - _my_tls.altstack.ss_flags = SS_ONSTACK; /* In assembler: Save regs on new stack, move to alternate stack, call thisfunc, revert stack regs. */ #ifdef __x86_64__ @@ -1671,8 +1669,6 @@ _cygtls::call_signal_handler () [FUNC] "o" (thisfunc) : "memory"); #endif - /* Revert alternate stack to unused. */ - _my_tls.altstack.ss_flags = 0; } else /* No alternate signal stack requested or available, just call diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 94faaf3..467c919 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -667,7 +667,17 @@ sigaltstack (const stack_t *ss, stack_t *oss) } } if (oss) - memcpy (oss, &me.altstack, sizeof *oss); + { + char stack_marker; + memcpy (oss, &me.altstack, sizeof *oss); + if (!me.altstack.ss_flags && me.altstack.ss_sp) + { + if (&stack_marker >= (char *) me.altstack.ss_sp + && &stack_marker < (char *) me.altstack.ss_sp ++ me.altstack.ss_size) + oss->ss_flags = SS_ONSTACK; + } + } } __except (EFAULT) {
[newlib-cygwin] Add comment to sigaltstack to explain setting ss_flags here
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=0f3e6315712428fcbfc0b6ffeec7c850d9b7206a commit 0f3e6315712428fcbfc0b6ffeec7c850d9b7206a Author: Corinna Vinschen Date: Tue Jun 30 20:43:50 2015 +0200 Add comment to sigaltstack to explain setting ss_flags here * signal.cc (sigaltstack): Add comment. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 4 winsup/cygwin/signal.cc | 4 2 files changed, 8 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 31b429b..01bb3eb 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,7 @@ +2015-06-30 Corinna Vinschen + + * signal.cc (sigaltstack): Add comment. + 2015-06-27 Corinna Vinschen * exceptions.cc (_cygtls::call_signal_handler): Drop manipulating diff --git a/winsup/cygwin/signal.cc b/winsup/cygwin/signal.cc index 467c919..2b9cfda 100644 --- a/winsup/cygwin/signal.cc +++ b/winsup/cygwin/signal.cc @@ -670,6 +670,10 @@ sigaltstack (const stack_t *ss, stack_t *oss) { char stack_marker; memcpy (oss, &me.altstack, sizeof *oss); + /* Check if the current stack is the alternate signal stack. If so, +set ss_flags accordingly. We do this here rather than setting +ss_flags in _cygtls::call_signal_handler since the signal handler +calls longjmp, so we never return to reset the flag. */ if (!me.altstack.ss_flags && me.altstack.ss_sp) { if (&stack_marker >= (char *) me.altstack.ss_sp
[newlib-cygwin] Fix fork after recovered stack overflow
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e3d345c5c39c79db00c8601682ed6fe35d8953c8 commit e3d345c5c39c79db00c8601682ed6fe35d8953c8 Author: Corinna Vinschen Date: Wed Jul 1 15:28:16 2015 +0200 Fix fork after recovered stack overflow * fork.cc (frok::parent): Set stacktop value based on requested stack pointer value in child. Explain why. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/fork.cc | 16 ++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 01bb3eb..eaa62a0 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-07-01 Corinna Vinschen + + * fork.cc (frok::parent): Set stacktop value based on requested stack + pointer value in child. Explain why. + 2015-06-30 Corinna Vinschen * signal.cc (sigaltstack): Add comment. diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index faccb48..951c7fd 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -308,9 +308,21 @@ frok::parent (volatile char * volatile stack_here) ch.forker_finished = forker_finished; PTEB teb = NtCurrentTeb (); - ch.stackbottom = _tlsbase; - ch.stacktop = (void *) _tlstop; ch.stackaddr = teb->DeallocationStack; + ch.stackbottom = _tlsbase; + /* If DeallocationStack is NULL, we're running on an application-provided + stack. If so, the entire stack is committed anyway and StackLimit points + to the allocation address of the stack. Otherwise we're running on a + system-allocated stack and using StackLimit is dangerous, in case the + application encountered a stack overflow and recovered from it via + a signal handler running on an alternate stack. Since stack_here is + the address of the stack pointer we start the child with anyway, we + can set ch.stacktop to this value rounded down to page size. The + child will not need the rest of the stack anyway. */ + if (!ch.stackaddr) +ch.stacktop = _tlstop; + else +ch.stacktop = (void *) ((uintptr_t) stack_here & ~wincap.page_size ()); ch.guardsize = 0; if (&_my_tls != _main_tls) {
[newlib-cygwin] Document previous change
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=fc22f775032cff7100166c32ab562b48578ee0dc commit fc22f775032cff7100166c32ab562b48578ee0dc Author: Corinna Vinschen Date: Wed Jul 1 15:50:18 2015 +0200 Document previous change Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.1.0 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/winsup/cygwin/release/2.1.0 b/winsup/cygwin/release/2.1.0 index 40aba8c..93b84b9 100644 --- a/winsup/cygwin/release/2.1.0 +++ b/winsup/cygwin/release/2.1.0 @@ -22,3 +22,6 @@ Bug Fixes - Try to handle concurrent close on socket more gracefully Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00235.html + +- Fix fork failing after the parent recovered from a stack overflow. + Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00384.html
[newlib-cygwin] Fix original stack when running signal handler on alternate stack
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=2cd7eb7f60208b0ffd51a9e117a8846c33b4ad41 commit 2cd7eb7f60208b0ffd51a9e117a8846c33b4ad41 Author: Corinna Vinschen Date: Sat Jul 4 22:49:30 2015 +0200 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 Diff: --- winsup/cygwin/ChangeLog | 25 winsup/cygwin/autoload.cc| 1 + winsup/cygwin/cygtls.h | 4 +- winsup/cygwin/exceptions.cc | 142 --- winsup/cygwin/tlsoffsets.h | 116 ++- winsup/cygwin/tlsoffsets64.h | 116 ++- winsup/cygwin/wincap.cc | 14 + winsup/cygwin/wincap.h | 7 +++ 8 files changed, 291 insertions(+), 134 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index eaa62a0..909996c 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,28 @@ +2015-07-04 Corinna Vinschen + + * 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. + 2015-07-01 Corinna Vinschen * fork.cc (frok::parent): Set stacktop value based on requested stack diff --git a/winsup/cygwin/autoload.cc b/winsup/cygwin/autoload.cc index 5832e27..6423a67 100644 --- a/winsup/cygwin/autoload.cc +++ b/winsup/cygwin/autoload.cc @@ -581,6 +581,7 @@ LoadDLLfunc (GetSystemTimePreciseAsFileTime, 4, kernel32) LoadDLLfuncEx (IdnToAscii, 20, kernel32, 1) LoadDLLfuncEx (IdnToUnicode, 20, kernel32, 1) LoadDLLfunc (LocaleNameToLCID, 8, kernel32) +LoadDLLfunc (SetThreadStackGuarantee, 4, kernel32) /* ldap functions are cdecl! */ #pragma push_macro ("mangle") diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 0944811..3dfffbb 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -17,6 +17,7 @@ details. */ #include #undef _NOMNTENT_FUNCS #include +#include #define CYGTLS_INITIALIZED 0xc763173f @@ -192,7 +193,8 @@ public: siginfo_t *sigwait_info; HANDLE signal_arrived; bool will_wait_for_signal; - CONTEXT thread_context; + long __align;/* Needed to align context to 16 byte. */ + ucontext_t context; DWORD thread_id; siginfo_t infodata; struct pthread *tid; diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 90a8ff2..0ce22d9
[newlib-cygwin] Add missing wincap changes to previous ChangeLog entry
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=f0464fbf9d779d3868a0fa6f341045babadfe145 commit f0464fbf9d779d3868a0fa6f341045babadfe145 Author: Corinna Vinschen Date: Sun Jul 5 12:48:05 2015 +0200 Add missing wincap changes to previous ChangeLog entry Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 909996c..840f396 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -22,6 +22,9 @@ struct _cygtls. * tlsoffset.h: Regenerate. * tlsoffset64.h: Regenerate. + * wincap.h (wincaps::def_guard_pages): New element. + (wincaps::has_set_thread_stack_guarantee): Ditto. + * wincap.cc: Implement above elements throughout. 2015-07-01 Corinna Vinschen
[newlib-cygwin] Disable fetching heap info on 64 bit XP/2003
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e426213a88e060ae3d739a8d9fe2f3e7e0432e43 commit e426213a88e060ae3d739a8d9fe2f3e7e0432e43 Author: Corinna Vinschen Date: Sun Jul 5 12:51:52 2015 +0200 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 Diff: --- winsup/cygwin/ChangeLog | 8 winsup/cygwin/fhandler_process.cc | 6 +- winsup/cygwin/release/2.1.0 | 2 ++ winsup/cygwin/wincap.cc | 10 ++ winsup/cygwin/wincap.h| 2 ++ 5 files changed, 27 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 840f396..a1f4957 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2015-07-05 Corinna Vinschen + + * 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. + 2015-07-04 Corinna Vinschen * autoload.cc (SetThreadStackGuarantee): Import. diff --git a/winsup/cygwin/fhandler_process.cc b/winsup/cygwin/fhandler_process.cc index 161050b..d3ee874 100644 --- a/winsup/cygwin/fhandler_process.cc +++ b/winsup/cygwin/fhandler_process.cc @@ -592,7 +592,11 @@ struct heap_info NTSTATUS status; PDEBUG_HEAP_ARRAY harray; -buf = RtlCreateQueryDebugBuffer (0, FALSE); +/* FIXME? RtlQueryProcessDebugInformation/CreateToolhelp32Snapshot both + crash the target process on 64 bit XP/2003 in native 64 bit mode. */ +if (wincap.has_broken_rtl_query_process_debug_information ()) + return; +buf = RtlCreateQueryDebugBuffer (16 * 65536, FALSE); if (!buf) return; status = RtlQueryProcessDebugInformation (pid, PDI_HEAPS | PDI_HEAP_BLOCKS, diff --git a/winsup/cygwin/release/2.1.0 b/winsup/cygwin/release/2.1.0 index 93b84b9..da484f5 100644 --- a/winsup/cygwin/release/2.1.0 +++ b/winsup/cygwin/release/2.1.0 @@ -25,3 +25,5 @@ Bug Fixes - Fix fork failing after the parent recovered from a stack overflow. Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00384.html + +- Fix a crash on 64 bit XP/2003 when opening /proc/$PID/maps. diff --git a/winsup/cygwin/wincap.cc b/winsup/cygwin/wincap.cc index 2c5880e..8e07661 100644 --- a/winsup/cygwin/wincap.cc +++ b/winsup/cygwin/wincap.cc @@ -48,6 +48,7 @@ wincaps wincap_xpsp2 __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:false, has_microsoft_accounts:false, has_set_thread_stack_guarantee:false, + has_broken_rtl_query_process_debug_information:false, }; wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -78,6 +79,7 @@ wincaps wincap_2003 __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:false, has_microsoft_accounts:false, has_set_thread_stack_guarantee:true, + has_broken_rtl_query_process_debug_information:true, }; wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -108,6 +110,7 @@ wincaps wincap_vista __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:false, has_microsoft_accounts:false, has_set_thread_stack_guarantee:true, + has_broken_rtl_query_process_debug_information:false, }; wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -138,6 +141,7 @@ wincaps wincap_7 __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:false, has_microsoft_accounts:false, has_set_thread_stack_guarantee:true, + has_broken_rtl_query_process_debug_information:false, }; wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -168,6 +172,7 @@ wincaps wincap_8 __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:true, has_microsoft_accounts:true, has_set_thread_stack_guarantee:true, + has_broken_rtl_query_process_debug_information:false, }; wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = { @@ -198,6 +203,7 @@ wincaps wincap_10 __attribute__((section (".cygwin_dll_common"), shared)) = { has_precise_system_time:true, has_microsoft_accounts:true, has_set_thread_stack_guarantee:true, + has_broken_rtl_query_process_debug_information:false, }; wincapc wincap __attribute__((section (".cygwin_dll_common"), shared)); @@ -255,6 +261,10 @
[newlib-cygwin] Implement correct RLIMIT_STACK handling
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=a54bc198b16635956d1ac94595e8abdee10a2e60 commit a54bc198b16635956d1ac94595e8abdee10a2e60 Author: Corinna Vinschen Date: Sun Jul 5 15:51:37 2015 +0200 Implement correct RLIMIT_STACK handling * miscfuncs.cc (struct pthread_wrapper_arg): Add member guardsize. (pthread_wrapper): Set thread stack guarantee according to guardsize. Tweak assembler code so that $rax/$eax is not required by GCC to prepare the wrapper_arg value. (CygwinCreateThread): Fix deadzone handling. Drop setting a "POSIX" guardpage (aka page w/ PAGE_NOACCESS). Always use Windows guard pages instead. On post-XP systems (providing SetThreadStackGuarantee) always set up stack Windows like with reserved/commited areas and movable guard pages. Only on XP set up stack fully commited if the guardpage size is not the default system guardpage size. Fill out pthread_wrapper_arg::guardsize. Improve comments. * resource.cc: Implement RSTACK_LIMIT Linux-like. (DEFAULT_STACKSIZE): New macro. (DEFAULT_STACKGUARD): Ditto. (rlimit_stack_guard): New muto. (rlimit_stack): New global variable holding current RSTACK_LIMIT values. (__set_rlimit_stack): Set rlimit_stack under lock. (__get_rlimit_stack): Initialize rlimit_stack from executable header and return rlimit_stack values under lock. (get_rlimit_stack): Filtering function to return useful default stacksize from rlimit_stack.rlim_cur value. (getrlimit): Call __get_rlimit_stack in RLIMIT_STACK case. (setrlimit): Call __set_rlimit_stack in RLIMIT_STACK case. * thread.cc (pthread::create): Fetch default stacksize calling get_rlimit_stack. (pthread_attr::pthread_attr): Fetch default guardsize calling wincap.def_guard_page_size. (pthread_attr_getstacksize): Fetch default stacksize calling get_rlimit_stack. * thread.h (PTHREAD_DEFAULT_STACKSIZE): Remove. (PTHREAD_DEFAULT_GUARDSIZE): Remove. (get_rlimit_stack): Declare. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 35 + winsup/cygwin/miscfuncs.cc | 94 - winsup/cygwin/release/2.1.0 | 6 +++ winsup/cygwin/resource.cc | 85 +++- winsup/cygwin/thread.cc | 6 +-- winsup/cygwin/thread.h | 9 + winsup/doc/new-features.xml | 8 7 files changed, 172 insertions(+), 71 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a1f4957..82a8a58 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,40 @@ 2015-07-05 Corinna Vinschen + * miscfuncs.cc (struct pthread_wrapper_arg): Add member guardsize. + (pthread_wrapper): Set thread stack guarantee according to guardsize. + Tweak assembler code so that $rax/$eax is not required by GCC to + prepare the wrapper_arg value. + (CygwinCreateThread): Fix deadzone handling. Drop setting a "POSIX" + guardpage (aka page w/ PAGE_NOACCESS). Always use Windows guard + pages instead. On post-XP systems (providing SetThreadStackGuarantee) + always set up stack Windows like with reserved/commited areas and + movable guard pages. Only on XP set up stack fully commited if the + guardpage size is not the default system guardpage size. + Fill out pthread_wrapper_arg::guardsize. Improve comments. + * resource.cc: Implement RSTACK_LIMIT Linux-like. + (DEFAULT_STACKSIZE): New macro. + (DEFAULT_STACKGUARD): Ditto. + (rlimit_stack_guard): New muto. + (rlimit_stack): New global variable holding current RSTACK_LIMIT values. + (__set_rlimit_stack): Set rlimit_stack under lock. + (__get_rlimit_stack): Initialize rlimit_stack from executable header + and return rlimit_stack values under lock. + (get_rlimit_stack): Filtering function to return useful default + stacksize from rlimit_stack.rlim_cur value. + (getrlimit): Call __get_rlimit_stack in RLIMIT_STACK case. + (setrlimit): Call __set_rlimit_stack in RLIMIT_STACK case. + * thread.cc (pthread::create): Fetch default stacksize calling + get_rlimit_stack. + (pthread_attr::pthread_attr): Fetch default guardsize calling + wincap.def_guard_page_size. + (pthread_attr_getstacksize): Fetch default stacksize calling + get_rlimit_stack. + * thread.h (PTHREAD_DEFAULT_STACKSIZE): Remove. + (PTHREAD_DEFAULT_GUARDSIZE): Remove. + (get_rlimit_stack): Declare. + +2015-07-05 Corinna Vinschen + * fhandler_process.cc (heap_info:
[newlib-cygwin] Align hard stack allocation to pthread stack setup changes
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=14e3fd1b221f59f7f8bc10f328c63e45d34019f8 commit 14e3fd1b221f59f7f8bc10f328c63e45d34019f8 Author: Corinna Vinschen Date: Sun Jul 5 17:45:06 2015 +0200 Align hard stack allocation to pthread stack setup changes * dcrt0.cc (CYGWIN_GUARD): Remove. (child_info_fork::alloc_stack_hard_way): Align stack commit to changes of thread stack setup in CygwinCreateThread. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 ++ winsup/cygwin/dcrt0.cc | 28 +--- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 82a8a58..58b75e2 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2015-07-05 Corinna Vinschen + * dcrt0.cc (CYGWIN_GUARD): Remove. + (child_info_fork::alloc_stack_hard_way): Align stack commit to changes + of thread stack setup in CygwinCreateThread. + +2015-07-05 Corinna Vinschen + * miscfuncs.cc (struct pthread_wrapper_arg): Add member guardsize. (pthread_wrapper): Set thread stack guarantee according to guardsize. Tweak assembler code so that $rax/$eax is not required by GCC to diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 738860d..48301ea 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -16,6 +16,7 @@ details. */ #include "glob.h" #include #include +#include #include "environ.h" #include "sigproc.h" #include "pinfo.h" @@ -404,8 +405,6 @@ check_sanity_and_sync (per_process *p) child_info NO_COPY *child_proc_info; -#define CYGWIN_GUARD (PAGE_READWRITE | PAGE_GUARD) - void child_info_fork::alloc_stack_hard_way (volatile char *b) { @@ -421,7 +420,7 @@ child_info_fork::alloc_stack_hard_way (volatile char *b) || is_mmapped_region ((caddr_t) stacktop, (caddr_t) stackbottom)) return; /* First, try to reserve the entire stack. */ - stacksize = (SIZE_T) stackbottom - (SIZE_T) stackaddr; + stacksize = (PBYTE) stackbottom - (PBYTE) stackaddr; if (!VirtualAlloc (stackaddr, stacksize, MEM_RESERVE, PAGE_NOACCESS)) { PTEB teb = NtCurrentTeb (); @@ -429,25 +428,32 @@ child_info_fork::alloc_stack_hard_way (volatile char *b) "%p - %p, (child has %p - %p), %E", stackaddr, stackbottom, teb->DeallocationStack, _tlsbase); } - stacksize = (SIZE_T) stackbottom - (SIZE_T) stacktop; + stacksize = (PBYTE) stackbottom - (PBYTE) stacktop; stack_ptr = VirtualAlloc (stacktop, stacksize, MEM_COMMIT, PAGE_READWRITE); if (!stack_ptr) abort ("can't commit memory for stack %p(%ly), %E", stacktop, stacksize); if (guardsize != (size_t) -1) { + ULONG real_guardsize = guardsize +? roundup2 (guardsize, wincap.page_size ()) +: wincap.def_guard_page_size (); /* Allocate PAGE_GUARD page if it still fits. */ if (stack_ptr > stackaddr) { - stack_ptr = (void *) ((LPBYTE) stack_ptr - - wincap.page_size ()); - if (!VirtualAlloc (stack_ptr, wincap.page_size (), MEM_COMMIT, -CYGWIN_GUARD)) + stack_ptr = (void *) ((PBYTE) stack_ptr - real_guardsize); + if (!VirtualAlloc (stack_ptr, real_guardsize, MEM_COMMIT, +PAGE_READWRITE | PAGE_GUARD)) api_fatal ("fork: couldn't allocate new stack guard page %p, %E", stack_ptr); } - /* Allocate POSIX guard pages. */ - if (guardsize > 0) - VirtualAlloc (stackaddr, guardsize, MEM_COMMIT, PAGE_NOACCESS); + /* On post-XP systems, set thread stack guarantee matching the guardsize. +Note that the guardsize is one page bigger than the guarantee. */ + if (wincap.has_set_thread_stack_guarantee () + && real_guardsize > wincap.def_guard_page_size ()) + { + real_guardsize -= wincap.page_size (); + SetThreadStackGuarantee (&real_guardsize); + } } b[0] = '\0'; }
[newlib-cygwin] Simplify fork code setting up child stack info
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=606013bcf108716f6a84b574864c26cff74f8a37 commit 606013bcf108716f6a84b574864c26cff74f8a37 Author: Corinna Vinschen Date: Tue Jul 7 17:05:20 2015 +0200 Simplify fork code setting up child stack info * fork.cc (frok::parent): Simplify code propagating stack setup to child process. Tweak comments. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/fork.cc | 49 - 2 files changed, 25 insertions(+), 29 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 13d6fe7..141307e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-07-07 Corinna Vinschen + + * fork.cc (frok::parent): Simplify code propagating stack setup to + child process. Tweak comments. + 2015-07-06 Yaakov Selkowitz * path.cc: Rework basename redefinition handling. Explain why. diff --git a/winsup/cygwin/fork.cc b/winsup/cygwin/fork.cc index 951c7fd..317aec7 100644 --- a/winsup/cygwin/fork.cc +++ b/winsup/cygwin/fork.cc @@ -307,39 +307,30 @@ frok::parent (volatile char * volatile stack_here) ch.forker_finished = forker_finished; - PTEB teb = NtCurrentTeb (); - ch.stackaddr = teb->DeallocationStack; ch.stackbottom = _tlsbase; - /* If DeallocationStack is NULL, we're running on an application-provided - stack. If so, the entire stack is committed anyway and StackLimit points - to the allocation address of the stack. Otherwise we're running on a - system-allocated stack and using StackLimit is dangerous, in case the - application encountered a stack overflow and recovered from it via - a signal handler running on an alternate stack. Since stack_here is - the address of the stack pointer we start the child with anyway, we - can set ch.stacktop to this value rounded down to page size. The - child will not need the rest of the stack anyway. */ + ch.stackaddr = NtCurrentTeb ()->DeallocationStack; if (!ch.stackaddr) -ch.stacktop = _tlstop; +{ + /* If DeallocationStack is NULL, we're running on an application-provided +stack. If so, the entire stack is committed anyway and StackLimit +points to the allocation address of the stack. Mark in guardsize that +we must not set up guard pages. */ + ch.stackaddr = ch.stacktop = _tlstop; + ch.guardsize = (size_t) -1; +} else -ch.stacktop = (void *) ((uintptr_t) stack_here & ~wincap.page_size ()); - ch.guardsize = 0; - if (&_my_tls != _main_tls) { - /* We have not been started from the main thread. Fetch the -information required to set up the thread stack identically -in the child. */ - if (!ch.stackaddr) - { - /* Pthread with application-provided stack. Don't set up a -PAGE_GUARD page. guardsize == -1 is used in alloc_stack_hard_way -to recognize this type of stack. */ - ch.stackaddr = _my_tls.tid->attr.stackaddr; - ch.guardsize = (size_t) -1; - } - else if (_my_tls.tid) - /* If it's a pthread, fetch guardsize from thread attributes. */ - ch.guardsize = _my_tls.tid->attr.guardsize; + /* Otherwise we're running on a system-allocated stack. Since stack_here +is the address of the stack pointer we start the child with anyway, we +can set ch.stacktop to this value rounded down to page size. The +child will not need the rest of the stack anyway. Guardsize depends +on whether we're running on a pthread or not. If pthread, we fetch +the guardpage size from the pthread attribs, otherwise we use the +system default. */ + ch.stacktop = (void *) ((uintptr_t) stack_here & ~wincap.page_size ()); + ch.guardsize = (&_my_tls != _main_tls && _my_tls.tid) +? _my_tls.tid->attr.guardsize +: wincap.def_guard_page_size (); } debug_printf ("stack - bottom %p, top %p, addr %p, guardsize %ly", ch.stackbottom, ch.stacktop, ch.stackaddr, ch.guardsize);
[newlib-cygwin] Simplify stack allocation code in child after fork
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=29a12632278368f197f3270532e2f6c19642512e commit 29a12632278368f197f3270532e2f6c19642512e Author: Corinna Vinschen Date: Tue Jul 7 17:24:37 2015 +0200 Simplify stack allocation code in child after fork * child_info.h (CURR_CHILD_INFO_MAGIC): Update. (child_info_fork::alloc_stack_hard_way): Drop declaration. * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fold into child_info_fork::alloc_stack. (getstack): Remove. (child_info_fork::alloc_stack): Simplify check for application-provided stack in "hard way" code. Don't call getstack for each page, just reallocate stack immediately as required. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 11 winsup/cygwin/child_info.h | 3 +- winsup/cygwin/dcrt0.cc | 123 + 3 files changed, 68 insertions(+), 69 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 141307e..a5e82d6 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,16 @@ 2015-07-07 Corinna Vinschen + * child_info.h (CURR_CHILD_INFO_MAGIC): Update. + (child_info_fork::alloc_stack_hard_way): Drop declaration. + * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fold into + child_info_fork::alloc_stack. + (getstack): Remove. + (child_info_fork::alloc_stack): Simplify check for application-provided + stack in "hard way" code. Don't call getstack for each page, just + reallocate stack immediately as required. + +2015-07-07 Corinna Vinschen + * fork.cc (frok::parent): Simplify code propagating stack setup to child process. Tweak comments. diff --git a/winsup/cygwin/child_info.h b/winsup/cygwin/child_info.h index d946727..9a0a2aa 100644 --- a/winsup/cygwin/child_info.h +++ b/winsup/cygwin/child_info.h @@ -39,7 +39,7 @@ enum child_status #define EXEC_MAGIC_SIZE sizeof(child_info) /* Change this value if you get a message indicating that it is out-of-sync. */ -#define CURR_CHILD_INFO_MAGIC 0x93737edaU +#define CURR_CHILD_INFO_MAGIC 0x4a91a908U #define NPROCS 256 @@ -113,7 +113,6 @@ public: void __reg1 handle_fork (); bool abort (const char *fmt = NULL, ...); void alloc_stack (); - void alloc_stack_hard_way (volatile char *); }; class fhandler_base; diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index 48301ea..f80ee36 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -405,39 +405,49 @@ check_sanity_and_sync (per_process *p) child_info NO_COPY *child_proc_info; +/* Extend the stack prior to fork longjmp. */ void -child_info_fork::alloc_stack_hard_way (volatile char *b) +child_info_fork::alloc_stack () { - void *stack_ptr; - SIZE_T stacksize; - - /* First check if the requested stack area is part of the user heap - or part of a mmapped region. If so, we have been started from a - pthread with an application-provided stack, and the stack has just - to be used as is. */ - if ((stacktop >= cygheap->user_heap.base - && stackbottom <= cygheap->user_heap.max) - || is_mmapped_region ((caddr_t) stacktop, (caddr_t) stackbottom)) -return; - /* First, try to reserve the entire stack. */ - stacksize = (PBYTE) stackbottom - (PBYTE) stackaddr; - if (!VirtualAlloc (stackaddr, stacksize, MEM_RESERVE, PAGE_NOACCESS)) -{ - PTEB teb = NtCurrentTeb (); - api_fatal ("fork: can't reserve memory for parent stack " -"%p - %p, (child has %p - %p), %E", -stackaddr, stackbottom, teb->DeallocationStack, _tlsbase); -} - stacksize = (PBYTE) stackbottom - (PBYTE) stacktop; - stack_ptr = VirtualAlloc (stacktop, stacksize, MEM_COMMIT, PAGE_READWRITE); - if (!stack_ptr) -abort ("can't commit memory for stack %p(%ly), %E", stacktop, stacksize); - if (guardsize != (size_t) -1) + /* Make sure not to try a hard allocation if we have been forked off from + the main thread of a Cygwin process which has been started from a 64 bit + parent. In that case the _tlsbase of the forked child is not the same + as the _tlsbase of the parent (== stackbottom), but only because the + stack of the parent has been slightly rearranged. See comment in + wow64_revert_to_original_stack for details. We check here if the + parent stack fits into the child stack. */ + if (_tlsbase != stackbottom + && (!wincap.is_wow64 () + || stacktop < NtCurrentTeb ()->DeallocationStack + || stackbottom > _tlsbase)) { + void *stack_ptr; + size_t stacksize; + + /* If guardsize is -1, we have been started from a pthread with an +application-provided stack, and the sta
[newlib-cygwin] x86_64: Handle myfault exceptions when running on alternate signal stack
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=60f10c64aa57d613471446ea3ec1b3ce6d3b9500 commit 60f10c64aa57d613471446ea3ec1b3ce6d3b9500 Author: Corinna Vinschen Date: Tue Jul 7 20:45:06 2015 +0200 x86_64: Handle myfault exceptions when running on alternate signal stack x86_64 only: * cygtls.cc (san::leave): Restore _my_tls.andreas. * cygtls.h (class san): Add _clemente as in 32 bit case. Add ret and frame members. (san::san): Handle _my_tls.andreas as on 32 bit. Take parameter and write it to new member ret. Store current stack pointer in frame. (san::~san): New destructor to restore _my_tls.andreas. (__try): Use __l_except address as parameter to san::san. * dcrt0.cc (dll_crt0_0): Add myfault_altstack_handler as vectored continuation handler. * exception.h (myfault_altstack_handler): Declare. * exceptions.cc (myfault_altstack_handler): New function. Explain what it's good for. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/cygtls.cc | 1 + winsup/cygwin/cygtls.h | 19 +-- winsup/cygwin/dcrt0.cc | 5 + winsup/cygwin/exception.h | 2 ++ winsup/cygwin/exceptions.cc | 46 + 5 files changed, 71 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc index dc9a698..cb8c24e 100644 --- a/winsup/cygwin/cygtls.cc +++ b/winsup/cygwin/cygtls.cc @@ -224,5 +224,6 @@ void san::leave () { /* Restore tls_pathbuf counters in case of error. */ _my_tls.locals.pathbufs._counters = _cnt; + _my_tls.andreas = _clemente; } #endif diff --git a/winsup/cygwin/cygtls.h b/winsup/cygwin/cygtls.h index 3dfffbb..91ed4d4 100644 --- a/winsup/cygwin/cygtls.h +++ b/winsup/cygwin/cygtls.h @@ -301,11 +301,26 @@ extern _cygtls *_sig_tls; #ifdef __x86_64__ class san { + san *_clemente; uint64_t _cnt; public: - san () __attribute__ ((always_inline)) + DWORD64 ret; + DWORD64 frame; + + san (PVOID _ret) __attribute__ ((always_inline)) { +_clemente = _my_tls.andreas; +_my_tls.andreas = this; _cnt = _my_tls.locals.pathbufs._counters; +/* myfault_altstack_handler needs the current stack pointer and the + address of the _except block to restore the context correctly. + See comment preceeding myfault_altstack_handler in exception.cc. */ +ret = (DWORD64) _ret; +__asm__ volatile ("movq %%rsp,%0": "=o" (frame)); + } + ~san () __attribute__ ((always_inline)) + { +_my_tls.andreas = _clemente; } /* This is the first thing called in the __except handler. The attribute "returns_twice" makes sure that GCC disregards any register value set @@ -363,7 +378,7 @@ public: { \ __label__ __l_try, __l_except, __l_endtry; \ __mem_barrier; \ -san __sebastian; \ +san __sebastian (&&__l_except); \ __asm__ goto ("\n" \ " .seh_handler _ZN9exception7myfaultEP17_EXCEPTION_RECORDPvP8_CONTEXTP19_DISPATCHER_CONTEXT, @except\n" \ " .seh_handlerdata \n" \ diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc index f80ee36..1874fe5 100644 --- a/winsup/cygwin/dcrt0.cc +++ b/winsup/cygwin/dcrt0.cc @@ -800,6 +800,11 @@ dll_crt0_0 () if (!dynamically_loaded) sigproc_init (); +#ifdef __x86_64__ + /* See comment preceeding myfault_altstack_handler in exception.cc. */ + AddVectoredContinueHandler (0, myfault_altstack_handler); +#endif + debug_printf ("finished dll_crt0_0 initialization"); } diff --git a/winsup/cygwin/exception.h b/winsup/cygwin/exception.h index 0478daf..13160fe 100644 --- a/winsup/cygwin/exception.h +++ b/winsup/cygwin/exception.h @@ -160,6 +160,8 @@ public: } }; +LONG CALLBACK myfault_altstack_handler (EXCEPTION_POINTERS *); + #endif /* !__x86_64__ */ class cygwin_exception diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 0ce22d9..2ba2f49 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -588,6 +588,50 @@ exception::myfault (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, /* NOTREACHED, make gcc happy. */ return ExceptionContinueSearch; } + +/* If another exception occurs while running a signal handler on an alternate + signal stack, the normal SEH handlers are skipped, because the OS exception + handling considers the current (alternate) stack "broken". However, it + still calls vectored exception handlers. + + TODO: What we do here is to handle only __try/__except blocks in Cygwin. + "Normal" exceptions will simply exit the process. Still, better +than nothing... */ +LONG WINA
[newlib-cygwin] Add accidentally missing ChangeLog entry for previous patch
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=e6b882b9573d8388199faf856d1707e5d4375e06 commit e6b882b9573d8388199faf856d1707e5d4375e06 Author: Corinna Vinschen Date: Tue Jul 7 20:49:02 2015 +0200 Add accidentally missing ChangeLog entry for previous patch Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 16 1 file changed, 16 insertions(+) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index a5e82d6..29b1183 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,21 @@ 2015-07-07 Corinna Vinschen + x86_64 only: + * cygtls.cc (san::leave): Restore _my_tls.andreas. + * cygtls.h (class san): Add _clemente as in 32 bit case. Add ret and + frame members. + (san::san): Handle _my_tls.andreas as on 32 bit. Take parameter and + write it to new member ret. Store current stack pointer in frame. + (san::~san): New destructor to restore _my_tls.andreas. + (__try): Use __l_except address as parameter to san::san. + * dcrt0.cc (dll_crt0_0): Add myfault_altstack_handler as vectored + continuation handler. + * exception.h (myfault_altstack_handler): Declare. + * exceptions.cc (myfault_altstack_handler): New function. Explain what + it's good for. + +2015-07-07 Corinna Vinschen + * child_info.h (CURR_CHILD_INFO_MAGIC): Update. (child_info_fork::alloc_stack_hard_way): Drop declaration. * dcrt0.cc (child_info_fork::alloc_stack_hard_way): Fold into
[newlib-cygwin] tzset: Check timezone and country case-insensitive
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b90a91a61800706ff83c47431658515dda90399c commit b90a91a61800706ff83c47431658515dda90399c Author: Corinna Vinschen Date: Wed Jul 8 10:25:49 2015 +0200 tzset: Check timezone and country case-insensitive * tzset.c (main): Check timezone and country case-insensitive. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/release/2.1.0 | 4 winsup/utils/ChangeLog | 4 winsup/utils/tzset.c| 4 ++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/release/2.1.0 b/winsup/cygwin/release/2.1.0 index aca69cd..1b9e19f 100644 --- a/winsup/cygwin/release/2.1.0 +++ b/winsup/cygwin/release/2.1.0 @@ -33,3 +33,7 @@ Bug Fixes Addresses: https://cygwin.com/ml/cygwin/2015-06/msg00384.html - Fix a crash on 64 bit XP/2003 when opening /proc/$PID/maps. + +- Apparently on some Windows systems timezones differ in case + from the standard. Fix the tzset tool to check case-insensitive. + Addresses: https://cygwin.com/ml/cygwin/2015-07/msg00113.html diff --git a/winsup/utils/ChangeLog b/winsup/utils/ChangeLog index 5a68a40..db6049b 100644 --- a/winsup/utils/ChangeLog +++ b/winsup/utils/ChangeLog @@ -1,3 +1,7 @@ +2015-07-08 Corinna Vinschen + + * tzset.c (main): Check timezone and country case-insensitive. + 2015-06-07 Jon Turney * strace.cc (proc_child): Log process and thread create and exit, diff --git a/winsup/utils/tzset.c b/winsup/utils/tzset.c index 2b3f413..0e22f44 100644 --- a/winsup/utils/tzset.c +++ b/winsup/utils/tzset.c @@ -207,11 +207,11 @@ main (int argc, char **argv) /* Now iterate over the mapping table and find the right entry. */ for (idx = 0; idx < TZMAP_SIZE; ++idx) { - if (!wcscmp (keyname, tzmap[idx].win_tzkey)) + if (!wcscasecmp (keyname, tzmap[idx].win_tzkey)) { if (gotit < 0) gotit = idx; - if (!wcscmp (country, tzmap[idx].country)) + if (!wcscasecmp (country, tzmap[idx].country)) break; } else if (gotit >= 0)
[newlib-cygwin] exceptions.cc: Reenable code only disabled for debug purposes
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=211cd495c47870590e87b5775edd9a02e09d6a9b commit 211cd495c47870590e87b5775edd9a02e09d6a9b Author: Corinna Vinschen Date: Mon Jul 13 16:08:29 2015 +0200 exceptions.cc: Reenable code only disabled for debug purposes * exceptions.cc (exception::handle): Reenable code only disabled for debug purposes. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 5 + winsup/cygwin/exceptions.cc | 2 -- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 29b1183..b470179 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-07-13 Corinna Vinschen + + * exceptions.cc (exception::handle): Reenable code only disabled for + debug purposes. + 2015-07-07 Corinna Vinschen x86_64 only: diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 2ba2f49..67df4fe 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -741,13 +741,11 @@ exception::handle (EXCEPTION_RECORD *e, exception_list *frame, CONTEXT *in, break; case STATUS_STACK_OVERFLOW: -#if 0 /* If we encounter a stack overflow, and if the thread has no alternate stack, don't even try to call a signal handler. This is in line with Linux behaviour and also makes a lot of sense on Windows. */ if (me.altstack.ss_flags) global_sigs[SIGSEGV].sa_handler = SIG_DFL; -#endif /*FALLTHRU*/ case STATUS_ARRAY_BOUNDS_EXCEEDED: case STATUS_IN_PAGE_ERROR:
[newlib-cygwin] Created tag cygwin-2_1_0-release
The signed tag 'cygwin-2_1_0-release' was created pointing to: c028685... Change to nano.specs to add nano's include dir Tagger: Corinna Vinschen Date: Tue Jul 14 21:12:12 2015 +0200 Cygwin 2.1.0 release
[newlib-cygwin] Document the fact that we forgot to bump for sigaltstack and sethostname
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=9a69aac0ed556d1141626b987bc4c0c877fdb169 commit 9a69aac0ed556d1141626b987bc4c0c877fdb169 Author: Corinna Vinschen Date: Fri Jul 17 14:02:43 2015 +0200 Document the fact that we forgot to bump for sigaltstack and sethostname Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 5 + winsup/cygwin/include/cygwin/version.h | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b470179..db7d723 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,8 @@ +2015-07-17 Corinna Vinschen + + * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Document the + fact that we forgot to bump for sigaltstack and sethostname. + 2015-07-13 Corinna Vinschen * exceptions.cc (exception::handle): Reenable code only disabled for diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 3d5d4de..7843136 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -471,7 +471,8 @@ details. */ 287: Export issetugid. */ - /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ + /* Note that we forgot to bump the api for ualarm, strtoll, strtoull, + sigaltstack, sethostname. */ #define CYGWIN_VERSION_API_MAJOR 0 #define CYGWIN_VERSION_API_MINOR 287
[newlib-cygwin] Implement getcontext, setcontext, makecontext, swapcontext
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=1020bb292aa0c19c487010aa1506c3d745ded6d5 commit 1020bb292aa0c19c487010aa1506c3d745ded6d5 Author: Corinna Vinschen Date: Fri Jul 17 14:31:12 2015 +0200 Implement getcontext, setcontext, makecontext, swapcontext * common.din (getcontext): Export. (makecontext): Export. (setcontext): Export. (swapcontext): Export. * exceptions.cc (__unwind_single_frame): New static functions, 64 bit only. (setcontext): New function. (getcontext): New function. (swapcontext): New function. (__cont_link_context): New function. (makecontext): New function. * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2002. (CYGWIN_VERSION_API_MINOR): Bump. * include/ucontext.h (getcontext): Add prototype. (setcontext): Ditto. (swapcontext): Ditto. (makecontext): Ditto. * ntdll.h (NtContinue): Ditto. * new-features.xml (ov-new2.2): Add new section. Document getcontext, setcontext, makecontext, swapcontext. * posix.xml (std-deprec): Add getcontext, setcontext, makecontext, swapcontext. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog| 21 winsup/cygwin/common.din | 4 + winsup/cygwin/exceptions.cc| 224 + winsup/cygwin/include/cygwin/version.h | 5 +- winsup/cygwin/include/ucontext.h | 12 ++ winsup/cygwin/ntdll.h | 1 + winsup/cygwin/release/2.2.0| 13 ++ winsup/doc/ChangeLog | 7 ++ winsup/doc/new-features.xml| 12 ++ winsup/doc/posix.xml | 4 + 10 files changed, 301 insertions(+), 2 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index db7d723..f2aabf7 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,26 @@ 2015-07-17 Corinna Vinschen + * common.din (getcontext): Export. + (makecontext): Export. + (setcontext): Export. + (swapcontext): Export. + * exceptions.cc (__unwind_single_frame): New static functions, 64 bit + only. + (setcontext): New function. + (getcontext): New function. + (swapcontext): New function. + (__cont_link_context): New function. + (makecontext): New function. + * include/cygwin/version.h (CYGWIN_VERSION_DLL_MAJOR): Bump to 2002. + (CYGWIN_VERSION_API_MINOR): Bump. + * include/ucontext.h (getcontext): Add prototype. + (setcontext): Ditto. + (swapcontext): Ditto. + (makecontext): Ditto. + * ntdll.h (NtContinue): Ditto. + +2015-07-17 Corinna Vinschen + * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Document the fact that we forgot to bump for sigaltstack and sethostname. diff --git a/winsup/cygwin/common.din b/winsup/cygwin/common.din index 644eb2e..e89a6bd 100644 --- a/winsup/cygwin/common.din +++ b/winsup/cygwin/common.din @@ -503,6 +503,7 @@ getc SIGFE getc_unlocked SIGFE getchar SIGFE getchar_unlocked SIGFE +getcontext NOSIGFE getcwd SIGFE getdelim = __getdelim SIGFE getdomainname SIGFE @@ -717,6 +718,7 @@ lsetxattr SIGFE lstat SIGFE lutimes SIGFE madvise = posix_madvise SIGFE +makecontext NOSIGFE mallinfo SIGFE malloc SIGFE malloc_stats SIGFE @@ -1054,6 +1056,7 @@ sendmsg = cygwin_sendmsg SIGFE sendto = cygwin_sendto SIGFE setbuf SIGFE setbuffer SIGFE +setcontext NOSIGFE sethostname SIGFE setdtablesize SIGFE setegid SIGFE @@ -1199,6 +1202,7 @@ strtoumax = strtoull NOSIGFE strupr NOSIGFE strxfrm NOSIGFE swab NOSIGFE +swapcontext NOSIGFE swprintf SIGFE swscanf SIGFE symlink SIGFE diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 67df4fe..eea2be3 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -14,6 +14,7 @@ details. */ #include "miscfuncs.h" #include #include +#include #include #include #include @@ -1863,3 +1864,226 @@ _cygtls::signal_debugger (siginfo_t& si) ResumeThread (th); } } + +#ifdef __x86_64__ +static inline void +__unwind_single_frame (PCONTEXT ctx) +{ + /* Amazing, but true: On 32 bit, RtlCaptureContext returns the context + matching the caller of getcontext, so all we have to do is call it. + On 64 bit, RtlCaptureContext returns the exact context of its own + caller, so we have to unwind virtually by a single frame to get the + context of the caller of getcontext. */ + PRUNTIME_FUNCTION f; + ULONG64 imagebase; + UNWIND_HISTORY_TABLE hist; + DWORD64 establisher; + PVOID hdl; + + f = RtlLookupFunctionEntry (ctx->Rip, &imagebase, &hist); + if (f) +RtlVirtualUnwind (0, imagebase, ctx->Rip
[newlib-cygwin] Reuse __unwind_single_frame where appropriate
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b3ccf998ccc7b45a3df442b8f5ca8989f5c874a6 commit b3ccf998ccc7b45a3df442b8f5ca8989f5c874a6 Author: Corinna Vinschen Date: Fri Jul 17 16:29:41 2015 +0200 Reuse __unwind_single_frame where appropriate * exceptions.cc (__unwind_single_frame): Move up in file to be accessible from other places. Move comment to getcontext. (stack_info::walk): Call __unwind_single_frame in 64 bit case. Fix preceeding comment. (myfault_altstack_handler): Call __unwind_single_frame. (getcontext): Give comment from __unwind_single_frame a new home. (swapcontext): Fix comment. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 10 + winsup/cygwin/exceptions.cc | 90 - 2 files changed, 42 insertions(+), 58 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index f2aabf7..0537eea 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,15 @@ 2015-07-17 Corinna Vinschen + * exceptions.cc (__unwind_single_frame): Move up in file to be + accessible from other places. Move comment to getcontext. + (stack_info::walk): Call __unwind_single_frame in 64 bit case. Fix + preceeding comment. + (myfault_altstack_handler): Call __unwind_single_frame. + (getcontext): Give comment from __unwind_single_frame a new home. + (swapcontext): Fix comment. + +2015-07-17 Corinna Vinschen + * common.din (getcontext): Export. (makecontext): Export. (setcontext): Export. diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index eea2be3..7e10ba9 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -280,17 +280,36 @@ stack_info::init (PUINT_PTR framep, bool wantargs, PCONTEXT ctx) extern "C" void _cygwin_exit_return (); -/* Walk the stack by looking at successive stored 'bp' frames. - This is not foolproof. */ -int -stack_info::walk () -{ #ifdef __x86_64__ +static inline void +__unwind_single_frame (PCONTEXT ctx) +{ PRUNTIME_FUNCTION f; ULONG64 imagebase; + UNWIND_HISTORY_TABLE hist; DWORD64 establisher; PVOID hdl; + f = RtlLookupFunctionEntry (ctx->Rip, &imagebase, &hist); + if (f) +RtlVirtualUnwind (0, imagebase, ctx->Rip, f, ctx, &hdl, &establisher, + NULL); + else +{ + ctx->Rip = *(ULONG_PTR *) ctx->Rsp; + ctx->Rsp += 8; +} +} +#endif + +/* Walk the stack. + + On 32 bit we're doing this by looking at successive stored 'ebp' frames. + This is not foolproof. */ +int +stack_info::walk () +{ +#ifdef __x86_64__ if (!c.Rip) return 0; @@ -306,15 +325,7 @@ stack_info::walk () sigstackptr--; return 1; } - - f = RtlLookupFunctionEntry (c.Rip, &imagebase, &hist); - if (f) -RtlVirtualUnwind (0, imagebase, c.Rip, f, &c, &hdl, &establisher, NULL); - else -{ - c.Rip = *(ULONG_PTR *) c.Rsp; - c.Rsp += 8; -} + __unwind_single_frame (&c); if (needargs && c.Rip) { PULONG_PTR p = (PULONG_PTR) c.Rsp; @@ -605,28 +616,13 @@ myfault_altstack_handler (EXCEPTION_POINTERS *exc) if (me.andreas) { - PRUNTIME_FUNCTION f; - ULONG64 imagebase; - UNWIND_HISTORY_TABLE hist; - DWORD64 establisher; - PVOID hdl; CONTEXT *c = exc->ContextRecord; /* Unwind the stack manually and call RtlRestoreContext. This is necessary because RtlUnwindEx checks the stack for validity, which, as outlined above, fails for the alternate stack. */ while (c->Rsp < me.andreas->frame) - { - f = RtlLookupFunctionEntry (c->Rip, &imagebase, &hist); - if (f) - RtlVirtualUnwind (0, imagebase, c->Rip, f, c, &hdl, &establisher, - NULL); - else - { - c->Rip = *(ULONG_PTR *) c->Rsp; - c->Rsp += 8; - } - } + __unwind_single_frame (c); c->Rip = me.andreas->ret; RtlRestoreContext (c, NULL); } @@ -1865,33 +1861,6 @@ _cygtls::signal_debugger (siginfo_t& si) } } -#ifdef __x86_64__ -static inline void -__unwind_single_frame (PCONTEXT ctx) -{ - /* Amazing, but true: On 32 bit, RtlCaptureContext returns the context - matching the caller of getcontext, so all we have to do is call it. - On 64 bit, RtlCaptureContext returns the exact context of its own - caller, so we have to unwind virtually by a single frame to get the - context of the caller of getcontext. */ - PRUNTIME_FUNCTION f; - ULONG64 imagebase; - UNWIND_HISTORY_TABLE hist; - DWORD64 establisher; - PVOID hdl; - - f = RtlLookupFunctionEntry (
[newlib-cygwin] Comment fixup
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=16d2d9f1312653daa9cb8d4cdb3a113e53f432ca commit 16d2d9f1312653daa9cb8d4cdb3a113e53f432ca Author: Corinna Vinschen Date: Fri Jul 17 16:47:14 2015 +0200 Comment fixup * exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext. (swapcontext/x86_64): Fix comment yet again. (getcontext/i686): Move comment from x86_64 getcontext, slightly rearranged, to preceeding comment. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 7 +++ winsup/cygwin/exceptions.cc | 12 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 0537eea..65adef5 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,12 @@ 2015-07-17 Corinna Vinschen + * exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext. + (swapcontext/x86_64): Fix comment yet again. + (getcontext/i686): Move comment from x86_64 getcontext, slightly + rearranged, to preceeding comment. + +2015-07-17 Corinna Vinschen + * exceptions.cc (__unwind_single_frame): Move up in file to be accessible from other places. Move comment to getcontext. (stack_info::walk): Call __unwind_single_frame in 64 bit case. Fix diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 7e10ba9..6e9890e 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -1886,11 +1886,6 @@ getcontext (ucontext_t *ucp) PCONTEXT ctx = (PCONTEXT) &ucp->uc_mcontext; ctx->ContextFlags = CONTEXT_FULL; RtlCaptureContext (ctx); - /* Amazing, but true: On 32 bit, RtlCaptureContext returns the context - matching the caller of getcontext, so all we have to do is call it. - On 64 bit, RtlCaptureContext returns the exact context of its own - caller, so we have to unwind virtually by a single frame to get the - context of the caller of getcontext. */ __unwind_single_frame (ctx); /* Successful getcontext is supposed to return 0. If we don't set rax to 0 here, there's a chance that code like this: @@ -1911,8 +1906,8 @@ swapcontext (ucontext_t *oucp, const ucontext_t *ucp) PCONTEXT ctx = (PCONTEXT) &oucp->uc_mcontext; ctx->ContextFlags = CONTEXT_FULL; RtlCaptureContext (ctx); - /* See comments in getcontext. */ __unwind_single_frame (ctx); + /* See comment in getcontext. */ oucp->uc_mcontext.rax = 0; oucp->uc_sigmask = oucp->uc_mcontext.oldmask = _my_tls.sigmask; return setcontext (ucp); @@ -1941,6 +1936,11 @@ __cont_link_context: \n\ the callee-saved registers, especially $ebx, are not changed by the calling function. If so, makecontext/__cont_link_context would be broken. + Amazing, but true: While on 64 bit RtlCaptureContext returns the exact + context of its own caller, as expected, on 32 bit RtlCaptureContext returns + the context of the callers caller. So while we have to unwind another frame + on 64 bit, we can skip this step on 32 bit. + Both functions are split into the first half in assembler, and the second half in C to allow easy access to _my_tls. */
[newlib-cygwin] Fix ucontext creation in call_signal handler
https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b2df1577c7b62d9f6f9c06f41037e9bd09f2174d commit b2df1577c7b62d9f6f9c06f41037e9bd09f2174d Author: Corinna Vinschen Date: Fri Jul 17 18:29:52 2015 +0200 Fix ucontext creation in call_signal handler * exceptions.cc (__unwind_single_frame): Define empty macro on i686. (_cygtls::call_signal_handler): Try to make sure signal context makes sense in case we're generating context here. Add comment to explain. Signed-off-by: Corinna Vinschen Diff: --- winsup/cygwin/ChangeLog | 6 ++ winsup/cygwin/exceptions.cc | 19 +++ 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index 65adef5..eb89f67 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,5 +1,11 @@ 2015-07-17 Corinna Vinschen + * exceptions.cc (__unwind_single_frame): Define empty macro on i686. + (_cygtls::call_signal_handler): Try to make sure signal context makes + sense in case we're generating context here. Add comment to explain. + +2015-07-17 Corinna Vinschen + * exceptions.cc (getcontext/x86_64): Drop comment on RtlCaptureContext. (swapcontext/x86_64): Fix comment yet again. (getcontext/i686): Move comment from x86_64 getcontext, slightly diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 6e9890e..d69dbf7 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -300,6 +300,8 @@ __unwind_single_frame (PCONTEXT ctx) ctx->Rsp += 8; } } +#else +#define __unwind_single_frame(ctx) #endif /* Walk the stack. @@ -1667,11 +1669,20 @@ _cygtls::call_signal_handler () sizeof (CONTEXT)); else { - /* FIXME: Really this should be the context which the signal -interrupted? */ - memset(&context.uc_mcontext, 0, sizeof (struct __mcontext)); + /* Software-generated signal. We're fetching the current +context, unwind to the caller and in case we're called +from sigdelayed, fix rip/eip accordingly. */ context.uc_mcontext.ctxflags = CONTEXT_FULL; - RtlCaptureContext ((CONTEXT *) &context.uc_mcontext); + RtlCaptureContext ((PCONTEXT) &context.uc_mcontext); + __unwind_single_frame ((PCONTEXT) &context.uc_mcontext); + if (stackptr > stack) + { +#ifdef __x86_64__ + context.uc_mcontext.rip = retaddr (); +#else + context.uc_mcontext.eip = retaddr (); +#endif + } } if (this_sa_flags & SA_ONSTACK