From: Jens Axboe <jens.axboe@oracle.com>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Miklos Szeredi <miklos@szeredi.hu>,
linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org
Subject: Re: splice vs O_APPEND
Date: Thu, 9 Oct 2008 23:20:53 +0200 [thread overview]
Message-ID: <20081009212052.GS19428@kernel.dk> (raw)
In-Reply-To: <alpine.LFD.2.00.0810091411520.3210@nehalem.linux-foundation.org>
On Thu, Oct 09 2008, Linus Torvalds wrote:
>
>
> On Thu, 9 Oct 2008, Miklos Szeredi 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).
>
> Heh. In the meantime, I had grown to hate that more complex patch.
>
> So because I do see your point with IS_APPEND (being different from
> O_APPEND), but because I also think that O_APPEND itself is a gray and
> murky area, I just committed the following. I doubt anybody will ever even
> notice it, but while I think it's all debatable, we might as well debate
> it with this in place. I do agree that it's "safer" behaviour.
>
> Linus
>
> ---
> commit a05b4085484ac45558810e4c5928e5a291c20f65
> Author: Linus Torvalds <torvalds@linux-foundation.org>
> Date: Thu Oct 9 14:04:54 2008 -0700
>
> Don't allow splice() to files opened with O_APPEND
>
> This is debatable, but while we're debating it, let's disallow the
> combination of splice and an O_APPEND destination.
>
> It's not entirely clear what the semantics of O_APPEND should be, and
> POSIX apparently expects pwrite() to ignore O_APPEND, for example. So
> we could make up any semantics we want, including the old ones.
>
> But Miklos convinced me that we should at least give it some thought,
> and that accepting writes at arbitrary offsets is wrong at least for
> IS_APPEND() files (which always have O_APPEND set, even if the reverse
> isn't true: you can obviously have O_APPEND set on a regular file).
>
> So disallow O_APPEND entirely for now. I doubt anybody cares, and this
> way we have one less gray area to worry about.
>
> Reported-and-argued-for-by: Miklos Szeredi <miklos@szeredi.hu>
> Cc: Jens Axboe <ens.axboe@oracle.com>
> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
A little late I see, but FWIW I agree. I doubt that anyone uses splice
with O_APPEND anyways, so should be zero-impact on that account at
least.
>
> diff --git a/fs/splice.c b/fs/splice.c
> index 1bbc6f4..a1e701c 100644
> --- a/fs/splice.c
> +++ b/fs/splice.c
> @@ -898,6 +898,9 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
> if (unlikely(!(out->f_mode & FMODE_WRITE)))
> return -EBADF;
>
> + if (unlikely(out->f_flags & O_APPEND))
> + return -EINVAL;
> +
> ret = rw_verify_area(WRITE, out, ppos, len);
> if (unlikely(ret < 0))
> return ret;
--
Jens Axboe
next prev parent reply other threads:[~2008-10-09 21:21 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-09 15:02 splice vs O_APPEND Miklos Szeredi
2008-10-09 15:37 ` Linus Torvalds
2008-10-09 16:04 ` Miklos Szeredi
2008-10-09 16:17 ` Linus Torvalds
2008-10-09 16:30 ` Miklos Szeredi
2008-10-09 19:22 ` Linus Torvalds
2008-10-09 19:51 ` Miklos Szeredi
2008-10-09 21:14 ` Linus Torvalds
2008-10-09 21:20 ` Jens Axboe [this message]
2008-10-09 21:27 ` Linus Torvalds
2008-10-10 9:46 ` Miklos Szeredi
2008-10-10 10:06 ` Jens Axboe
2008-10-10 15:49 ` [stable] " Greg KH
2008-10-10 16:05 ` Miklos Szeredi
2008-10-10 16:20 ` Greg KH
2008-10-10 10:23 ` Michael Kerrisk
2008-10-09 16:30 ` Andreas Schwab
2008-10-09 16:43 ` Miklos Szeredi
2008-10-09 17:03 ` Andreas Schwab
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=20081009212052.GS19428@kernel.dk \
--to=jens.axboe@oracle.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miklos@szeredi.hu \
--cc=torvalds@linux-foundation.org \
/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