* Re: [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete
[not found] ` <1428787108-13650-3-git-send-email-viro@ZenIV.linux.org.uk>
@ 2015-04-14 18:00 ` Tadeusz Struk
2015-04-14 18:26 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Tadeusz Struk @ 2015-04-14 18:00 UTC (permalink / raw)
To: Al Viro, davem; +Cc: netdev, linux-crypto
On 04/11/2015 02:18 PM, Al Viro wrote:
> @@ -766,8 +765,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg,
>
> init_sync_kiocb(&iocb, NULL);
> ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
> - if (-EIOCBQUEUED == ret)
> - ret = wait_on_sync_kiocb(&iocb);
> + BUG_ON(ret == -EIOCBQUEUED);
NACK - PF_ALG type sockets support async operations and return -EIOCBQUEUED
See skcipher_recvmsg_async() in crypto/algif_skcipher.c in net-next
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete
2015-04-14 18:00 ` [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete Tadeusz Struk
@ 2015-04-14 18:26 ` Al Viro
2015-04-14 18:37 ` Tadeusz Struk
0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2015-04-14 18:26 UTC (permalink / raw)
To: Tadeusz Struk; +Cc: davem, netdev, linux-crypto
On Tue, Apr 14, 2015 at 11:00:49AM -0700, Tadeusz Struk wrote:
> On 04/11/2015 02:18 PM, Al Viro wrote:
> > @@ -766,8 +765,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg,
> >
> > init_sync_kiocb(&iocb, NULL);
> > ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
> > - if (-EIOCBQUEUED == ret)
> > - ret = wait_on_sync_kiocb(&iocb);
> > + BUG_ON(ret == -EIOCBQUEUED);
>
> NACK - PF_ALG type sockets support async operations and return -EIOCBQUEUED
> See skcipher_recvmsg_async() in crypto/algif_skcipher.c in net-next
Its only caller is
static int skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
size_t ignored, int flags)
{
return (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) ?
skcipher_recvmsg_async(sock, msg, flags) :
skcipher_recvmsg_sync(sock, msg, flags);
}
Note that !is_sync_kiocb() in there. Compare with init_sync_kiocb() in
sock_recvmsg()...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete
2015-04-14 18:26 ` Al Viro
@ 2015-04-14 18:37 ` Tadeusz Struk
2015-04-14 19:22 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Tadeusz Struk @ 2015-04-14 18:37 UTC (permalink / raw)
To: Al Viro; +Cc: davem, netdev, linux-crypto
On 04/14/2015 11:26 AM, Al Viro wrote:
>>> @@ -766,8 +765,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg,
>>> > >
>>> > > init_sync_kiocb(&iocb, NULL);
>>> > > ret = __sock_recvmsg(&iocb, sock, msg, size, flags);
>>> > > - if (-EIOCBQUEUED == ret)
>>> > > - ret = wait_on_sync_kiocb(&iocb);
>>> > > + BUG_ON(ret == -EIOCBQUEUED);
>> >
>> > NACK - PF_ALG type sockets support async operations and return -EIOCBQUEUED
>> > See skcipher_recvmsg_async() in crypto/algif_skcipher.c in net-next
> Its only caller is
>
> static int skcipher_recvmsg(struct socket *sock, struct msghdr *msg,
> size_t ignored, int flags)
> {
> return (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) ?
> skcipher_recvmsg_async(sock, msg, flags) :
> skcipher_recvmsg_sync(sock, msg, flags);
> }
>
> Note that !is_sync_kiocb() in there. Compare with init_sync_kiocb() in
> sock_recvmsg()...
The only problem is it calls init_sync_kiocb(&iocb, NULL) on a different iocb.
The one that isn't even passed to skcipher_recvmsg()
skcipher_recvmsg() checks is_sync_kiocb(msg->msg_iocb).
I just want to make sure that after the merging window is closed I can still
trigger aio_read on PF_ALG socket.
thanks
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete
2015-04-14 18:37 ` Tadeusz Struk
@ 2015-04-14 19:22 ` Al Viro
0 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2015-04-14 19:22 UTC (permalink / raw)
To: Tadeusz Struk; +Cc: davem, netdev, linux-crypto
On Tue, Apr 14, 2015 at 11:37:01AM -0700, Tadeusz Struk wrote:
> The only problem is it calls init_sync_kiocb(&iocb, NULL) on a different iocb.
> The one that isn't even passed to skcipher_recvmsg()
> skcipher_recvmsg() checks is_sync_kiocb(msg->msg_iocb).
> I just want to make sure that after the merging window is closed I can still
> trigger aio_read on PF_ALG socket.
> thanks
... and after the merge with net-next#master that BUG_ON() is gone, so
you are still just fine.
FWIW, in the current for-davem (or in net-next#master, now that Dave has
pulled it) the functions in question are:
static inline int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
size_t size, int flags)
{
return sock->ops->recvmsg(sock, msg, size, flags);
}
int sock_recvmsg(struct socket *sock, struct msghdr *msg, size_t size,
int flags)
{
int err = security_socket_recvmsg(sock, msg, size, flags);
return err ?: sock_recvmsg_nosec(sock, msg, size, flags);
}
EXPORT_SYMBOL(sock_recvmsg);
static ssize_t sock_read_iter(struct kiocb *iocb, struct iov_iter *to)
{
struct file *file = iocb->ki_filp;
struct socket *sock = file->private_data;
struct msghdr msg = {.msg_iter = *to,
.msg_iocb = iocb};
ssize_t res;
if (file->f_flags & O_NONBLOCK)
msg.msg_flags = MSG_DONTWAIT;
if (iocb->ki_pos != 0)
return -ESPIPE;
if (!iov_iter_count(to)) /* Match SYS5 behaviour */
return 0;
res = sock_recvmsg(sock, &msg, iov_iter_count(to), msg.msg_flags);
*to = msg.msg_iter;
return res;
}
AFAICS, everything looks fine. Now, _another_ BUG_ON() might be worth
eventual removal (one in sock_sendmsg_nosec()), but right now we don't
have async ->sendmsg() instances, so it's not urgent.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-04-14 19:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20150411211742.GJ889@ZenIV.linux.org.uk>
[not found] ` <1428787108-13650-3-git-send-email-viro@ZenIV.linux.org.uk>
2015-04-14 18:00 ` [PATCH 03/17] fs: don't allow to complete sync iocbs through aio_complete Tadeusz Struk
2015-04-14 18:26 ` Al Viro
2015-04-14 18:37 ` Tadeusz Struk
2015-04-14 19:22 ` Al Viro
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).