mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ram Pai <linuxram@us.ibm.com>
To: linux-kernel@vger.kernel.org
Cc: akpm@osdl.org, linuxram@us.ibm.com, nacc@us.ibm.com,
	viro@ftp.linux.org.uk
Subject: [PATCH 1/1] VFS: fixes a bug in sys_linkat()
Date: Tue, 12 Sep 2006 17:57:38 -0700	[thread overview]
Message-ID: <200609130057.k8D0vcqJ028474@ram.us.ibm.com> (raw)

Hardlink using sys_linkat() returns EXDEV when the source and the destination
point to the same filesystem, residing under different mounts.

An example scenario is:

mount /dev/sda /mnt
mount /dev/sdb /mnt1
mkdir /mnt1/src
mkdir /mnt/dest
mount --bind /mnt1/src /mnt/dest   (note: at this point the filesystems
			under /mnt1/src and /mnt/dest is same)
touch /mnt1/src/testfile
ln /mnt1/src/testfile /mnt/dest/sametestfile  (note: this should succeed).

The ln command fails. It does not correctly recognize that both
the source and destination point to the same filesystem.

The following patch fixes the problem.
Thanks to Nishanth Aravamudan(nacc@us.ibm.com) for identifying the bug.

Signed by Ram Pai (linuxram@us.ibm.com)
---
 fs/namei.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-2.6.17.10/fs/namei.c
===================================================================
--- linux-2.6.17.10.orig/fs/namei.c
+++ linux-2.6.17.10/fs/namei.c
@@ -2263,7 +2263,7 @@ asmlinkage long sys_linkat(int olddfd, c
 	if (error)
 		goto out;
 	error = -EXDEV;
-	if (old_nd.mnt != nd.mnt)
+	if (old_nd.mnt->mnt_sb != nd.mnt->mnt_sb)
 		goto out_release;
 	new_dentry = lookup_create(&nd, 0);
 	error = PTR_ERR(new_dentry);

             reply	other threads:[~2006-09-13  0:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-09-13  0:57 Ram Pai [this message]
2006-09-13  1:11 ` Al Viro
2006-09-13  1:32   ` Ram Pai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200609130057.k8D0vcqJ028474@ram.us.ibm.com \
    --to=linuxram@us.ibm.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=nacc@us.ibm.com \
    --cc=viro@ftp.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®