mirror of
https://git.FreeBSD.org/src.git
synced 2025-01-03 12:35:02 +00:00
Handle the cases where NULL is passed as cap_rightsp to the
filestat_new_entry() function. Reported by: Alex Kozlov <spam@rm-rf.kiev.ua> Approved by: re (gjb)
This commit is contained in:
parent
5f3850777e
commit
772f66457a
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=256242
@ -61,6 +61,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <sys/conf.h>
|
||||
#include <sys/ksem.h>
|
||||
#include <sys/mman.h>
|
||||
#include <sys/capability.h>
|
||||
#define _KERNEL
|
||||
#include <sys/mount.h>
|
||||
#include <sys/pipe.h>
|
||||
@ -395,7 +396,10 @@ filestat_new_entry(void *typedep, int type, int fd, int fflags, int uflags,
|
||||
entry->fs_ref_count = refcount;
|
||||
entry->fs_offset = offset;
|
||||
entry->fs_path = path;
|
||||
entry->fs_cap_rights = *cap_rightsp;
|
||||
if (cap_rightsp != NULL)
|
||||
entry->fs_cap_rights = *cap_rightsp;
|
||||
else
|
||||
cap_rights_init(&entry->fs_cap_rights);
|
||||
return (entry);
|
||||
}
|
||||
|
||||
@ -478,21 +482,21 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
|
||||
/* root directory vnode, if one. */
|
||||
if (filed.fd_rdir) {
|
||||
entry = filestat_new_entry(filed.fd_rdir, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, 0);
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_RDIR, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
/* current working directory vnode. */
|
||||
if (filed.fd_cdir) {
|
||||
entry = filestat_new_entry(filed.fd_cdir, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, 0);
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_CDIR, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
/* jail root, if any. */
|
||||
if (filed.fd_jdir) {
|
||||
entry = filestat_new_entry(filed.fd_jdir, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, 0);
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_JAIL, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
@ -500,14 +504,14 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
|
||||
if (kp->ki_tracep) {
|
||||
entry = filestat_new_entry(kp->ki_tracep, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
|
||||
PS_FST_UFLAG_TRACE, 0, 0, NULL, 0);
|
||||
PS_FST_UFLAG_TRACE, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
/* text vnode, if one */
|
||||
if (kp->ki_textvp) {
|
||||
entry = filestat_new_entry(kp->ki_textvp, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, 0);
|
||||
PS_FST_FFLAG_READ, PS_FST_UFLAG_TEXT, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
@ -515,7 +519,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
|
||||
if ((vp = getctty(kd, kp)) != NULL) {
|
||||
entry = filestat_new_entry(vp, PS_FST_TYPE_VNODE, -1,
|
||||
PS_FST_FFLAG_READ | PS_FST_FFLAG_WRITE,
|
||||
PS_FST_UFLAG_CTTY, 0, 0, NULL, 0);
|
||||
PS_FST_UFLAG_CTTY, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
@ -578,7 +582,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
|
||||
}
|
||||
/* XXXRW: No capability rights support for kvm yet. */
|
||||
entry = filestat_new_entry(data, type, i,
|
||||
to_filestat_flags(file.f_flag), 0, 0, 0, NULL, 0);
|
||||
to_filestat_flags(file.f_flag), 0, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
@ -637,7 +641,7 @@ procstat_getfiles_kvm(struct procstat *procstat, struct kinfo_proc *kp, int mmap
|
||||
*/
|
||||
entry = filestat_new_entry(object.handle,
|
||||
PS_FST_TYPE_VNODE, -1, fflags,
|
||||
PS_FST_UFLAG_MMAP, 0, 0, NULL, 0);
|
||||
PS_FST_UFLAG_MMAP, 0, 0, NULL, NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
@ -878,7 +882,7 @@ procstat_getfiles_sysctl(struct procstat *procstat, struct kinfo_proc *kp,
|
||||
path = NULL;
|
||||
entry = filestat_new_entry(kve, PS_FST_TYPE_VNODE, -1,
|
||||
fflags, PS_FST_UFLAG_MMAP, refcount, offset, path,
|
||||
0);
|
||||
NULL);
|
||||
if (entry != NULL)
|
||||
STAILQ_INSERT_TAIL(head, entry, next);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user