Date: Tue, 25 Jan 2000 17:01:48 -0800 (PST) From: Michael Oswell <oswell@xcert.com> To: freebsd-security@FreeBSD.ORG Subject: make -j vulnerability && FreeBSD 2.2.x Message-ID: <Pine.BSF.4.21.0001251654410.34816-100000@oswell.x509.com>
next in thread | raw e-mail | index | archive | help
It seems that the patch that was released for the make vulnerability a few
days ago is not relevant to machines running FreeBSD 2.2.x. I manually
entered the changes from the patch which was released into the Make source
on a FreeBSD 2.2.8 box, as well as a few other minor changes to make it
compile. I have attached my new patch below in case it is of interest to
anyone.
I make no guarentees that this patch is correct, and would appreciate it
if anyone could verify that it does indeed fix the problem. Also, if a
patch has already been released for 2.2.x machines to fix this problem,
please let me know.
Thanks.
*** job.c Tue Jan 25 16:37:52 2000
--- job.c.patched Tue Jan 25 16:47:58 2000
***************
*** 157,173 ****
#define JOB_FINISHED 2 /* The job is already finished */
#define JOB_STOPPED 3 /* The job is stopped */
/*
- * tfile is the name of a file into which all shell commands are put. It is
- * used over by removing it before the child shell is executed. The XXXXX in
- * the string are replaced by the pid of the make process in a 5-character
- * field with leading zeroes.
- */
- static char tfile[] = TMPPAT;
-
-
- /*
* Descriptions for various shells.
*/
static Shell shells[] = {
/*
--- 157,164 ----
***************
*** 988,996 ****
if ((aborting == ABORT_ERROR) && Job_Empty()) {
/*
* If we are aborting and the job table is now empty, we finish.
*/
! (void) eunlink(tfile);
Finish(errors);
}
}
--- 979,987 ----
if ((aborting == ABORT_ERROR) && Job_Empty()) {
/*
* If we are aborting and the job table is now empty, we finish.
*/
! (void) eunlink(job->tfile);
Finish(errors);
}
}
***************
*** 1661,1668 ****
--- 1652,1660 ----
static int jobno = 0; /* job number of catching output in a file */
Boolean cmdsOK; /* true if the nodes commands were all right */
Boolean local; /* Set true if the job was run locally */
Boolean noExec; /* Set true if we decide not to run the job */
+ int tfd; /* File descriptor for temp file */
if (previous != NULL) {
previous->flags &= ~(JOB_FIRST|JOB_IGNERR|JOB_SILENT|JOB_REMOTE);
job = previous;
***************
*** 1690,1697 ****
--- 1682,1695 ----
job->flags |= JOB_SILENT;
}
job->flags |= flags;
+ (void) strcpy(job->tfile, TMPPAT);
+ if ((tfd = mkstemp(job->tfile)) == -1)
+ Punt("cannot create temp file: %s", strerror(errno));
+ else
+ (void) close(tfd);
+
/*
* Check the commands now so any attributes from .DEFAULT have a chance
* to migrate to the node
*/
***************
*** 1715,1725 ****
if (!cmdsOK) {
DieHorribly();
}
! job->cmdFILE = fopen(tfile, "w+");
if (job->cmdFILE == NULL) {
! Punt("Could not open %s", tfile);
}
(void) fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
/*
* Send the commands to the command file, flush all its buffers then
--- 1713,1723 ----
if (!cmdsOK) {
DieHorribly();
}
! job->cmdFILE = fopen(job->tfile, "w+");
if (job->cmdFILE == NULL) {
! Punt("Could not open %s", job->tfile);
}
(void) fcntl(FILENO(job->cmdFILE), F_SETFD, 1);
/*
* Send the commands to the command file, flush all its buffers then
***************
*** 1823,1831 ****
/*
* Unlink and close the command file if we opened one
*/
if (job->cmdFILE != stdout) {
! (void) eunlink(tfile);
if (job->cmdFILE != NULL)
(void) fclose(job->cmdFILE);
} else {
(void) fflush(stdout);
--- 1821,1829 ----
/*
* Unlink and close the command file if we opened one
*/
if (job->cmdFILE != stdout) {
! (void) eunlink(job->tfile);
if (job->cmdFILE != NULL)
(void) fclose(job->cmdFILE);
} else {
(void) fflush(stdout);
***************
*** 1851,1859 ****
return(JOB_ERROR);
}
} else {
(void) fflush(job->cmdFILE);
! (void) eunlink(tfile);
}
/*
* Set up the control arguments to the shell. This is based on the flags
--- 1849,1857 ----
return(JOB_ERROR);
}
} else {
(void) fflush(job->cmdFILE);
! (void) eunlink(job->tfile);
}
/*
* Set up the control arguments to the shell. This is based on the flags
***************
*** 1878,1886 ****
(void) fcntl(job->outPipe, F_SETFD, 1);
} else {
(void) fprintf(stdout, "Remaking `%s'\n", gn->name);
(void) fflush(stdout);
! sprintf(job->outFile, "%s%02d", tfile, jobno);
jobno = (jobno + 1) % 100;
job->outFd = open(job->outFile,O_WRONLY|O_CREAT|O_APPEND,0600);
(void) fcntl(job->outFd, F_SETFD, 1);
}
--- 1876,1884 ----
(void) fcntl(job->outPipe, F_SETFD, 1);
} else {
(void) fprintf(stdout, "Remaking `%s'\n", gn->name);
(void) fflush(stdout);
! sprintf(job->outFile, "%s%02d", job->tfile, jobno);
jobno = (jobno + 1) % 100;
job->outFd = open(job->outFile,O_WRONLY|O_CREAT|O_APPEND,0600);
(void) fcntl(job->outFd, F_SETFD, 1);
}
***************
*** 2397,2406 ****
* be running at once. */
{
GNode *begin; /* node for commands to do at the very start */
- (void) sprintf(tfile, "/tmp/make%05d", getpid());
-
jobs = Lst_Init(FALSE);
stoppedJobs = Lst_Init(FALSE);
maxJobs = maxproc;
maxLocal = maxlocal;
--- 2395,2402 ----
***************
*** 2902,2910 ****
#endif /* RMT_WILL_WATCH */
}
}
}
! (void) eunlink(tfile);
}
/*
*-----------------------------------------------------------------------
--- 2898,2906 ----
#endif /* RMT_WILL_WATCH */
}
}
}
! (void) eunlink(job->tfile);
}
/*
*-----------------------------------------------------------------------
***************
*** 2936,2944 ****
#endif /* RMT_WILL_WATCH */
}
}
}
- (void) eunlink(tfile);
return(errors);
}
/*-
--- 2932,2939 ----
***************
*** 3012,3028 ****
#else
KILL(job->pid, SIGINT);
KILL(job->pid, SIGKILL);
#endif /* RMT_WANTS_SIGNALS */
}
}
/*
* Catch as many children as want to report in at first, then give up
*/
while (waitpid((pid_t) -1, &foo, WNOHANG) > 0)
continue;
- (void) eunlink(tfile);
}
#ifdef REMOTE
/*-
--- 3007,3023 ----
#else
KILL(job->pid, SIGINT);
KILL(job->pid, SIGKILL);
#endif /* RMT_WANTS_SIGNALS */
+ (void) eunlink(job->tfile);
}
}
/*
* Catch as many children as want to report in at first, then give up
*/
while (waitpid((pid_t) -1, &foo, WNOHANG) > 0)
continue;
}
#ifdef REMOTE
/*-
*** job.h Tue Jan 25 16:38:16 2000
--- job.h.patched Tue Jan 25 16:38:13 2000
***************
*** 92,99 ****
--- 92,101 ----
*/
#define JOB_BUFSIZE 1024
typedef struct Job {
int pid; /* The child's process ID */
+ char tfile[sizeof(TMPPAT)];
+ /* Temporary file to use for job */
GNode *node; /* The target the child is making */
LstNode tailCmds; /* The node of the first command to be
* saved when the job has been run */
FILE *cmdFILE; /* When creating the shell script, this is
-----
Michael Oswell
Xcert International Inc.
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-security" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0001251654410.34816-100000>
