Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/netbsd-3]: src/sys/kern Pull up revision 1.20 (requested by elad in tick...
details: https://anonhg.NetBSD.org/src/rev/2a90ccf1c02d
branches: netbsd-3
changeset: 576357:2a90ccf1c02d
user: tron <tron%NetBSD.org@localhost>
date: Sat Jul 02 15:46:46 2005 +0000
description:
Pull up revision 1.20 (requested by elad in ticket #487):
More veriexec refactoring.
- Use u_char for the fingerprint status.
- Add a pointer to the vnode's veriexec hash table entry in the vnode
struct. This saves a lookup and will also used by planned features.
- When removing a file from the tables, set the vnode fingerprint status
to NOENTRY.
- Add switch to do flag-specific handling in veriexec_verify(). At the
moment this prevents execution of FILE entries in strict level 2, but
it will also be used by planned features.
- Use memset() instead of bzero().
- Various cosmetic changes.
diffstat:
sys/kern/kern_verifiedexec.c | 50 +++++++++++++++++++++++++++++--------------
1 files changed, 33 insertions(+), 17 deletions(-)
diffs (128 lines):
diff -r 565efecdc095 -r 2a90ccf1c02d sys/kern/kern_verifiedexec.c
--- a/sys/kern/kern_verifiedexec.c Sat Jul 02 15:46:26 2005 +0000
+++ b/sys/kern/kern_verifiedexec.c Sat Jul 02 15:46:46 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_verifiedexec.c,v 1.9.2.10 2005/06/10 15:25:14 tron Exp $ */
+/* $NetBSD: kern_verifiedexec.c,v 1.9.2.11 2005/07/02 15:46:46 tron Exp $ */
/*-
* Copyright 2005 Elad Efrat <elad%bsd.org.il@localhost>
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_verifiedexec.c,v 1.9.2.10 2005/06/10 15:25:14 tron Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_verifiedexec.c,v 1.9.2.11 2005/07/02 15:46:46 tron Exp $");
#include <sys/param.h>
#include <sys/mount.h>
@@ -215,8 +215,7 @@
panic("veriexec: Operations vector is NULL");
}
- bzero(fp, vhe->ops->hash_len);
-
+ memset(fp, 0, vhe->ops->hash_len);
ctx = (void *) malloc(vhe->ops->context_size, M_TEMP, M_WAITOK);
buf = (u_char *) malloc(PAGE_SIZE, M_TEMP, M_WAITOK);
@@ -243,11 +242,11 @@
if (error)
goto bad;
- /* calculate fingerprint for each chunk */
+ /* calculate fingerprint for each chunk */
(vhe->ops->update)(ctx, buf, (unsigned int) len);
}
- /* finalise the fingerprint calculation */
+ /* finalise the fingerprint calculation */
(vhe->ops->final)(fp, ctx);
bad:
@@ -354,26 +353,25 @@
veriexec_verify(struct proc *p, struct vnode *vp, struct vattr *va,
const u_char *name, int flag)
{
- struct veriexec_hash_entry *vhe;
u_char *digest;
int error = 0;
/* Evaluate fingerprint if needed and set the status on the vp. */
- if (vp->fp_status == FINGERPRINT_NOTEVAL) {
- vhe = veriexec_lookup(va->va_fsid, va->va_fileid);
- if (vhe == NULL) {
+ if ((vp->vhe == NULL) || (vp->fp_status == FINGERPRINT_NOTEVAL)) {
+ vp->vhe = veriexec_lookup(va->va_fsid, va->va_fileid);
+ if (vp->vhe == NULL) {
vp->fp_status = FINGERPRINT_NOENTRY;
goto out;
}
-
+
veriexec_dprintf(("veriexec: veriexec_verify: Got entry for "
"%s. (dev=%d, inode=%u)\n", name,
va->va_fsid, va->va_fileid));
- /* Calculate fingerprint for the inode. */
- digest = (u_char *) malloc(vhe->ops->hash_len, M_TEMP,
+ digest = (u_char *) malloc(vp->vhe->ops->hash_len, M_TEMP,
M_WAITOK);
- error = veriexec_fp_calc(p, vp, vhe, va->va_size, digest);
+ error = veriexec_fp_calc(p, vp, vp->vhe, va->va_size,
+digest);
if (error) {
veriexec_dprintf(("veriexec: veriexec_verify: "
@@ -382,8 +380,8 @@
return (error);
}
- if (veriexec_fp_cmp(vhe->ops, vhe->fp, digest) == 0) {
- if (vhe->type == VERIEXEC_INDIRECT) {
+ if (veriexec_fp_cmp(vp->vhe->ops, vp->vhe->fp, digest) == 0) {
+ if (vp->vhe->type == VERIEXEC_INDIRECT) {
vp->fp_status = FINGERPRINT_INDIRECT;
} else {
vp->fp_status = FINGERPRINT_VALID;
@@ -394,6 +392,22 @@
free(digest, M_TEMP);
}
+ switch (flag) {
+ case VERIEXEC_DIRECT:
+ case VERIEXEC_INDIRECT:
+ break;
+ case VERIEXEC_FILE:
+ if (vp->vhe->type != VERIEXEC_FILE) {
+ veriexec_report("Execution of 'FILE' entry.",
+ name, va, p, REPORT_NOVERBOSE,
+ REPORT_ALARM, REPORT_NOPANIC);
+
+ if (veriexec_strict > 1)
+ return (EPERM);
+ }
+ break;
+ }
+
out:
switch (vp->fp_status) {
case FINGERPRINT_NOTEVAL:
@@ -443,7 +457,7 @@
p, REPORT_VERBOSE, REPORT_NOALARM, REPORT_NOPANIC);
/* We don't care about these in learning mode. */
- if (veriexec_strict < 1) {
+ if (veriexec_strict == 0) {
break;
}
@@ -561,6 +575,8 @@
free(vhe->fp, M_TEMP);
free(vhe, M_TEMP);
tbl->hash_count--;
+ vp->fp_status = FINGERPRINT_NOENTRY;
+ vp->vhe = NULL;
return (error);
}
Home |
Main Index |
Thread Index |
Old Index