On 8/25/23 9:53 AM, Breno Leitao wrote:
On Mon, Aug 21, 2023 at 01:25:25PM -0700, Martin KaFai Lau wrote:
On 8/17/23 12:08 PM, Gabriel Krisman Bertazi wrote:
Shouldn't you call sock->ops->getsockopt for level!=SOL_SOCKET prior to
running the hook? Before this patch, it would bail out with EOPNOTSUPP,
but now the bpf hook gets called even for level!=SOL_SOCKET, which
doesn't fit __sys_getsockopt. Am I misreading the code?
I agree it should not call into bpf if the io_uring cannot support non
SOL_SOCKET optnames. Otherwise, the bpf prog will get different optval and
optlen when running in _sys_getsockopt vs io_uring getsockopt (e.g. in
regular _sys_getsockopt(SOL_TCP), bpf expects the optval returned from
tcp_getsockopt).
I think __sys_getsockopt can also be refactored similar to __sys_setsockopt
in patch 3. Yes, for non SOL_SOCKET it only supports __user *optval and
__user *optlen but may be a WARN_ON_ONCE/BUG_ON(sockpt_is_kernel(optval))
can be added before calling ops->getsockopt()? Then this details can be
hidden away from the io_uring.
Right, I've spent some time thinking about it, and this could be done.
This is a draft I have. Is it what you had in mind?
Yes. lgtm. Thanks.