From: Gabriel Krisman Bertazi <krisman@suse.de>
To: Stefan Metzmacher <metze@samba.org>
Cc: Jens Axboe <axboe@kernel.dk>,
netdev@vger.kernel.org, io-uring@vger.kernel.org,
Jakub Kicinski <kuba@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Kuniyuki Iwashima <kuniyu@google.com>,
Paolo Abeni <pabeni@redhat.com>,
Willem de Bruijn <willemb@google.com>,
Simon Horman <horms@kernel.org>
Subject: Re: [PATCH v3 3/3] io_uring: Introduce getsockname io_uring cmd
Date: Tue, 25 Nov 2025 13:37:27 -0500 [thread overview]
Message-ID: <87y0nuhsbc.fsf@mailhost.krisman.be> (raw)
In-Reply-To: <dc97cb0e-628c-4a97-98ca-06ececf32e1e@samba.org> (Stefan Metzmacher's message of "Tue, 25 Nov 2025 13:36:26 +0100")
Stefan Metzmacher <metze@samba.org> writes:
> Hi Gabriel,
>
>> +static int io_uring_cmd_getsockname(struct socket *sock,
>> + struct io_uring_cmd *cmd,
>> + unsigned int issue_flags)
>> +{
>> + const struct io_uring_sqe *sqe = cmd->sqe;
>> + struct sockaddr __user *uaddr;
>> + unsigned int peer;
>> + int __user *ulen;
>> +
>> + if (sqe->ioprio || sqe->__pad1 || sqe->len || sqe->rw_flags)
>> + return -EINVAL;
>> +
>> + uaddr = u64_to_user_ptr(READ_ONCE(sqe->addr));
>> + ulen = u64_to_user_ptr(sqe->addr3);
>> + peer = READ_ONCE(sqe->optlen);
>> + if (peer > 1)
>> + return -EINVAL;
>> + return do_getsockname(sock, 0, uaddr, ulen);
>
> I guess this should actually pass down 'peer' instead of '0'?
Thanks for the catch. I guess two wrongs *do* make a right somethings.
The getpeername test was peeking at the wrong socket, effectively
testing the local port against itself, and it thus succeeded. Updated
the test and will send a v4.
--
Gabriel Krisman Bertazi
prev parent reply other threads:[~2025-11-25 18:37 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-25 0:23 [PATCH v3 0/3] Introduce getsockname io_uring_cmd Gabriel Krisman Bertazi
2025-11-25 0:23 ` [PATCH v3 1/3] socket: Unify getsockname and getpeername implementation Gabriel Krisman Bertazi
2025-11-25 0:23 ` [PATCH v3 2/3] socket: Split out a getsockname helper for io_uring Gabriel Krisman Bertazi
2025-11-25 0:23 ` [PATCH v3 3/3] io_uring: Introduce getsockname io_uring cmd Gabriel Krisman Bertazi
2025-11-25 12:36 ` Stefan Metzmacher
2025-11-25 18:37 ` Gabriel Krisman Bertazi [this message]
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=87y0nuhsbc.fsf@mailhost.krisman.be \
--to=krisman@suse.de \
--cc=axboe@kernel.dk \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=io-uring@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@google.com \
--cc=metze@samba.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=willemb@google.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