public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: Paul Moore <paul@paul-moore.com>, Christian Brauner <brauner@kernel.org>
Cc: "Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>,
	"Linux Next Mailing List" <linux-next@vger.kernel.org>,
	"Mickaël Salaün" <mic@digikod.net>
Subject: linux-next: manual merge of the security tree with the vfs-brauner tree
Date: Tue, 10 Sep 2024 13:27:40 +1000	[thread overview]
Message-ID: <20240910132740.775b92e1@canb.auug.org.au> (raw)

[-- Attachment #1: Type: text/plain, Size: 3071 bytes --]

Hi all,

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

  fs/fcntl.c

between commit:

  1934b212615d ("file: reclaim 24 bytes from f_owner")

from the vfs-brauner tree and commit:

  26f204380a3c ("fs: Fix file_set_fowner LSM hook inconsistencies")

from the security 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.

-- 
Cheers,
Stephen Rothwell

diff --cc fs/fcntl.c
index f6fde75a3bd5,c28dc6c005f1..000000000000
--- a/fs/fcntl.c
+++ b/fs/fcntl.c
@@@ -89,72 -87,24 +89,66 @@@ static int setfl(int fd, struct file * 
  	return error;
  }
  
 +/*
 + * Allocate an file->f_owner struct if it doesn't exist, handling racing
 + * allocations correctly.
 + */
 +int file_f_owner_allocate(struct file *file)
 +{
 +	struct fown_struct *f_owner;
 +
 +	f_owner = file_f_owner(file);
 +	if (f_owner)
 +		return 0;
 +
 +	f_owner = kzalloc(sizeof(struct fown_struct), GFP_KERNEL);
 +	if (!f_owner)
 +		return -ENOMEM;
 +
 +	rwlock_init(&f_owner->lock);
 +	f_owner->file = file;
 +	/* If someone else raced us, drop our allocation. */
 +	if (unlikely(cmpxchg(&file->f_owner, NULL, f_owner)))
 +		kfree(f_owner);
 +	return 0;
 +}
 +EXPORT_SYMBOL(file_f_owner_allocate);
 +
 +void file_f_owner_release(struct file *file)
 +{
 +	struct fown_struct *f_owner;
 +
 +	f_owner = file_f_owner(file);
 +	if (f_owner) {
 +		put_pid(f_owner->pid);
 +		kfree(f_owner);
 +	}
 +}
 +
- static void f_modown(struct file *filp, struct pid *pid, enum pid_type type,
-                      int force)
+ void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
+ 		int force)
  {
 -	write_lock_irq(&filp->f_owner.lock);
 -	if (force || !filp->f_owner.pid) {
 -		put_pid(filp->f_owner.pid);
 -		filp->f_owner.pid = get_pid(pid);
 -		filp->f_owner.pid_type = type;
 +	struct fown_struct *f_owner;
 +
 +	f_owner = file_f_owner(filp);
 +	if (WARN_ON_ONCE(!f_owner))
 +		return;
 +
 +	write_lock_irq(&f_owner->lock);
 +	if (force || !f_owner->pid) {
 +		put_pid(f_owner->pid);
 +		f_owner->pid = get_pid(pid);
 +		f_owner->pid_type = type;
  
  		if (pid) {
  			const struct cred *cred = current_cred();
+ 			security_file_set_fowner(filp);
 -			filp->f_owner.uid = cred->uid;
 -			filp->f_owner.euid = cred->euid;
 +			f_owner->uid = cred->uid;
 +			f_owner->euid = cred->euid;
  		}
  	}
 -	write_unlock_irq(&filp->f_owner.lock);
 +	write_unlock_irq(&f_owner->lock);
  }
- 
- void __f_setown(struct file *filp, struct pid *pid, enum pid_type type,
- 		int force)
- {
- 	security_file_set_fowner(filp);
- 	f_modown(filp, pid, type, force);
- }
  EXPORT_SYMBOL(__f_setown);
  
  int f_setown(struct file *filp, int who, int force)

[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

             reply	other threads:[~2024-09-10  3:27 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10  3:27 Stephen Rothwell [this message]
2024-09-10 19:45 ` linux-next: manual merge of the security tree with the vfs-brauner tree Paul Moore
  -- strict thread matches above, loose matches on Subject: below --
2026-04-06 14:05 Mark Brown
2023-11-20  3:31 Stephen Rothwell
2023-11-20 21:09 ` Paul Moore

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=20240910132740.775b92e1@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=brauner@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=mic@digikod.net \
    --cc=paul@paul-moore.com \
    /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