Skip to contentSkip to conversation

linux-next: manual merge of the pidfd tree with the vfs tree

DISCUSSION Stephen Rothwell 1 participant 3 messages Jan 25, 2021 – Feb 21, 2021 Linux-next tree

lore
Share & tools
lore
#0 lore raw

Hi all,

Today's linux-next merge of the pidfd tree got a conflict in:

fs/namei.c

between commit:

e36cffed20a3 ("fs: make unlazy_walk() error handling consistent") 1e8f44f159b3 ("do_tmpfile(): don't mess with finish_open()")

from the vfs tree and commit:

47291baa8ddf ("namei: make permission helpers idmapped mount aware") ba73d98745be ("namei: handle idmapped mounts in may_*() helpers") 549c7297717c ("fs: make helpers idmap mount aware")

from the pidfd tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

Signature · 45 lines
Cheers,
Stephen Rothwell

diff --cc fs/namei.c
index 4cae88733a5c,dbf53b325ac9..000000000000
--- a/fs/namei.c
+++ b/fs/namei.c
@@@ -1568,14 -1639,18 +1644,16 @@@ static struct dentry *lookup_slow(cons
  	return res;
  }
  
- static inline int may_lookup(struct nameidata *nd)
+ static inline int may_lookup(struct user_namespace *mnt_userns,
+ 			     struct nameidata *nd)
  {
  	if (nd->flags & LOOKUP_RCU) {
- 		int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
+ 		int err = inode_permission(mnt_userns, nd->inode,
+ 					   MAY_EXEC | MAY_NOT_BLOCK);
 -		if (err != -ECHILD)
 +		if (err != -ECHILD || !try_to_unlazy(nd))
  			return err;
 -		if (unlazy_walk(nd))
 -			return -ECHILD;
  	}
- 	return inode_permission(nd->inode, MAY_EXEC);
+ 	return inode_permission(mnt_userns, nd->inode, MAY_EXEC);
  }
  
  static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq)
@@@ -3324,9 -3453,11 +3453,9 @@@ static int do_tmpfile(struct nameidata 
  	path.dentry = child;
  	audit_inode(nd->name, child, 0);
  	/* Don't check for other permissions, the inode was just created */
- 	error = may_open(&path, 0, op->open_flag);
+ 	error = may_open(mnt_userns, &path, 0, op->open_flag);
 -	if (error)
 -		goto out2;
 -	file->f_path.mnt = path.mnt;
 -	error = finish_open(file, child, NULL);
 +	if (!error)
 +		error = vfs_open(&path, file);
  out2:
  	mnt_drop_write(path.mnt);
  out:
#1 lore raw

Hi all,

Quoted 57 lines · On Mon, 25 Jan 2021 17:00:54 +1100 Stephen Rothwell <[email protected]>…

Today's linux-next merge of the pidfd tree got a conflict in:

fs/namei.c

between commit:

e36cffed20a3 ("fs: make unlazy_walk() error handling consistent") 1e8f44f159b3 ("do_tmpfile(): don't mess with finish_open()")

from the vfs tree and commit:

47291baa8ddf ("namei: make permission helpers idmapped mount aware") ba73d98745be ("namei: handle idmapped mounts in may_*() helpers") 549c7297717c ("fs: make helpers idmap mount aware")

from the pidfd tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

fs/namei.c +5 -4
diff --cc fs/namei.c
index 4cae88733a5c,dbf53b325ac9..000000000000
@@@ -1568,14 -1639,18 +1644,16 @@@ static struct dentry *lookup_slow(cons
  	return res;
  }
 
- static inline int may_lookup(struct nameidata *nd)
+ static inline int may_lookup(struct user_namespace *mnt_userns,
+ 			     struct nameidata *nd)
  {
  	if (nd->flags & LOOKUP_RCU) {
- 		int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
+ 		int err = inode_permission(mnt_userns, nd->inode,
+ 					   MAY_EXEC | MAY_NOT_BLOCK);
 -		if (err != -ECHILD)
 +		if (err != -ECHILD || !try_to_unlazy(nd))
  			return err;
 -		if (unlazy_walk(nd))
 -			return -ECHILD;
  	}
- 	return inode_permission(nd->inode, MAY_EXEC);
+ 	return inode_permission(mnt_userns, nd->inode, MAY_EXEC);
  }
 
  static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq)
@@@ -3324,9 -3453,11 +3453,9 @@@ static int do_tmpfile(struct nameidata 
  	path.dentry = child;
  	audit_inode(nd->name, child, 0);
  	/* Don't check for other permissions, the inode was just created */
- 	error = may_open(&path, 0, op->open_flag);

fs/namei.c

Quoted 10 lines
fs/namei.c +1 -0
+ 	error = may_open(mnt_userns, &path, 0, op->open_flag);
 -	if (error)
 -		goto out2;
 -	file->f_path.mnt = path.mnt;
 -	error = finish_open(file, child, NULL);
 +	if (!error)
 +		error = vfs_open(&path, file);
  out2:
  	mnt_drop_write(path.mnt);
  out:

With the merge window about to open, this is a reminder that this conflict still exists.

Those vfs tree commits have also been merged into the block tree.

Signature · 2 lines
Cheers,
Stephen Rothwell
#2 lore raw

Hi all,

Quoted 73 lines · On Mon, 15 Feb 2021 08:05:21 +1100 Stephen Rothwell <[email protected]>…
Quoted 57 lines · On Mon, 25 Jan 2021 17:00:54 +1100 Stephen Rothwell <[email protected]>…

Today's linux-next merge of the pidfd tree got a conflict in:

fs/namei.c

between commit:

e36cffed20a3 ("fs: make unlazy_walk() error handling consistent") 1e8f44f159b3 ("do_tmpfile(): don't mess with finish_open()")

from the vfs tree and commit:

47291baa8ddf ("namei: make permission helpers idmapped mount aware") ba73d98745be ("namei: handle idmapped mounts in may_*() helpers") 549c7297717c ("fs: make helpers idmap mount aware")

from the pidfd tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

fs/namei.c +5 -4
diff --cc fs/namei.c
index 4cae88733a5c,dbf53b325ac9..000000000000
@@@ -1568,14 -1639,18 +1644,16 @@@ static struct dentry *lookup_slow(cons
  	return res;
  }
 
- static inline int may_lookup(struct nameidata *nd)
+ static inline int may_lookup(struct user_namespace *mnt_userns,
+ 			     struct nameidata *nd)
  {
  	if (nd->flags & LOOKUP_RCU) {
- 		int err = inode_permission(nd->inode, MAY_EXEC|MAY_NOT_BLOCK);
+ 		int err = inode_permission(mnt_userns, nd->inode,
+ 					   MAY_EXEC | MAY_NOT_BLOCK);
 -		if (err != -ECHILD)
 +		if (err != -ECHILD || !try_to_unlazy(nd))
  			return err;
 -		if (unlazy_walk(nd))
 -			return -ECHILD;
  	}
- 	return inode_permission(nd->inode, MAY_EXEC);
+ 	return inode_permission(mnt_userns, nd->inode, MAY_EXEC);
  }
 
  static int reserve_stack(struct nameidata *nd, struct path *link, unsigned seq)
@@@ -3324,9 -3453,11 +3453,9 @@@ static int do_tmpfile(struct nameidata 
  	path.dentry = child;
  	audit_inode(nd->name, child, 0);
  	/* Don't check for other permissions, the inode was just created */
- 	error = may_open(&path, 0, op->open_flag);

fs/namei.c

Quoted 10 lines
fs/namei.c +1 -0
+ 	error = may_open(mnt_userns, &path, 0, op->open_flag);
 -	if (error)
 -		goto out2;
 -	file->f_path.mnt = path.mnt;
 -	error = finish_open(file, child, NULL);
 +	if (!error)
 +		error = vfs_open(&path, file);
  out2:
  	mnt_drop_write(path.mnt);
  out:  

With the merge window about to open, this is a reminder that this conflict still exists.

Quoted 1 line

Those vfs tree commits have also been merged into the block tree.

This is now a conflict between the pidfd tree and Linus' tree.

Signature · 2 lines
Cheers,
Stephen Rothwell