summaryrefslogtreecommitdiffstats
path: root/usr.bin/fstat/fstat.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2005-01-29 11:38:00 +0000
committerphk <phk@FreeBSD.org>2005-01-29 11:38:00 +0000
commit56bc3e6bfc46537d319bfcac92dd65bcfd93788a (patch)
treeb71b092b2f321dbbc9c070f9b4ef759bd2bdbce9 /usr.bin/fstat/fstat.c
parentc73fd1a2390c7c535d3076f99de6b1d4d9eb2882 (diff)
downloadFreeBSD-src-56bc3e6bfc46537d319bfcac92dd65bcfd93788a.zip
FreeBSD-src-56bc3e6bfc46537d319bfcac92dd65bcfd93788a.tar.gz
Report jail directory if set.
Sanity-check fd_lastfile. PR: 62699 Patch by: "Mark W. Krentel" <krentel@dreamscape.com>
Diffstat (limited to 'usr.bin/fstat/fstat.c')
-rw-r--r--usr.bin/fstat/fstat.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/usr.bin/fstat/fstat.c b/usr.bin/fstat/fstat.c
index a20469e..86eee92 100644
--- a/usr.bin/fstat/fstat.c
+++ b/usr.bin/fstat/fstat.c
@@ -106,6 +106,7 @@ __FBSDID("$FreeBSD$");
#define RDIR -3
#define TRACE -4
#define MMAP -5
+#define JDIR -6
DEVS *devs;
@@ -309,6 +310,9 @@ int Pid;
case MMAP: \
printf(" mmap"); \
break; \
+ case JDIR: \
+ printf(" jail"); \
+ break; \
default: \
printf(" %4d", i); \
break; \
@@ -345,6 +349,11 @@ dofiles(struct kinfo_proc *kp)
*/
vtrans(filed.fd_cdir, CDIR, FREAD);
/*
+ * jail root, if any.
+ */
+ if (filed.fd_jdir)
+ vtrans(filed.fd_jdir, JDIR, FREAD);
+ /*
* ktrace vnode, if one
*/
if (kp->ki_tracep)
@@ -358,6 +367,12 @@ dofiles(struct kinfo_proc *kp)
* open files
*/
#define FPSIZE (sizeof (struct file *))
+#define MAX_LASTFILE (0x1000000)
+
+ /* Sanity check on filed.fd_lastfile */
+ if (filed.fd_lastfile <= -1 || filed.fd_lastfile > MAX_LASTFILE)
+ return;
+
ALLOC_OFILES(filed.fd_lastfile+1);
if (!KVM_READ(filed.fd_ofiles, ofiles,
(filed.fd_lastfile+1) * FPSIZE)) {
OpenPOWER on IntegriCloud