PATCH some cleanups and security fixes
Greg KH
AppliedQuoted 6 lines · Harald Hoyer
posted by Steve Grubb on
https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id0351
tdb/spinlock.c line 29
Quoted 8 lines
tdb/spinlock.c renamed from tdb/spinlock.c.rhsec +1
-1@@ -23,7 +23,7 @@#define HAVE_MMAP 1#include "../udev.h" -#if HAVE_CONFIG_H +#ifdef HAVE_CONFIG_H #include <config.h> #endif
Not needed.
udevstart.c line 217
Quoted 11 lines
udevstart.c renamed from udevstart.c.rhsec +1
-1@@ -211,7 +211,7 @@ dir2 =opendir (dirname);if (dir2 !=NULL ) {for (dent2 =readdir (dir2); dent2 !=NULL ; dent2 =readdir (dir2)) { -char dirname2[MAX_PATHLEN -1 ]; +char dirname2[MAX_PATHLEN ];DIR *dir3;struct dirent *dent3;
Applied.
namedev.c line 356
Quoted 11 lines
namedev.c renamed from namedev.c.rhsec +1
-1@@ -350,7 +350,7 @@ { .bus = "usb-serial", .file = "detach_state" }, { .bus = "ide", .file = "detach_state" }, { .bus = "pci", .file = "vendor" }, - {} + { NULL, NULL } };#define SECONDS_TO_WAIT_FOR_FILE 10
Not needed.
Quoted 76 lines
udevd.c renamed from udevd.c.rhsec +32
-5@@ -45,9 +45,9 @@static int pipefds[2 ];static long expected_seqnum =0 ; -volatile static int children_waiting; -volatile static int run_msg_q; -volatile static int sig_flag; +static volatile int children_waiting; +static volatile int run_msg_q; +static volatile int sig_flag;static int run_exec_q;static LIST_HEAD (msg_list);@@ -398,7 +398,7 @@int ssock, maxsockplus;struct sockaddr_un saddr;socklen_t addrlen; -int retval; +int retval, fd;const int on =1 ;struct sigaction act;fd_set readfds;@@ -410,6 +410,22 @@dbg ("need to be root, exit" );exit (1 ); } +/* make sure we are at top of dir */ +chdir ("/" ); +umask (umask (077 ) |022 ); +/* Set fds to dev/null */ + fd =open ("/dev/null" ,O_RDWR ); +if ( fd <0 ) { +dbg ("error opening /dev/null %s" ,strerror (errno)); +exit (1 ); + } +dup2 (fd,0 ); +dup2 (fd,1 ); +dup2 (fd,2 ); +if (fd >2 ) +close (fd); +/* Get new session id so stray signals don't come our way. */ +setsid ();/* setup signal handler pipe */ retval =pipe (pipefds);@@ -419,7 +435,12 @@ } retval =fcntl (pipefds[0 ],F_SETFL ,O_NONBLOCK ); -if (retval <0 ) { +if (retval <0 ) { +dbg ("error fcntl on read pipe: %s" ,strerror (errno)); +exit (1 ); + } + retval =fcntl (pipefds[0 ],F_SETFD ,FD_CLOEXEC ); +if (retval <0 ) {dbg ("error fcntl on read pipe: %s" ,strerror (errno));exit (1 ); }@@ -429,7 +450,13 @@dbg ("error fcntl on write pipe: %s" ,strerror (errno));exit (1 ); } + retval =fcntl (pipefds[1 ],F_SETFD ,FD_CLOEXEC ); +if (retval <0 ) { +dbg ("error fcntl on write pipe: %s" ,strerror (errno)); +exit (1 ); + } +/* set signal handlers */ act.sa_handler = sig_handler;sigemptyset (&act.sa_mask);
udevd.c line 492
Quoted 9 lines
udevd.c renamed from udevd.c.rhsec +5
-0@@ -457,15 +484,22 @@dbg ("bind failed, exit" ); goto exit; } + retval =fcntl (ssock,F_SETFD ,FD_CLOEXEC ); +if (retval <0 ) { +dbg ("error fcntl on ssock: %s" ,strerror (errno)); +exit (1 ); + }
Applied.
udevd.c line 505
Quoted 13 lines
udevd.c renamed from udevd.c.rhsec +2
-0/* enable receiving of the sender credentials */ setsockopt (ssock,SOL_SOCKET ,SO_PASSCRED , &on,sizeof (on));/* possible override of udev binary, used for testing */ +#ifdef DEBUG udev_bin =getenv ("UDEV_BIN" );if (udev_bin !=NULL )dbg ("udev binary is set to '%s'" , udev_bin); else +#endif udev_bin =UDEV_BIN ;FD_ZERO (&readfds);
Not applied.
dev_d.c line 84
Quoted 10 lines
dev_d.c renamed from dev_d.c.rhsec +1
-0@@ -78,6 +78,7 @@strfieldcpy (env_devname, dev->name);setenv ("DEVPATH" , devpath,1 ); } +else env_devname[0 ] =0 ;setenv ("DEVNAME" , env_devname,1 );dbg ("DEVNAME='%s'" , env_devname);
I fixed this up by hand.
udev-remove.c line 111
Quoted 11 lines
udev-remove.c renamed from udev-remove.c.rhsec +1
-1@@ -105,7 +105,7 @@char filename[NAME_SIZE ];char linkname[NAME_SIZE ];char partitionname[NAME_SIZE ]; -int retval; +int retval =0 ;int i;char *pos;int len;
Not needed.
thanks,
greg k-h
-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal Use IT products in your business? Tell us what you think of them. Give us Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
Linux-hotplug-devel mailing list http://linux-hotplug.sourceforge.net
[email protected]
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel