Re: splice vs O_APPEND

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Miklos Szeredi
Date: Thursday, October 9, 2008 - 12:51 pm

On Thu, 9 Oct 2008, Linus Torvalds wrote:

The thing is, the append-only attribute is absolutely useless without
being able to depend on it.  So in that sense I think the IS_APPEND
issue is important, and I'm fine with your original proposal for that
(except we don't need the IS_IMMUTABLE check).

I also agree that the O_APPEND issue is murky and should probably be
discussed separately.

Thanks,
Miklos
----

Subject: splice: disallow random writes for append-only inodes

From: Linus Torvalds <torvalds@linux-foundation.org>

It was possible to write to a random location in an append-only file
using splice.

Signed-off-by: Miklos Szeredi <mszeredi@suse.cz>
---
 fs/splice.c |    5 +++++
 1 file changed, 5 insertions(+)

Index: linux-2.6/fs/splice.c
===================================================================
--- linux-2.6.orig/fs/splice.c	2008-10-09 21:46:07.000000000 +0200
+++ linux-2.6/fs/splice.c	2008-10-09 21:47:42.000000000 +0200
@@ -891,6 +891,7 @@ static long do_splice_from(struct pipe_i
 			   loff_t *ppos, size_t len, unsigned int flags)
 {
 	int ret;
+	struct inode *inode;
 
 	if (unlikely(!out->f_op || !out->f_op->splice_write))
 		return -EINVAL;
@@ -898,6 +899,10 @@ static long do_splice_from(struct pipe_i
 	if (unlikely(!(out->f_mode & FMODE_WRITE)))
 		return -EBADF;
 
+	inode = out->f_dentry->d_inode;
+	if (IS_APPEND(inode))
+		return -EINVAL;
+
 	ret = rw_verify_area(WRITE, out, ppos, len);
 	if (unlikely(ret < 0))
 		return ret;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
splice vs O_APPEND, Miklos Szeredi, (Thu Oct 9, 8:02 am)
Re: splice vs O_APPEND, Linus Torvalds, (Thu Oct 9, 8:37 am)
Re: splice vs O_APPEND, Miklos Szeredi, (Thu Oct 9, 9:04 am)
Re: splice vs O_APPEND, Linus Torvalds, (Thu Oct 9, 9:17 am)
Re: splice vs O_APPEND, Andreas Schwab, (Thu Oct 9, 9:30 am)
Re: splice vs O_APPEND, Miklos Szeredi, (Thu Oct 9, 9:30 am)
Re: splice vs O_APPEND, Miklos Szeredi, (Thu Oct 9, 9:43 am)
Re: splice vs O_APPEND, Andreas Schwab, (Thu Oct 9, 10:03 am)
Re: splice vs O_APPEND, Linus Torvalds, (Thu Oct 9, 12:22 pm)
Re: splice vs O_APPEND, Miklos Szeredi, (Thu Oct 9, 12:51 pm)
Re: splice vs O_APPEND, Linus Torvalds, (Thu Oct 9, 2:14 pm)
Re: splice vs O_APPEND, Jens Axboe, (Thu Oct 9, 2:20 pm)
Re: splice vs O_APPEND, Linus Torvalds, (Thu Oct 9, 2:27 pm)
Re: splice vs O_APPEND, Miklos Szeredi, (Fri Oct 10, 2:46 am)
Re: splice vs O_APPEND, Jens Axboe, (Fri Oct 10, 3:06 am)
Re: splice vs O_APPEND, Michael Kerrisk, (Fri Oct 10, 3:23 am)
Re: [stable] splice vs O_APPEND, Greg KH, (Fri Oct 10, 8:49 am)
Re: [stable] splice vs O_APPEND, Miklos Szeredi, (Fri Oct 10, 9:05 am)
Re: [stable] splice vs O_APPEND, Greg KH, (Fri Oct 10, 9:20 am)