From 72c21479ae470cc38263a6d4f4fef6f1cbc10034 Mon Sep 17 00:00:00 2001 From: Andrea Arcangeli Date: Mon, 23 Aug 2004 21:26:07 -0700 Subject: [PATCH] [PATCH] Correctly handle d_path error returns There's some minor bug in the d_path handling (the nfsd one may not the the correct fix, there's no failure path for it, so I just terminate the string, and the last one in the audit subsystem is just a robustness cleanup if somebody will extend d_path in the future, right now it's a noop). Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/compat.c | 2 ++ fs/nfsd/export.c | 5 +++++ kernel/audit.c | 2 +- 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/compat.c b/fs/compat.c index 709a02fc8e501..3cddaab903548 100644 --- a/fs/compat.c +++ b/fs/compat.c @@ -429,6 +429,8 @@ asmlinkage long compat_sys_ioctl(unsigned int fd, unsigned int cmd, fn = d_path(filp->f_dentry, filp->f_vfsmnt, path, PAGE_SIZE); + if (IS_ERR(fn)) + fn = "?"; } sprintf(buf,"'%c'", (cmd>>24) & 0x3f); diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 3b9e865c4abc1..1a53ff65dc3f7 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c @@ -294,6 +294,11 @@ void svc_export_request(struct cache_detail *cd, qword_add(bpp, blen, exp->ex_client->name); pth = d_path(exp->ex_dentry, exp->ex_mnt, *bpp, *blen); + if (IS_ERR(pth)) { + /* is this correct? */ + (*bpp)[0] = '\n'; + return; + } qword_add(bpp, blen, pth); (*bpp)[-1] = '\n'; } diff --git a/kernel/audit.c b/kernel/audit.c index 765822b03b910..a86aaf2c8fadb 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -708,7 +708,7 @@ void audit_log_d_path(struct audit_buffer *ab, const char *prefix, audit_log_move(ab); avail = sizeof(ab->tmp) - ab->len; p = d_path(dentry, vfsmnt, ab->tmp + ab->len, avail); - if (p == ERR_PTR(-ENAMETOOLONG)) { + if (IS_ERR(p)) { /* FIXME: can we save some information here? */ audit_log_format(ab, ""); } else { -- 2.53.0