[kernel] Fix hfsplus bless ioctl with hardlinks (from Matthew Garrett)

Josh Boyer jwboyer at fedoraproject.org
Wed Apr 18 18:12:57 UTC 2012


commit 7f6230e25d2c047e578ed90d0f4060bce085ad8b
Author: Josh Boyer <jwboyer at redhat.com>
Date:   Wed Apr 18 14:10:02 2012 -0400

    Fix hfsplus bless ioctl with hardlinks (from Matthew Garrett)

 ...-Fix-bless-ioctl-when-used-with-hardlinks.patch |  100 ++++++++++++++++++++
 kernel.spec                                        |    5 +
 2 files changed, 105 insertions(+), 0 deletions(-)
---
diff --git a/hfsplus-Fix-bless-ioctl-when-used-with-hardlinks.patch b/hfsplus-Fix-bless-ioctl-when-used-with-hardlinks.patch
new file mode 100644
index 0000000..3e0b4a5
--- /dev/null
+++ b/hfsplus-Fix-bless-ioctl-when-used-with-hardlinks.patch
@@ -0,0 +1,100 @@
+Path: news.gmane.org!not-for-mail
+From: Matthew Garrett <mjg at redhat.com>
+Newsgroups: gmane.linux.kernel,gmane.linux.file-systems
+Subject: [PATCH V2] hfsplus: Fix bless ioctl when used with hardlinks
+Date: Mon, 16 Apr 2012 16:57:18 -0400
+Lines: 45
+Approved: news at gmane.org
+Message-ID: <1334609838-14831-1-git-send-email-mjg at redhat.com>
+NNTP-Posting-Host: plane.gmane.org
+X-Trace: dough.gmane.org 1334609870 7622 80.91.229.3 (16 Apr 2012 20:57:50 GMT)
+X-Complaints-To: usenet at dough.gmane.org
+NNTP-Posting-Date: Mon, 16 Apr 2012 20:57:50 +0000 (UTC)
+Cc: linux-fsdevel at vger.kernel.org, linux-kernel at vger.kernel.org,
+	Matthew Garrett <mjg at redhat.com>
+To: hch at infradead.org
+Original-X-From: linux-kernel-owner at vger.kernel.org Mon Apr 16 22:57:49 2012
+Return-path: <linux-kernel-owner at vger.kernel.org>
+Envelope-to: glk-linux-kernel-3 at plane.gmane.org
+Original-Received: from vger.kernel.org ([209.132.180.67])
+	by plane.gmane.org with esmtp (Exim 4.69)
+	(envelope-from <linux-kernel-owner at vger.kernel.org>)
+	id 1SJszc-0006G8-Gd
+	for glk-linux-kernel-3 at plane.gmane.org; Mon, 16 Apr 2012 22:57:48 +0200
+Original-Received: (majordomo at vger.kernel.org) by vger.kernel.org via listexpand
+	id S1755330Ab2DPU5g (ORCPT <rfc822;glk-linux-kernel-3 at m.gmane.org>);
+	Mon, 16 Apr 2012 16:57:36 -0400
+Original-Received: from mx1.redhat.com ([209.132.183.28]:44295 "EHLO mx1.redhat.com"
+	rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP
+	id S1752969Ab2DPU5e (ORCPT <rfc822;linux-kernel at vger.kernel.org>);
+	Mon, 16 Apr 2012 16:57:34 -0400
+Original-Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22])
+	by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKvQoA029518
+	(version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK);
+	Mon, 16 Apr 2012 16:57:26 -0400
+Original-Received: from cavan.codon.org.uk (ovpn-113-122.phx2.redhat.com [10.3.113.122])
+	by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id q3GKvP1p017146
+	(version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO);
+	Mon, 16 Apr 2012 16:57:26 -0400
+Original-Received: from nat-pool-rdu.redhat.com ([66.187.233.202] helo=x220.boston.devel.redhat.com)
+	by cavan.codon.org.uk with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32)
+	(Exim 4.72)
+	(envelope-from <mjg at redhat.com>)
+	id 1SJszC-0003jY-P9; Mon, 16 Apr 2012 21:57:23 +0100
+X-SA-Do-Not-Run: Yes
+X-SA-Exim-Connect-IP: 66.187.233.202
+X-SA-Exim-Mail-From: mjg at redhat.com
+X-SA-Exim-Scanned: No (on cavan.codon.org.uk); SAEximRunCond expanded to false
+X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22
+Original-Sender: linux-kernel-owner at vger.kernel.org
+Precedence: bulk
+List-ID: <linux-kernel.vger.kernel.org>
+X-Mailing-List: linux-kernel at vger.kernel.org
+Xref: news.gmane.org gmane.linux.kernel:1282933 gmane.linux.file-systems:63394
+Archived-At: <http://permalink.gmane.org/gmane.linux.kernel/1282933>
+
+HFS+ doesn't really implement hard links - instead, hardlinks are indicated
+by a magic file type which refers to an indirect node in a hidden
+directory. The spec indicates that stat() should return the inode number
+of the indirect node, but it turns out that this doesn't satisfy the
+firmware when it's looking for a bootloader - it wants the catalog ID of
+the hardlink file instead. Fix up this case.
+
+Signed-off-by: Matthew Garrett <mjg at redhat.com>
+---
+
+V2 cleans up the casting.
+
+ fs/hfsplus/ioctl.c |    9 +++++++--
+ 1 file changed, 7 insertions(+), 2 deletions(-)
+
+diff --git a/fs/hfsplus/ioctl.c b/fs/hfsplus/ioctl.c
+index c640ba5..09addc8 100644
+--- a/fs/hfsplus/ioctl.c
++++ b/fs/hfsplus/ioctl.c
+@@ -31,6 +31,7 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
+ 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
+ 	struct hfsplus_vh *vh = sbi->s_vhdr;
+ 	struct hfsplus_vh *bvh = sbi->s_backup_vhdr;
++	u32 cnid = (unsigned long)dentry->d_fsdata;
+ 
+ 	if (!capable(CAP_SYS_ADMIN))
+ 		return -EPERM;
+@@ -41,8 +42,12 @@ static int hfsplus_ioctl_bless(struct file *file, int __user *user_flags)
+ 	vh->finder_info[0] = bvh->finder_info[0] =
+ 		cpu_to_be32(parent_ino(dentry));
+ 
+-	/* Bootloader */
+-	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(inode->i_ino);
++	/*
++	 * Bootloader. Just using the inode here breaks in the case of
++	 * hard links - the firmware wants the ID of the hard link file,
++	 * but the inode points at the indirect inode
++	 */
++	vh->finder_info[1] = bvh->finder_info[1] = cpu_to_be32(cnid);
+ 
+ 	/* Per spec, the OS X system folder - same as finder_info[0] here */
+ 	vh->finder_info[5] = bvh->finder_info[5] =
+-- 
+1.7.10
+
diff --git a/kernel.spec b/kernel.spec
index 91f665f..9ed5c7c 100644
--- a/kernel.spec
+++ b/kernel.spec
@@ -727,6 +727,8 @@ Patch21010: highbank-export-clock-functions.patch
 
 Patch21094: power-x86-destdir.patch
 
+Patch21098: hfsplus-Fix-bless-ioctl-when-used-with-hardlinks.patch
+
 #rhbz 754518
 Patch21235: scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch
 
@@ -1423,6 +1425,8 @@ ApplyPatch lis3-improve-handling-of-null-rate.patch
 
 ApplyPatch power-x86-destdir.patch
 
+ApplyPatch hfsplus-Fix-bless-ioctl-when-used-with-hardlinks.patch
+
 #rhbz 754518
 ApplyPatch scsi-sd_revalidate_disk-prevent-NULL-ptr-deref.patch
 
@@ -2310,6 +2314,7 @@ fi
 #                 ||     ||
 %changelog
 * Wed Apr 18 2012 Josh Boyer <jwboyer at redhat.com>
+- Fix hfsplus bless ioctl with hardlinks (from Matthew Garrett)
 - Change patch to resolve libata hotplug (rhbz 807632)
 
 * Tue Apr 17 2012 Josh Boyer <jwboyer at redhat.com>


More information about the scm-commits mailing list