From: Oleg Nesterov <oleg@redhat.com>
To: Andrey Wagin <avagin@gmail.com>
Cc: Andrew Vagin <avagin@parallels.com>,
Pavel Emelyanov <xemul@parallels.com>,
David Howells <dhowells@redhat.com>,
linux-kernel@vger.kernel.org, criu@openvz.org,
Cyrill Gorcunov <gorcunov@openvz.org>,
Alexander Viro <viro@zeniv.linux.org.uk>,
linux-fsdevel@vger.kernel.org,
Thomas Gleixner <tglx@linutronix.de>,
"Paul E. McKenney" <paulmck@linux.vnet.ibm.com>,
Michael Kerrisk <mtk.manpages@gmail.com>
Subject: Re: [CRIU] [PATCH 1/4] signalfd: add ability to return siginfo in a raw format
Date: Fri, 28 Dec 2012 15:12:49 +0100 [thread overview]
Message-ID: <20121228141249.GA24229@redhat.com> (raw)
In-Reply-To: <CANaxB-x8k-c+gkeUJ1LovxSdWHJZggt0POPQxEotmuQvcXeicg@mail.gmail.com>
On 12/27, Andrey Wagin wrote:
>
> 2012/12/27 Oleg Nesterov <oleg@redhat.com>:
> > On 12/27, Andrey Wagin wrote:
> >>
> >> On Wed, Dec 26, 2012 at 05:31:12PM +0100, Oleg Nesterov wrote:
> >> >
> >> > So I think we should not use llseek. But, probably we can rely on pread() ?
> >> > This way we can avoid the problem above, and this looks even simpler.
> >>
> >> Yes. It is a good idea. A new patch is attached to this email. I
> >> implemented pread for signalfd and fixed all your previous comments.
> >>
> ...
> > I think it would be better to pass ppos, not *ppos, because ...
> >
> >> + if (*ppos)
> >> + (*ppos)++;
> >
> > in this case we can update *ppos in signalfd_peek() and simplify the
> > code a bit.
> >
> > Compared to the previous version it is "safe" to change *ppos even if
> > copy_to_user() fails, *ppos will be "lost" anyway after we return.
>
> Yes. But ppos is updated, because pread() reads all siginfo-s from a queue,
> which fit in a buffer starting with the initial ppos.
Can't understand. And I guess you misunderstood.
I meant, we can update *ppos in signalfd_peek() _and_ we can do this
unconditionally even if copy_to_user() failed.
> >> @@ -321,6 +372,7 @@ SYSCALL_DEFINE4(signalfd4, int, ufd, sigset_t __user *, user_mask,
> >> }
> >>
> >> file->f_flags |= flags & SFD_RAW;
> >> + file->f_mode |= FMODE_PREAD;
> >>
> >> fd_install(ufd, file);
> >
> > Hmm. Looks like it is based on other patches I didnt see...
> >
> > But I don't understand how FMODE_PREAD connects to this patch, we need
> > this flag set even for regular sys_read() ???
>
> It doesn't need for sys_read(), but this patch is about pread() and
> sys_pread() checks it.
>
> SYSCALL_DEFINE(pread64)(unsigned int fd, char __user *buf,
> size_t count, loff_t pos)
> {
> ....
> if (f.file) {
> ret = -ESPIPE;
> if (f.file->f_mode & FMODE_PREAD)
> ret = vfs_read(f.file, buf, count, &pos);
And sys_read() checks it too, that was my point.
So either this code was already broken before this patch, or FMODE_PREAD
is already set and you do not need this chunk.
Oleg.
next prev parent reply other threads:[~2012-12-28 14:13 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-24 8:13 [PATCH 0/4] signalfd: a kernel interface for dumping/restoring pending signals Andrey Vagin
2012-12-24 8:13 ` [PATCH 1/4] signalfd: add ability to return siginfo in a raw format Andrey Vagin
2012-12-24 16:53 ` Oleg Nesterov
2012-12-25 8:29 ` Andrey Wagin
2012-12-25 14:30 ` Oleg Nesterov
2012-12-25 15:27 ` Oleg Nesterov
2012-12-25 15:40 ` Pavel Emelyanov
2012-12-25 16:58 ` Oleg Nesterov
2012-12-26 14:47 ` [CRIU] " Andrew Vagin
2012-12-26 16:31 ` Oleg Nesterov
2012-12-27 14:36 ` Andrey Wagin
2012-12-27 15:30 ` Oleg Nesterov
2012-12-27 18:40 ` Andrey Wagin
2012-12-28 14:12 ` Oleg Nesterov [this message]
2012-12-28 14:28 ` Andrey Wagin
2012-12-28 14:46 ` Oleg Nesterov
2012-12-28 14:48 ` Andrey Wagin
2012-12-28 14:56 ` Oleg Nesterov
2012-12-24 8:13 ` [PATCH 2/4] signal: add a helper for dequeuing signals from a specified queue Andrey Vagin
[not found] ` <1356336807-5517-3-git-send-email-avagin-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-12-24 20:52 ` Michael Kerrisk
2012-12-24 8:13 ` [PATCH 3/4] signalfd: add ability to choose a private or shared queue Andrey Vagin
2012-12-24 17:05 ` Oleg Nesterov
2012-12-24 20:53 ` Michael Kerrisk
2012-12-24 8:13 ` [PATCH 4/4] signal: allow to send any siginfo to itself Andrey Vagin
[not found] ` <1356336807-5517-1-git-send-email-avagin-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org>
2012-12-24 20:51 ` [PATCH 0/4] signalfd: a kernel interface for dumping/restoring pending signals Michael Kerrisk
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=20121228141249.GA24229@redhat.com \
--to=oleg@redhat.com \
--cc=avagin@gmail.com \
--cc=avagin@parallels.com \
--cc=criu@openvz.org \
--cc=dhowells@redhat.com \
--cc=gorcunov@openvz.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mtk.manpages@gmail.com \
--cc=paulmck@linux.vnet.ibm.com \
--cc=tglx@linutronix.de \
--cc=viro@zeniv.linux.org.uk \
--cc=xemul@parallels.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;
as well as URLs for NNTP newsgroup(s).