linux-next.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* linux-next: manual merge of the keys tree with Linus' tree
@ 2020-02-19 23:43 Stephen Rothwell
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2020-02-19 23:43 UTC (permalink / raw)
  To: David Howells, Linus Torvalds
  Cc: Linux Next Mailing List, Linux Kernel Mailing List

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

Hi all,

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

  fs/pipe.c

between commit:

  6551d5c56eb0 ("pipe: make sure to wake up everybody when the last reader/writer closes")

from Linus' tree and commit:

  549d46d3827d ("pipe: Add general notification queue support")

from the keys tree.

I fixed it up (I think - 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/pipe.c
index 2144507447c5,238601a7ab24..000000000000
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@@ -1269,12 -1310,63 +1311,64 @@@ int pipe_resize_ring(struct pipe_inode_
  	kfree(pipe->bufs);
  	pipe->bufs = bufs;
  	pipe->ring_size = nr_slots;
- 	pipe->max_usage = nr_slots;
+ 	if (pipe->max_usage > nr_slots)
+ 		pipe->max_usage = nr_slots;
  	pipe->tail = tail;
  	pipe->head = head;
 -	wake_up_interruptible_all(&pipe->rd_wait);
 -	wake_up_interruptible_all(&pipe->wr_wait);
 +
 +	/* This might have made more room for writers */
 +	wake_up_interruptible(&pipe->wr_wait);
+ 	return 0;
+ }
+ 
+ /*
+  * Allocate a new array of pipe buffers and copy the info over. Returns the
+  * pipe size if successful, or return -ERROR on error.
+  */
+ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
+ {
+ 	unsigned long user_bufs;
+ 	unsigned int nr_slots, size;
+ 	long ret = 0;
+ 
+ #ifdef CONFIG_WATCH_QUEUE
+ 	if (pipe->watch_queue)
+ 		return -EBUSY;
+ #endif
+ 
+ 	size = round_pipe_size(arg);
+ 	nr_slots = size >> PAGE_SHIFT;
+ 
+ 	if (!nr_slots)
+ 		return -EINVAL;
+ 
+ 	/*
+ 	 * If trying to increase the pipe capacity, check that an
+ 	 * unprivileged user is not trying to exceed various limits
+ 	 * (soft limit check here, hard limit check just below).
+ 	 * Decreasing the pipe capacity is always permitted, even
+ 	 * if the user is currently over a limit.
+ 	 */
+ 	if (nr_slots > pipe->max_usage &&
+ 			size > pipe_max_size && !capable(CAP_SYS_RESOURCE))
+ 		return -EPERM;
+ 
+ 	user_bufs = account_pipe_buffers(pipe->user, pipe->nr_accounted, nr_slots);
+ 
+ 	if (nr_slots > pipe->max_usage &&
+ 			(too_many_pipe_buffers_hard(user_bufs) ||
+ 			 too_many_pipe_buffers_soft(user_bufs)) &&
+ 			pipe_is_unprivileged_user()) {
+ 		ret = -EPERM;
+ 		goto out_revert_acct;
+ 	}
+ 
+ 	ret = pipe_resize_ring(pipe, nr_slots);
+ 	if (ret < 0)
+ 		goto out_revert_acct;
+ 
+ 	pipe->max_usage = nr_slots;
+ 	pipe->nr_accounted = nr_slots;
  	return pipe->max_usage * PAGE_SIZE;
  
  out_revert_acct:

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

^ permalink raw reply	[flat|nested] 4+ messages in thread
* linux-next: manual merge of the keys tree with Linus' tree
@ 2020-05-11  4:59 Stephen Rothwell
  2020-05-12  8:38 ` Stephen Rothwell
  0 siblings, 1 reply; 4+ messages in thread
From: Stephen Rothwell @ 2020-05-11  4:59 UTC (permalink / raw)
  To: David Howells
  Cc: Linux Next Mailing List, Linux Kernel Mailing List,
	Pavel Begunkov, Jens Axboe

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

Hi all,

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

  fs/splice.c

between commit:

  90da2e3f25c8 ("splice: move f_mode checks to do_{splice,tee}()")

from Linus' tree and commit:

  549d46d3827d ("pipe: Add general notification queue support")

from the keys 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/splice.c
index fd0a1e7e5959,6e6ea30c72b4..000000000000
--- a/fs/splice.c
+++ b/fs/splice.c
@@@ -1118,12 -1118,8 +1118,12 @@@ long do_splice(struct file *in, loff_t 
  	loff_t offset;
  	long ret;
  
 +	if (unlikely(!(in->f_mode & FMODE_READ) ||
 +		     !(out->f_mode & FMODE_WRITE)))
 +		return -EBADF;
 +
- 	ipipe = get_pipe_info(in);
- 	opipe = get_pipe_info(out);
+ 	ipipe = get_pipe_info(in, true);
+ 	opipe = get_pipe_info(out, true);
  
  	if (ipipe && opipe) {
  		if (off_in || off_out)
@@@ -1757,14 -1766,10 +1757,17 @@@ static int link_pipe(struct pipe_inode_
  static long do_tee(struct file *in, struct file *out, size_t len,
  		   unsigned int flags)
  {
- 	struct pipe_inode_info *ipipe = get_pipe_info(in);
- 	struct pipe_inode_info *opipe = get_pipe_info(out);
 -	struct pipe_inode_info *ipipe = get_pipe_info(in, true);
 -	struct pipe_inode_info *opipe = get_pipe_info(out, true);
++	struct pipe_inode_info *ipipe;
++	struct pipe_inode_info *opipe;
  	int ret = -EINVAL;
  
 +	if (unlikely(!(in->f_mode & FMODE_READ) ||
 +		     !(out->f_mode & FMODE_WRITE)))
 +		return -EBADF;
 +
++	ipipe = get_pipe_info(in, true);
++	opipe = get_pipe_info(out, true);
++
  	/*
  	 * Duplicate the contents of ipipe to opipe without actually
  	 * copying the data.

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

^ permalink raw reply	[flat|nested] 4+ messages in thread
* linux-next: manual merge of the keys tree with Linus' tree
@ 2020-02-09 22:34 Stephen Rothwell
  0 siblings, 0 replies; 4+ messages in thread
From: Stephen Rothwell @ 2020-02-09 22:34 UTC (permalink / raw)
  To: David Howells, Linus Torvalds
  Cc: Linux Next Mailing List, Linux Kernel Mailing List

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

Hi all,

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

  fs/pipe.c

between commit:

  0ddad21d3e99 ("pipe: use exclusive waits when reading or writing")

from Linus' tree and commits:

  57421d0685a3 ("pipe: Add general notification queue support")
  95e0a8b2f657 ("pipe: Add notification lossage handling")

from the keys tree.

I fixed it up (I think - 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/pipe.c
index 5a34d6c22d4c,423aafca4338..000000000000
--- a/fs/pipe.c
+++ b/fs/pipe.c
@@@ -347,10 -375,14 +378,14 @@@ pipe_read(struct kiocb *iocb, struct io
  
  			if (!buf->len) {
  				pipe_buf_release(pipe, buf);
 -				spin_lock_irq(&pipe->wait.lock);
 +				spin_lock_irq(&pipe->rd_wait.lock);
+ #ifdef CONFIG_WATCH_QUEUE
+ 				if (buf->flags & PIPE_BUF_FLAG_LOSS)
+ 					pipe->note_loss = true;
+ #endif
  				tail++;
  				pipe->tail = tail;
 -				spin_unlock_irq(&pipe->wait.lock);
 +				spin_unlock_irq(&pipe->rd_wait.lock);
  			}
  			total_len -= chars;
  			if (!total_len)
@@@ -1268,11 -1290,62 +1310,63 @@@ int pipe_resize_ring(struct pipe_inode_
  	kfree(pipe->bufs);
  	pipe->bufs = bufs;
  	pipe->ring_size = nr_slots;
- 	pipe->max_usage = nr_slots;
+ 	if (pipe->max_usage > nr_slots)
+ 		pipe->max_usage = nr_slots;
  	pipe->tail = tail;
  	pipe->head = head;
 -	wake_up_interruptible_all(&pipe->wait);
 +	wake_up_interruptible_all(&pipe->rd_wait);
 +	wake_up_interruptible_all(&pipe->wr_wait);
+ 	return 0;
+ }
+ 
+ /*
+  * Allocate a new array of pipe buffers and copy the info over. Returns the
+  * pipe size if successful, or return -ERROR on error.
+  */
+ static long pipe_set_size(struct pipe_inode_info *pipe, unsigned long arg)
+ {
+ 	unsigned long user_bufs;
+ 	unsigned int nr_slots, size;
+ 	long ret = 0;
+ 
+ #ifdef CONFIG_WATCH_QUEUE
+ 	if (pipe->watch_queue)
+ 		return -EBUSY;
+ #endif
+ 
+ 	size = round_pipe_size(arg);
+ 	nr_slots = size >> PAGE_SHIFT;
+ 
+ 	if (!nr_slots)
+ 		return -EINVAL;
+ 
+ 	/*
+ 	 * If trying to increase the pipe capacity, check that an
+ 	 * unprivileged user is not trying to exceed various limits
+ 	 * (soft limit check here, hard limit check just below).
+ 	 * Decreasing the pipe capacity is always permitted, even
+ 	 * if the user is currently over a limit.
+ 	 */
+ 	if (nr_slots > pipe->max_usage &&
+ 			size > pipe_max_size && !capable(CAP_SYS_RESOURCE))
+ 		return -EPERM;
+ 
+ 	user_bufs = account_pipe_buffers(pipe->user, pipe->nr_accounted, nr_slots);
+ 
+ 	if (nr_slots > pipe->max_usage &&
+ 			(too_many_pipe_buffers_hard(user_bufs) ||
+ 			 too_many_pipe_buffers_soft(user_bufs)) &&
+ 			pipe_is_unprivileged_user()) {
+ 		ret = -EPERM;
+ 		goto out_revert_acct;
+ 	}
+ 
+ 	ret = pipe_resize_ring(pipe, nr_slots);
+ 	if (ret < 0)
+ 		goto out_revert_acct;
+ 
+ 	pipe->max_usage = nr_slots;
+ 	pipe->nr_accounted = nr_slots;
  	return pipe->max_usage * PAGE_SIZE;
  
  out_revert_acct:

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-05-12  8:38 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-19 23:43 linux-next: manual merge of the keys tree with Linus' tree Stephen Rothwell
  -- strict thread matches above, loose matches on Subject: below --
2020-05-11  4:59 Stephen Rothwell
2020-05-12  8:38 ` Stephen Rothwell
2020-02-09 22:34 Stephen Rothwell

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).