* 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.
This commit is contained in:
parent
1498189ca8
commit
deb648cc8b
@ -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>
|
2003-09-16 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* cygheap.cc (cygheap_user::set_saved_sid): Rename from set_orig_sid.
|
* cygheap.cc (cygheap_user::set_saved_sid): Rename from set_orig_sid.
|
||||||
|
@ -19,6 +19,7 @@ details. */
|
|||||||
#include "sigproc.h"
|
#include "sigproc.h"
|
||||||
#include "pinfo.h"
|
#include "pinfo.h"
|
||||||
#include "tty.h"
|
#include "tty.h"
|
||||||
|
#include "sys/cygwin.h"
|
||||||
|
|
||||||
/* Common functions shared by tty/console */
|
/* Common functions shared by tty/console */
|
||||||
|
|
||||||
@ -84,7 +85,7 @@ void
|
|||||||
tty_min::kill_pgrp (int sig)
|
tty_min::kill_pgrp (int sig)
|
||||||
{
|
{
|
||||||
int killself = 0;
|
int killself = 0;
|
||||||
winpids pids;
|
winpids pids ((DWORD) PID_MAP_RW);
|
||||||
for (unsigned i = 0; i < pids.npids; i++)
|
for (unsigned i = 0; i < pids.npids; i++)
|
||||||
{
|
{
|
||||||
_pinfo *p = pids[i];
|
_pinfo *p = pids[i];
|
||||||
|
@ -49,7 +49,7 @@ struct __cygwin_perfile
|
|||||||
|
|
||||||
/* External interface stuff */
|
/* External interface stuff */
|
||||||
|
|
||||||
typedef enum
|
typedef
|
||||||
{
|
{
|
||||||
CW_LOCK_PINFO,
|
CW_LOCK_PINFO,
|
||||||
CW_UNLOCK_PINFO,
|
CW_UNLOCK_PINFO,
|
||||||
|
@ -541,22 +541,31 @@ winpids::add (DWORD& nelem, bool winpid, DWORD pid)
|
|||||||
pinfolist = (pinfo *) realloc (pinfolist, size_pinfolist (npidlist + 1));
|
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)
|
if (winpid)
|
||||||
/* nothing to do */;
|
goto out;
|
||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
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;
|
pidlist[nelem++] = pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,6 +197,7 @@ class winpids
|
|||||||
DWORD *pidlist;
|
DWORD *pidlist;
|
||||||
DWORD npidlist;
|
DWORD npidlist;
|
||||||
pinfo *pinfolist;
|
pinfo *pinfolist;
|
||||||
|
DWORD pinfo_access; // access type for pinfo open
|
||||||
DWORD (winpids::* enum_processes) (bool winpid);
|
DWORD (winpids::* enum_processes) (bool winpid);
|
||||||
DWORD enum_init (bool winpid);
|
DWORD enum_init (bool winpid);
|
||||||
DWORD enumNT (bool winpid);
|
DWORD enumNT (bool winpid);
|
||||||
@ -207,9 +208,14 @@ public:
|
|||||||
DWORD npids;
|
DWORD npids;
|
||||||
inline void reset () { npids = 0; release (); }
|
inline void reset () { npids = 0; release (); }
|
||||||
void set (bool winpid);
|
void set (bool winpid);
|
||||||
winpids (int): enum_processes (&winpids::enum_init) { reset (); }
|
winpids (int): pinfo_access (0), enum_processes (&winpids::enum_init)
|
||||||
winpids (): pidlist (NULL), npidlist (0), pinfolist (NULL),
|
{ reset (); }
|
||||||
enum_processes (&winpids::enum_init), npids (0) { set (0); }
|
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 DWORD& winpid (int i) const {return pidlist[i];}
|
||||||
inline _pinfo *operator [] (int i) const {return (_pinfo *) pinfolist[i];}
|
inline _pinfo *operator [] (int i) const {return (_pinfo *) pinfolist[i];}
|
||||||
~winpids ();
|
~winpids ();
|
||||||
|
@ -247,7 +247,7 @@ kill_pgrp (pid_t pid, int sig)
|
|||||||
|
|
||||||
sigproc_printf ("pid %d, signal %d", pid, 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++)
|
for (unsigned i = 0; i < pids.npids; i++)
|
||||||
{
|
{
|
||||||
_pinfo *p = pids[i];
|
_pinfo *p = pids[i];
|
||||||
|
@ -725,6 +725,11 @@ sig_send (_pinfo *p, int sig, DWORD ebp, bool exception)
|
|||||||
else if ((thiscatch = getevent (p, "sigcatch")))
|
else if ((thiscatch = getevent (p, "sigcatch")))
|
||||||
{
|
{
|
||||||
todo = p->getsigtodo (sig);
|
todo = p->getsigtodo (sig);
|
||||||
|
if (IsBadWritePtr (todo, sizeof (*todo)))
|
||||||
|
{
|
||||||
|
set_errno (EACCES);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
issem = false;
|
issem = false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user