From 3bbac9bf6b1d39aae28519e6ddbbd856f9f9b0c6 Mon Sep 17 00:00:00 2001 From: Steve Muir Date: Wed, 27 Oct 2004 20:12:10 +0000 Subject: [PATCH] Permit hard-linking across bind-mounts as long as the source dir is not read-only [PL #2624] --- fs/namei.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 34da5b453..17f40811e 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -2025,8 +2025,13 @@ asmlinkage long sys_link(const char __user * oldname, const char __user * newnam error = path_lookup(to, LOOKUP_PARENT, &nd); if (error) goto out; - error = -EXDEV; - if (old_nd.mnt != nd.mnt) + /* + * We allow hard-links to be created to a bind-mount as long + * as the bind-mount is not read-only. Checking for cross-dev + * links is subsumed by the superblock check in vfs_link(). + */ + error = -EROFS; + if (MNT_IS_RDONLY(old_nd.mnt)) goto out_release; new_dentry = lookup_create(&nd, 0); error = PTR_ERR(new_dentry); -- 2.47.0