linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stephen Rothwell <sfr@canb.auug.org.au>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Alexey Gladkov <legion@kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	Linux Next Mailing List <linux-next@vger.kernel.org>,
	Peter Zijlstra <peterz@infradead.org>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: linux-next: manual merge of the userns tree with Linus' tree
Date: Fri, 25 Jun 2021 18:22:19 +1000	[thread overview]
Message-ID: <20210625182219.1a2ae36e@canb.auug.org.au> (raw)

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

Hi all,

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

  kernel/signal.c

between commits:

  69995ebbb9d3 ("signal: Hand SIGQUEUE_PREALLOC flag to __sigqueue_alloc()")
  4bad58ebc8bc ("signal: Allow tasks to cache one sigqueue struct")
  399f8dd9a866 ("signal: Prevent sigqueue caching after task got released")

from Linus' tree and commit:

  d64696905554 ("Reimplement RLIMIT_SIGPENDING on top of ucounts")

from the userns 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 kernel/signal.c
index 782951c06660,9a6dab712123..000000000000
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@@ -408,12 -410,11 +408,12 @@@ void task_join_group_stop(struct task_s
   *   appropriate lock must be held to stop the target task from exiting
   */
  static struct sigqueue *
 -__sigqueue_alloc(int sig, struct task_struct *t, gfp_t flags, int override_rlimit)
 +__sigqueue_alloc(int sig, struct task_struct *t, gfp_t gfp_flags,
 +		 int override_rlimit, const unsigned int sigqueue_flags)
  {
  	struct sigqueue *q = NULL;
- 	struct user_struct *user;
- 	int sigpending;
+ 	struct ucounts *ucounts = NULL;
+ 	long sigpending;
  
  	/*
  	 * Protect access to @t credentials. This can go away when all
@@@ -424,42 -425,26 +424,41 @@@
  	 * changes from/to zero.
  	 */
  	rcu_read_lock();
- 	user = __task_cred(t)->user;
- 	sigpending = atomic_inc_return(&user->sigpending);
+ 	ucounts = task_ucounts(t);
+ 	sigpending = inc_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_SIGPENDING, 1);
  	if (sigpending == 1)
- 		get_uid(user);
+ 		ucounts = get_ucounts(ucounts);
  	rcu_read_unlock();
  
- 	if (override_rlimit || likely(sigpending <= task_rlimit(t, RLIMIT_SIGPENDING))) {
+ 	if (override_rlimit || (sigpending < LONG_MAX && sigpending <= task_rlimit(t, RLIMIT_SIGPENDING))) {
 -		q = kmem_cache_alloc(sigqueue_cachep, flags);
 +		/*
 +		 * Preallocation does not hold sighand::siglock so it can't
 +		 * use the cache. The lockless caching requires that only
 +		 * one consumer and only one producer run at a time.
 +		 *
 +		 * For the regular allocation case it is sufficient to
 +		 * check @q for NULL because this code can only be called
 +		 * if the target task @t has not been reaped yet; which
 +		 * means this code can never observe the error pointer which is
 +		 * written to @t->sigqueue_cache in exit_task_sigqueue_cache().
 +		 */
 +		q = READ_ONCE(t->sigqueue_cache);
 +		if (!q || sigqueue_flags)
 +			q = kmem_cache_alloc(sigqueue_cachep, gfp_flags);
 +		else
 +			WRITE_ONCE(t->sigqueue_cache, NULL);
  	} else {
  		print_dropped_signal(sig);
  	}
  
  	if (unlikely(q == NULL)) {
- 		if (atomic_dec_and_test(&user->sigpending))
- 			free_uid(user);
+ 		if (ucounts && dec_rlimit_ucounts(ucounts, UCOUNT_RLIMIT_SIGPENDING, 1))
+ 			put_ucounts(ucounts);
  	} else {
  		INIT_LIST_HEAD(&q->list);
 -		q->flags = 0;
 +		q->flags = sigqueue_flags;
- 		q->user = user;
+ 		q->ucounts = ucounts;
  	}
- 
  	return q;
  }
  
@@@ -507,9 -452,11 +506,11 @@@ static void __sigqueue_free(struct sigq
  {
  	if (q->flags & SIGQUEUE_PREALLOC)
  		return;
- 	if (atomic_dec_and_test(&q->user->sigpending))
- 		free_uid(q->user);
+ 	if (q->ucounts && dec_rlimit_ucounts(q->ucounts, UCOUNT_RLIMIT_SIGPENDING, 1)) {
+ 		put_ucounts(q->ucounts);
+ 		q->ucounts = NULL;
+ 	}
 -	kmem_cache_free(sigqueue_cachep, q);
 +	sigqueue_cache_or_free(q);
  }
  
  void flush_sigqueue(struct sigpending *queue)

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

             reply	other threads:[~2021-06-25  8:22 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-25  8:22 Stephen Rothwell [this message]
2021-06-28  7:16 ` linux-next: manual merge of the userns tree with Linus' tree Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2021-05-26  4:51 Stephen Rothwell
2021-05-26  4:38 Stephen Rothwell
2021-05-26  4:32 Stephen Rothwell
2016-11-22  8:17 Stephen Rothwell
2016-11-22 17:44 ` Eric W. Biederman
2016-11-22 22:56   ` Stephen Rothwell
2016-07-08  6:13 Stephen Rothwell
2016-06-24  4:41 Stephen Rothwell
2014-04-17  5:06 Stephen Rothwell
2014-04-17  5:25 ` Al Viro
2014-04-17  8:44   ` Eric W. Biederman
2014-04-22  1:37     ` Stephen Rothwell
2014-04-09  2:45 Stephen Rothwell
2014-04-09  2:40 Stephen Rothwell
2014-04-09  2:39 Stephen Rothwell
2012-05-22  7:44 Stephen Rothwell
2012-05-22 14:29 ` Eric W. Biederman

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=20210625182219.1a2ae36e@canb.auug.org.au \
    --to=sfr@canb.auug.org.au \
    --cc=ebiederm@xmission.com \
    --cc=legion@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=tglx@linutronix.de \
    /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;
as well as URLs for NNTP newsgroup(s).