]> sourceware.org Git - newlib-cygwin.git/commitdiff
* pinfo.h (winpids::pid_access): New element.
authorChristopher Faylor <me@cgf.cx>
Wed, 17 Sep 2003 01:15:56 +0000 (01:15 +0000)
committerChristopher Faylor <me@cgf.cx>
Wed, 17 Sep 2003 01:15:56 +0000 (01:15 +0000)
(winpids::winpids): Rejigger to set pinfo_access.
* pinfo.cc (winpids::add): Try to open shared memory region with supplied
pinfo_access first, then default to readonly.
* fhandler_termios.cc (tty_min::kill_pgrp): When getting list of pids to work
with, suggest opening with PID_MAP_RW.
* signal.cc (kill_pgrp): Ditto.
* sigproc.cc (sig_send): Perform a write check on todo prior to attempting to
increment it.  Return EACCES if we can't write to it.

winsup/cygwin/ChangeLog
winsup/cygwin/fhandler_termios.cc
winsup/cygwin/include/sys/cygwin.h
winsup/cygwin/pinfo.cc
winsup/cygwin/pinfo.h
winsup/cygwin/signal.cc
winsup/cygwin/sigproc.cc

index c4d79237ff8c75df6d3e249ece1187bbbe2d31a9..a7ef9a7d82a52b54c3cfee9a6841463a4498d737 100644 (file)
@@ -1,3 +1,15 @@
+2003-09-16  Christopher Faylor  <cgf@redhat.com>
+
+       * pinfo.h (winpids::pid_access): New element.
+       (winpids::winpids): Rejigger to set pinfo_access.
+       * pinfo.cc (winpids::add): Try to open shared memory region with
+       supplied pinfo_access first, then default to readonly.
+       * fhandler_termios.cc (tty_min::kill_pgrp): When getting list of pids
+       to work with, suggest opening with PID_MAP_RW.
+       * signal.cc (kill_pgrp): Ditto.
+       * sigproc.cc (sig_send): Perform a write check on todo prior to
+       attempting to increment it.  Return EACCES if we can't write to it.
+
 2003-09-16  Corinna Vinschen  <corinna@vinschen.de>
 
        * cygheap.cc (cygheap_user::set_saved_sid): Rename from set_orig_sid.
index 49dbb337872605ae32ebcb3d20cb957f71a7f404..1a2dd251ccbb15876da14631e3771baec05dc8cc 100644 (file)
@@ -19,6 +19,7 @@ details. */
 #include "sigproc.h"
 #include "pinfo.h"
 #include "tty.h"
+#include "sys/cygwin.h"
 
 /* Common functions shared by tty/console */
 
@@ -84,7 +85,7 @@ void
 tty_min::kill_pgrp (int sig)
 {
   int killself = 0;
-  winpids pids;
+  winpids pids ((DWORD) PID_MAP_RW);
   for (unsigned i = 0; i < pids.npids; i++)
     {
       _pinfo *p = pids[i];
index 36c3f53b1d6caad9d590f1d6fbebaf3cff635ca0..d1083264b53bf94fd7886ce9334ae0cdf200b5ee 100644 (file)
@@ -49,7 +49,7 @@ struct __cygwin_perfile
 
 /* External interface stuff */
 
-typedef enum
+typedef
   {
     CW_LOCK_PINFO,
     CW_UNLOCK_PINFO,
index eabf6a92c77a2ef1fc6669d50cc3260933a77445..6c59860c68aa287af35b39ba454fff922721aa76 100644 (file)
@@ -541,22 +541,31 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid)
       pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1));
     }
 
-  pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0));
+  pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0)
+                        | pinfo_access);
   if (winpid)
-    /* nothing to do */;
-  else if (!pinfolist[nelem])
-    return;
-  else
-    /* Scan list of previously recorded pids to make sure that this pid hasn't
-       shown up before.  This can happen when a process execs. */
-    for (unsigned i = 0; i < nelem; i++)
-      if (pinfolist[i]->pid == pinfolist[nelem]->pid)
-       {
-         if ((_pinfo *) pinfolist[nelem] != (_pinfo *) myself)
-           pinfolist[nelem].release ();
-         return;
-       }
+    goto out;
 
+  if (!pinfolist[nelem])
+    {
+      if (!pinfo_access)
+       return;
+      pinfolist[nelem].init (cygpid, PID_NOREDIR | (winpid ? PID_ALLPIDS : 0));
+      if (!pinfolist[nelem])
+       return;
+      }
+
+  /* Scan list of previously recorded pids to make sure that this pid hasn't
+     shown up before.  This can happen when a process execs. */
+  for (unsigned i = 0; i < nelem; i++)
+    if (pinfolist[i]->pid == pinfolist[nelem]->pid)
+      {
+       if ((_pinfo *) pinfolist[nelem] != (_pinfo *) myself)
+         pinfolist[nelem].release ();
+       return;
+      }
+
+out:
   pidlist[nelem++] = pid;
 }
 
index e437328b626643eb4cf9f940e59f00bb65a9aec4..518252c27d2d55f1b72a39605e3f399834e19fcf 100644 (file)
@@ -197,6 +197,7 @@ class winpids
   DWORD *pidlist;
   DWORD npidlist;
   pinfo *pinfolist;
+  DWORD pinfo_access;          // access type for pinfo open
   DWORD (winpids::* enum_processes) (bool winpid);
   DWORD enum_init (bool winpid);
   DWORD enumNT (bool winpid);
@@ -207,9 +208,14 @@ public:
   DWORD npids;
   inline void reset () { npids = 0; release (); }
   void set (bool winpid);
-  winpids (int): enum_processes (&winpids::enum_init) { reset (); }
-  winpids (): pidlist (NULL), npidlist (0), pinfolist (NULL),
-             enum_processes (&winpids::enum_init), npids (0) { set (0); }
+  winpids (int): pinfo_access (0), enum_processes (&winpids::enum_init)
+    { reset (); }
+  winpids (DWORD acc = 0): pidlist (NULL), npidlist (0), pinfolist (NULL),
+                          enum_processes (&winpids::enum_init), npids (0)
+  {
+    pinfo_access = acc;
+    set (0);
+  }
   inline DWORD& winpid (int i) const {return pidlist[i];}
   inline _pinfo *operator [] (int i) const {return (_pinfo *) pinfolist[i];}
   ~winpids ();
index 5ee4cc71a86e6d0a56c966ed4da3ee9e30e2733b..07c8a2c0beb72cbb45cd9c331dc1a4365b2b210a 100644 (file)
@@ -247,7 +247,7 @@ kill_pgrp (pid_t pid, int sig)
 
   sigproc_printf ("pid %d, signal %d", pid, sig);
 
-  winpids pids;
+  winpids pids ((DWORD) PID_MAP_RW);
   for (unsigned i = 0; i < pids.npids; i++)
     {
       _pinfo *p = pids[i];
index 795c7f3ef2d48668af968d9e7bf7869316715f78..dff073049f55ba8af9baec62da0af61645e8a980 100644 (file)
@@ -725,6 +725,11 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
   else if ((thiscatch = getevent (p, "sigcatch")))
     {
       todo = p->getsigtodo (sig);
+      if (IsBadWritePtr (todo, sizeof (*todo)))
+       {
+         set_errno (EACCES);
+         goto out;
+       }
       issem = false;
     }
   else
This page took 0.046653 seconds and 5 git commands to generate.