[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20081020205707.GA24476@kroah.com>
Date: Mon, 20 Oct 2008 13:57:07 -0700
From: Greg KH <greg@...ah.com>
To: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
Cc: Greg Kroah-Hartman <gregkh@...e.de>, linux-kernel@...r.kernel.org,
Andrew Morton <akpm@...ux-foundation.org>,
Kay Sievers <kay.sievers@...y.org>
Subject: Re: [PATCH 02/46] sysfs: crash debugging
On Thu, Oct 16, 2008 at 01:40:56PM -0400, Mathieu Desnoyers wrote:
> * Greg Kroah-Hartman (gregkh@...e.de) wrote:
> > From: Andrew Morton <akpm@...ux-foundation.org>
> >
> > Print the name of the last-accessed sysfs file when we oops, to help track
> > down oopses which occur in sysfs store/read handlers. Because these oopses
> > tend to not leave any trace of the offending code in the stack traces.
> >
> > Cc: Kay Sievers <kay.sievers@...y.org>
> > Cc: Mathieu Desnoyers <mathieu.desnoyers@...ymtl.ca>
> > Signed-off-by: Andrew Morton <akpm@...ux-foundation.org>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@...e.de>
> > ---
> > arch/x86/kernel/dumpstack_32.c | 2 ++
> > arch/x86/kernel/dumpstack_64.c | 2 ++
> > fs/sysfs/file.c | 13 +++++++++++++
> > include/linux/sysfs.h | 6 ++++++
> > 4 files changed, 23 insertions(+), 0 deletions(-)
> >
> > diff --git a/arch/x86/kernel/dumpstack_32.c b/arch/x86/kernel/dumpstack_32.c
> > index 201ee35..1a78180 100644
> > --- a/arch/x86/kernel/dumpstack_32.c
> > +++ b/arch/x86/kernel/dumpstack_32.c
> > @@ -13,6 +13,7 @@
> > #include <linux/kexec.h>
> > #include <linux/bug.h>
> > #include <linux/nmi.h>
> > +#include <linux/sysfs.h>
> >
> > #include <asm/stacktrace.h>
> >
> > @@ -343,6 +344,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
> > printk("DEBUG_PAGEALLOC");
> > #endif
> > printk("\n");
> > + sysfs_printk_last_file();
> > if (notify_die(DIE_OOPS, str, regs, err,
> > current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
> > return 1;
> > diff --git a/arch/x86/kernel/dumpstack_64.c b/arch/x86/kernel/dumpstack_64.c
> > index 086cc81..96a5db7 100644
> > --- a/arch/x86/kernel/dumpstack_64.c
> > +++ b/arch/x86/kernel/dumpstack_64.c
> > @@ -13,6 +13,7 @@
> > #include <linux/kexec.h>
> > #include <linux/bug.h>
> > #include <linux/nmi.h>
> > +#include <linux/sysfs.h>
> >
> > #include <asm/stacktrace.h>
> >
> > @@ -489,6 +490,7 @@ int __kprobes __die(const char *str, struct pt_regs *regs, long err)
> > printk("DEBUG_PAGEALLOC");
> > #endif
> > printk("\n");
> > + sysfs_printk_last_file();
> > if (notify_die(DIE_OOPS, str, regs, err,
> > current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
> > return 1;
> > diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c
> > index c9e4e50..ce8339c 100644
> > --- a/fs/sysfs/file.c
> > +++ b/fs/sysfs/file.c
> > @@ -19,10 +19,18 @@
> > #include <linux/poll.h>
> > #include <linux/list.h>
> > #include <linux/mutex.h>
> > +#include <linux/limits.h>
> > #include <asm/uaccess.h>
> >
> > #include "sysfs.h"
> >
> > +/* used in crash dumps to help with debugging */
> > +static char last_sysfs_file[PATH_MAX];
> > +void sysfs_printk_last_file(void)
> > +{
> > + printk(KERN_EMERG "last sysfs file: %s\n", last_sysfs_file);
> > +}
> > +
> > /*
> > * There's one sysfs_buffer for each open file and one
> > * sysfs_open_dirent for each sysfs_dirent with one or more open
> > @@ -328,6 +336,11 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
> > struct sysfs_buffer *buffer;
> > struct sysfs_ops *ops;
> > int error = -EACCES;
> > + char *p;
> > +
> > + p = d_path(&file->f_path, last_sysfs_file, sizeof(last_sysfs_file));
> > + if (p)
>
> if (!IS_ERR(p)) ?
>
> > + memmove(last_sysfs_file, p, strlen(p) + 1);
> >
>
> Given we do a strlen() here anyway, shouldn't we just use strcpy ?
Probably would be good.
Care to send a patch for both of these?
thanks,
greg k-h
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists