diff options
author | kib <kib@FreeBSD.org> | 2017-01-12 01:09:15 +0000 |
---|---|---|
committer | kib <kib@FreeBSD.org> | 2017-01-12 01:09:15 +0000 |
commit | 76bb2f371469f2763fb84f3bb3dd828f90420d2c (patch) | |
tree | a11407698afefec2bbded7a1e8e1675210b634c2 /sys/i386/ibcs2 | |
parent | c1d4c0bf60b7b59ca091fe19df87571815ba5485 (diff) | |
download | FreeBSD-src-76bb2f371469f2763fb84f3bb3dd828f90420d2c.zip FreeBSD-src-76bb2f371469f2763fb84f3bb3dd828f90420d2c.tar.gz |
MFC r311452:
Do not allocate struct statfs on kernel stack.
Diffstat (limited to 'sys/i386/ibcs2')
-rw-r--r-- | sys/i386/ibcs2/ibcs2_stat.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sys/i386/ibcs2/ibcs2_stat.c b/sys/i386/ibcs2/ibcs2_stat.c index 55d14af..115c2ae 100644 --- a/sys/i386/ibcs2/ibcs2_stat.c +++ b/sys/i386/ibcs2/ibcs2_stat.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include <sys/filedesc.h> #include <sys/jail.h> #include <sys/kernel.h> +#include <sys/malloc.h> #include <sys/mount.h> #include <sys/malloc.h> #include <sys/vnode.h> @@ -108,16 +109,18 @@ ibcs2_statfs(td, uap) struct thread *td; struct ibcs2_statfs_args *uap; { - struct statfs sf; + struct statfs *sf; char *path; int error; CHECKALTEXIST(td, uap->path, &path); - error = kern_statfs(td, path, UIO_SYSSPACE, &sf); + sf = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); + error = kern_statfs(td, path, UIO_SYSSPACE, sf); free(path, M_TEMP); - if (error) - return (error); - return cvt_statfs(&sf, (caddr_t)uap->buf, uap->len); + if (error == 0) + error = cvt_statfs(sf, (caddr_t)uap->buf, uap->len); + free(sf, M_STATFS); + return (error); } int @@ -125,13 +128,15 @@ ibcs2_fstatfs(td, uap) struct thread *td; struct ibcs2_fstatfs_args *uap; { - struct statfs sf; + struct statfs *sf; int error; - error = kern_fstatfs(td, uap->fd, &sf); - if (error) - return (error); - return cvt_statfs(&sf, (caddr_t)uap->buf, uap->len); + sf = malloc(sizeof(struct statfs), M_STATFS, M_WAITOK); + error = kern_fstatfs(td, uap->fd, sf); + if (error == 0) + error = cvt_statfs(sf, (caddr_t)uap->buf, uap->len); + free(sf, M_STATFS); + return (error); } int |