Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/filemon Retrieve the pathname of the exec'd file bef...
details: https://anonhg.NetBSD.org/src/rev/c76486b9f835
branches: trunk
changeset: 341802:c76486b9f835
user: pgoyette <pgoyette%NetBSD.org@localhost>
date: Mon Nov 23 00:47:43 2015 +0000
description:
Retrieve the pathname of the exec'd file before we call sys_execve().
We cannot rely on using copyinstr() to retrieve the pathname from
user mode after a successful exec, since the user mode address space
is no longer valid (and may not even be accessible). This worked in
earlier code but was broken by rev 1.7.
diffstat:
sys/dev/filemon/filemon_wrapper.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diffs (43 lines):
diff -r 7bbe2cf3e6f1 -r c76486b9f835 sys/dev/filemon/filemon_wrapper.c
--- a/sys/dev/filemon/filemon_wrapper.c Sun Nov 22 20:47:42 2015 +0000
+++ b/sys/dev/filemon/filemon_wrapper.c Mon Nov 23 00:47:43 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: filemon_wrapper.c,v 1.9 2015/11/22 01:20:52 pgoyette Exp $ */
+/* $NetBSD: filemon_wrapper.c,v 1.10 2015/11/23 00:47:43 pgoyette Exp $ */
/*
* Copyright (c) 2010, Juniper Networks, Inc.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.9 2015/11/22 01:20:52 pgoyette Exp $");
+__KERNEL_RCSID(0, "$NetBSD: filemon_wrapper.c,v 1.10 2015/11/23 00:47:43 pgoyette Exp $");
#include <sys/param.h>
#include <sys/types.h>
@@ -71,10 +71,12 @@
register_t * retval)
{
char fname[MAXPATHLEN];
- int error;
+ int error, cerror;
size_t done;
struct filemon *filemon;
-
+
+ cerror = copyinstr(SCARG(uap, path), fname, sizeof(fname), &done);
+
if ((error = sys_execve(l, uap, retval)) != EJUSTRETURN)
return error;
@@ -82,8 +84,7 @@
if (filemon == NULL)
return EJUSTRETURN;
- error = copyinstr(SCARG(uap, path), fname, sizeof(fname), &done);
- if (error)
+ if (cerror)
goto out;
filemon_printf(filemon, "E %d %s\n", curproc->p_pid, fname);
Home |
Main Index |
Thread Index |
Old Index