From mboxrd@z Thu Jan 1 00:00:00 1970 From: Gustav Munkby Subject: [PATCH] hfsplus: disable rename of directory hardlinks Date: Tue, 3 May 2011 16:26:13 +0200 Message-ID: <1304432773-6212-1-git-send-email-grddev@gmail.com> References: <4DC00D13.5060903@gmail.com> Cc: Al Viro , linux-fsdevel@vger.kernel.org To: Christoph Hellwig Return-path: Received: from mail-ew0-f46.google.com ([209.85.215.46]:52538 "EHLO mail-ew0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752525Ab1ECO1H (ORCPT ); Tue, 3 May 2011 10:27:07 -0400 Received: by ewy4 with SMTP id 4so40800ewy.19 for ; Tue, 03 May 2011 07:27:06 -0700 (PDT) In-Reply-To: <4DC00D13.5060903@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org List-ID: Signed-off-by: Gustav Munkby --- fs/hfsplus/dir.c | 9 ++++++++- 1 files changed, 8 insertions(+), 1 deletions(-) diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c index 4df5059..3c35296 100644 --- a/fs/hfsplus/dir.c +++ b/fs/hfsplus/dir.c @@ -108,7 +108,7 @@ again: inode = hfsplus_iget(dir->i_sb, cnid); if (IS_ERR(inode)) return ERR_CAST(inode); - if (S_ISREG(inode->i_mode)) + if (S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)) HFSPLUS_I(inode)->linkid = linkid; out: d_add(dentry, inode); @@ -465,6 +465,13 @@ static int hfsplus_rename(struct inode *old_dir, struct dentry *old_dentry, { int res; + /* Renaming directory hardlinks to could create loops. + * Conservatively prevent any hardlink renaming. + */ + if (S_ISDIR(old_dentry->d_inode->i_mode) && + HFSPLUS_I(old_dentry->d_inode)->linkid) + return -EPERM; + /* Unlink destination if it already exists */ if (new_dentry->d_inode) { if (S_ISDIR(new_dentry->d_inode->i_mode)) -- 1.7.5