From patchwork Fri Jun 17 14:48:43 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud Giersch X-Patchwork-Id: 891542 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5HEnE28009632 for ; Fri, 17 Jun 2011 14:49:14 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932309Ab1FQOsz (ORCPT ); Fri, 17 Jun 2011 10:48:55 -0400 Received: from smtp3-g21.free.fr ([212.27.42.3]:35716 "EHLO smtp3-g21.free.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932238Ab1FQOsy (ORCPT ); Fri, 17 Jun 2011 10:48:54 -0400 Received: from plop (gy190-1-88-184-169-119.fbx.proxad.net [88.184.169.119]) (Authenticated sender: arnaud.giersch) by smtp3-g21.free.fr (Postfix) with ESMTPA id D790DA62B5; Fri, 17 Jun 2011 16:48:45 +0200 (CEST) Received: from arnaud by plop with local (Exim 4.72) (envelope-from ) id 1QXaLk-0003UU-11; Fri, 17 Jun 2011 16:48:44 +0200 From: Arnaud Giersch To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] coredump: call vfs_getattr() to get inode attributes Date: Fri, 17 Jun 2011 16:48:43 +0200 Message-ID: <87ei2ssed0.fsf@free.fr> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Fri, 17 Jun 2011 14:49:14 +0000 (UTC) From: Arnaud Giersch In do_coredump(), call vfs_getattr() to get inode attributes, and do not get them directly from the fields of the inode struct. Without this patch, when dumping core on an NFSv4 mount, and the i_uid field is not correctly filled at open time, the uid check fails, and an empty core dump is produced. This apparently only happens when there was no "core" file before the dump. If a "core" file owned by the current user is already present, it is correctly filled. The reason is that decode_attr_owner() in fs/nfs/nfs4xdr.c is not allowed to call the idmapper when it receives may_sleep = 0 (see commit 80e52aced138bb41b045a8595a87510f27d8d8c5, and some explanations in http://article.gmane.org/gmane.linux.nfs/33391). Signed-off-by: Arnaud Giersch --- fs/exec.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-nfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/exec.c b/fs/exec.c index 97e0d52..8a73425 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -2147,7 +2147,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) goto close_fail; } } else { - struct inode *inode; + struct kstat stat; if (cprm.limit < binfmt->min_coredump) goto fail_unlock; @@ -2158,8 +2158,10 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) if (IS_ERR(cprm.file)) goto fail_unlock; - inode = cprm.file->f_path.dentry->d_inode; - if (inode->i_nlink > 1) + if (vfs_getattr(cprm.file->f_path.mnt, cprm.file->f_path.dentry, + &stat)) + goto close_fail; + if (stat.nlink > 1) goto close_fail; if (d_unhashed(cprm.file->f_path.dentry)) goto close_fail; @@ -2167,13 +2169,13 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) * AK: actually i see no reason to not allow this for named * pipes etc, but keep the previous behaviour for now. */ - if (!S_ISREG(inode->i_mode)) + if (!S_ISREG(stat.mode)) goto close_fail; /* * Dont allow local users get cute and trick others to coredump * into their pre-created files. */ - if (inode->i_uid != current_fsuid()) + if (stat.uid != current_fsuid()) goto close_fail; if (!cprm.file->f_op || !cprm.file->f_op->write) goto close_fail;