fix race condition
This commit is contained in:
parent
cd80f609e6
commit
864a5356a1
1
NEWS
1
NEWS
@ -1,6 +1,7 @@
|
|||||||
procps-3.2.5 --> procps-3.2.6
|
procps-3.2.5 --> procps-3.2.6
|
||||||
|
|
||||||
more MIPS crud -- thanks Jim Gifford and Ryan Oliver
|
more MIPS crud -- thanks Jim Gifford and Ryan Oliver
|
||||||
|
begin prep for setuid
|
||||||
|
|
||||||
procps-3.2.4 --> procps-3.2.5
|
procps-3.2.4 --> procps-3.2.5
|
||||||
|
|
||||||
|
@ -509,8 +509,10 @@ int open_psdb_message(const char *restrict override, void (*message)(const char
|
|||||||
||
|
||
|
||||||
(sm=getenv("PS_SYSTEM_MAP"))
|
(sm=getenv("PS_SYSTEM_MAP"))
|
||||||
){
|
){
|
||||||
|
if(!have_privs){
|
||||||
read_and_parse();
|
read_and_parse();
|
||||||
if(sysmap_mmap(sm, message)) return 0;
|
if(sysmap_mmap(sm, message)) return 0;
|
||||||
|
}
|
||||||
/* failure is better than ignoring the user & using bad data */
|
/* failure is better than ignoring the user & using bad data */
|
||||||
return -1; /* ought to return "Namelist not found." */
|
return -1; /* ought to return "Namelist not found." */
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
# for --version-script
|
# for --version-script
|
||||||
# WTF is the syntax for this file?
|
# WTF is the syntax for this file?
|
||||||
# Give me a BNF, man!
|
# Give me a BNF, man!
|
||||||
_3_2_4 {
|
_3_2_5 {
|
||||||
global:
|
global:
|
||||||
__cyg_profile_func_enter; __cyg_profile_func_exit; main;
|
__cyg_profile_func_enter; __cyg_profile_func_exit; main;
|
||||||
|
|
||||||
@ -10,7 +10,7 @@ global:
|
|||||||
openproc; closeproc;
|
openproc; closeproc;
|
||||||
tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; lookup_wchan;
|
tty_to_dev; dev_to_tty; open_psdb_message; open_psdb; lookup_wchan;
|
||||||
display_version; procps_version; linux_version_code;
|
display_version; procps_version; linux_version_code;
|
||||||
Hertz; smp_num_cpus;
|
Hertz; smp_num_cpus; have_privs;
|
||||||
sprint_uptime; uptime; user_from_uid; print_uptime; loadavg;
|
sprint_uptime; uptime; user_from_uid; print_uptime; loadavg;
|
||||||
pretty_print_signals; print_given_signals; unix_print_signals; signal_name_to_number; signal_number_to_name;
|
pretty_print_signals; print_given_signals; unix_print_signals; signal_name_to_number; signal_number_to_name;
|
||||||
meminfo; vminfo; getstat; getdiskstat; getpartitions_num; getslabinfo; get_pid_digits;
|
meminfo; vminfo; getstat; getdiskstat; getpartitions_num; getslabinfo; get_pid_digits;
|
||||||
|
@ -170,8 +170,13 @@ static void old_Hertz_hack(void){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// same as: euid != uid || egid != gid
|
||||||
|
#ifndef AT_SECURE
|
||||||
|
#define AT_SECURE 23 // secure mode boolean (true if setuid, etc.)
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef AT_CLKTCK
|
#ifndef AT_CLKTCK
|
||||||
#define AT_CLKTCK 17 /* frequency of times() */
|
#define AT_CLKTCK 17 // frequency of times()
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define NOTE_NOT_FOUND 42
|
#define NOTE_NOT_FOUND 42
|
||||||
@ -189,8 +194,21 @@ static unsigned long find_elf_note(unsigned long findme){
|
|||||||
return NOTE_NOT_FOUND;
|
return NOTE_NOT_FOUND;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int have_privs;
|
||||||
|
|
||||||
|
static int check_for_privs(void){
|
||||||
|
unsigned long rc = find_elf_note(AT_SECURE);
|
||||||
|
if(rc==NOTE_NOT_FOUND){
|
||||||
|
// not valid to run this code after UID or GID change!
|
||||||
|
// (if needed, may use AT_UID and friends instead)
|
||||||
|
rc = geteuid() != getuid() || getegid() != getgid();
|
||||||
|
}
|
||||||
|
return !!rc;
|
||||||
|
}
|
||||||
|
|
||||||
static void init_libproc(void) __attribute__((constructor));
|
static void init_libproc(void) __attribute__((constructor));
|
||||||
static void init_libproc(void){
|
static void init_libproc(void){
|
||||||
|
have_privs = check_for_privs();
|
||||||
// ought to count CPUs in /proc/stat instead of relying
|
// ought to count CPUs in /proc/stat instead of relying
|
||||||
// on glibc, which foolishly tries to parse /proc/cpuinfo
|
// on glibc, which foolishly tries to parse /proc/cpuinfo
|
||||||
//
|
//
|
||||||
|
@ -8,6 +8,7 @@ EXTERN_C_BEGIN
|
|||||||
|
|
||||||
extern unsigned long long Hertz; /* clock tick frequency */
|
extern unsigned long long Hertz; /* clock tick frequency */
|
||||||
extern long smp_num_cpus; /* number of CPUs */
|
extern long smp_num_cpus; /* number of CPUs */
|
||||||
|
extern int have_privs; /* boolean, true if setuid or similar */
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
#define JT double
|
#define JT double
|
||||||
|
Loading…
Reference in New Issue
Block a user