]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - fs/namei.c
fs/f2fs/namei.c: remove unnecessary new_valid_dev() check
[karo-tx-linux.git] / fs / namei.c
index e5daa6f65c6e894aaeba36a2533599f4ee3fb3b7..174ef4f106cd2ac9696db8cf153f40dd7ef0ecaa 100644 (file)
@@ -955,26 +955,23 @@ static bool safe_hardlink_source(struct inode *inode)
  *  - sysctl_protected_hardlinks enabled
  *  - fsuid does not match inode
  *  - hardlink source is unsafe (see safe_hardlink_source() above)
- *  - not CAP_FOWNER
+ *  - not CAP_FOWNER in a namespace with the inode owner uid mapped
  *
  * Returns 0 if successful, -ve on error.
  */
 static int may_linkat(struct path *link)
 {
-       const struct cred *cred;
        struct inode *inode;
 
        if (!sysctl_protected_hardlinks)
                return 0;
 
-       cred = current_cred();
        inode = link->dentry->d_inode;
 
        /* Source inode owner (or CAP_FOWNER) can hardlink all they like,
         * otherwise, it must be a safe source.
         */
-       if (uid_eq(cred->fsuid, inode->i_uid) || safe_hardlink_source(inode) ||
-           capable(CAP_FOWNER))
+       if (inode_owner_or_capable(inode) || safe_hardlink_source(inode))
                return 0;
 
        audit_log_link_denied("linkat", link);
@@ -4681,7 +4678,7 @@ EXPORT_SYMBOL(__page_symlink);
 int page_symlink(struct inode *inode, const char *symname, int len)
 {
        return __page_symlink(inode, symname, len,
-                       !(mapping_gfp_mask(inode->i_mapping) & __GFP_FS));
+                       !mapping_gfp_constraint(inode->i_mapping, __GFP_FS));
 }
 EXPORT_SYMBOL(page_symlink);