Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs don't crash when printing error messages when th...
details: https://anonhg.NetBSD.org/src/rev/0bb21589ec81
branches: trunk
changeset: 339747:0bb21589ec81
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Sat Aug 08 08:18:52 2015 +0000
description:
don't crash when printing error messages when there are no credentials.
don't abuse the printed uid to log the inode number.
The printing/logging of error messages should be simplified.
diffstat:
sys/ufs/ffs/ffs_alloc.c | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diffs (84 lines):
diff -r 06e94f73efab -r 0bb21589ec81 sys/ufs/ffs/ffs_alloc.c
--- a/sys/ufs/ffs/ffs_alloc.c Sat Aug 08 07:53:51 2015 +0000
+++ b/sys/ufs/ffs/ffs_alloc.c Sat Aug 08 08:18:52 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_alloc.c,v 1.149 2015/03/28 19:24:04 maxv Exp $ */
+/* $NetBSD: ffs_alloc.c,v 1.150 2015/08/08 08:18:52 mlelstv Exp $ */
/*-
* Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.149 2015/03/28 19:24:04 maxv Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ffs_alloc.c,v 1.150 2015/08/08 08:18:52 mlelstv Exp $");
#if defined(_KERNEL_OPT)
#include "opt_ffs.h"
@@ -111,7 +111,7 @@
static daddr_t ffs_alloccgblk(struct inode *, struct buf *, daddr_t, int);
static ino_t ffs_dirpref(struct inode *);
static daddr_t ffs_fragextend(struct inode *, int, daddr_t, int, int);
-static void ffs_fserr(struct fs *, u_int, const char *);
+static void ffs_fserr(struct fs *, kauth_cred_t, const char *);
static daddr_t ffs_hashalloc(struct inode *, int, daddr_t, int, int,
daddr_t (*)(struct inode *, int, daddr_t, int, int));
static daddr_t ffs_nodealloccg(struct inode *, int, daddr_t, int, int);
@@ -145,7 +145,7 @@
if (bno >= fs->fs_size) {
printf("bad block %" PRId64 ", ino %llu\n", bno,
(unsigned long long)inum);
- ffs_fserr(fs, inum, "bad block");
+ ffs_fserr(fs, NOCRED, "bad block");
return EINVAL;
}
return 0;
@@ -286,7 +286,7 @@
}
nospace:
mutex_exit(&ump->um_lock);
- ffs_fserr(fs, kauth_cred_geteuid(cred), "file system full");
+ ffs_fserr(fs, cred, "file system full");
uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt);
return (ENOSPC);
}
@@ -532,7 +532,7 @@
/*
* no space available
*/
- ffs_fserr(fs, kauth_cred_geteuid(cred), "file system full");
+ ffs_fserr(fs, cred, "file system full");
uprintf("\n%s: write failed, file system is full\n", fs->fs_fsmnt);
return (ENOSPC);
}
@@ -605,7 +605,7 @@
noinodes:
mutex_exit(&ump->um_lock);
UFS_WAPBL_END(pvp->v_mount);
- ffs_fserr(fs, kauth_cred_geteuid(cred), "out of inodes");
+ ffs_fserr(fs, cred, "out of inodes");
uprintf("\n%s: create/symlink failed, no inodes free\n", fs->fs_fsmnt);
return ENOSPC;
}
@@ -2159,9 +2159,17 @@
* fs: error message
*/
static void
-ffs_fserr(struct fs *fs, u_int uid, const char *cp)
+ffs_fserr(struct fs *fs, kauth_cred_t cred, const char *cp)
{
+ KASSERT(cred != NULL);
- log(LOG_ERR, "uid %d, pid %d, command %s, on %s: %s\n",
- uid, curproc->p_pid, curproc->p_comm, fs->fs_fsmnt, cp);
+ if (cred == NOCRED || cred == FSCRED) {
+ log(LOG_ERR, "pid %d, command %s, on %s: %s\n",
+ curproc->p_pid, curproc->p_comm,
+ fs->fs_fsmnt, cp);
+ } else {
+ log(LOG_ERR, "uid %d, pid %d, command %s, on %s: %s\n",
+ kauth_cred_getuid(cred), curproc->p_pid, curproc->p_comm,
+ fs->fs_fsmnt, cp);
+ }
}
Home |
Main Index |
Thread Index |
Old Index