On Thu, May 11, 2023 at 03:25:06PM +0200, Alexander Mikhalitsyn wrote:
> Implement ->bpf_bypass_getsockopt proto callback and filter out
> SCTP_SOCKOPT_PEELOFF, SCTP_SOCKOPT_PEELOFF_FLAGS and SCTP_SOCKOPT_CONNECTX3
> socket options from running eBPF hook on them.
>
> SCTP_SOCKOPT_PEELOFF and SCTP_SOCKOPT_PEELOFF_FLAGS options do fd_install(),
> and if BPF_CGROUP_RUN_PROG_GETSOCKOPT hook returns an error after success of
> the original handler sctp_getsockopt(...), userspace will receive an error
> from getsockopt syscall and will be not aware that fd was successfully
> installed into a fdtable.
>
> As pointed by Marcelo Ricardo Leitner it seems reasonable to skip
> bpf getsockopt hook for SCTP_SOCKOPT_CONNECTX3 sockopt too.
> Because internaly, it triggers connect() and if error is masked
> then userspace will be confused.
>
> This patch was born as a result of discussion around a new SCM_PIDFD interface:
> https://lore.kernel.org/all/[email protected]/
>
> Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks")
> Cc: Daniel Borkmann <[email protected]>
> Cc: Christian Brauner <[email protected]>
> Cc: Stanislav Fomichev <[email protected]>
> Cc: Neil Horman <[email protected]>
> Cc: Marcelo Ricardo Leitner <[email protected]>
> Cc: Xin Long <[email protected]>
> Cc: [email protected]
> Cc: [email protected]
> Cc: [email protected]
> Suggested-by: Stanislav Fomichev <[email protected]>
> Acked-by: Stanislav Fomichev <[email protected]>
> Signed-off-by: Alexander Mikhalitsyn <[email protected]>
Thx!
Acked-by: Marcelo Ricardo Leitner <[email protected]>
On Thu, May 11, 2023 at 9:33 AM Marcelo Ricardo Leitner
<[email protected]> wrote:
>
> On Thu, May 11, 2023 at 03:25:06PM +0200, Alexander Mikhalitsyn wrote:
> > Implement ->bpf_bypass_getsockopt proto callback and filter out
> > SCTP_SOCKOPT_PEELOFF, SCTP_SOCKOPT_PEELOFF_FLAGS and SCTP_SOCKOPT_CONNECTX3
> > socket options from running eBPF hook on them.
> >
> > SCTP_SOCKOPT_PEELOFF and SCTP_SOCKOPT_PEELOFF_FLAGS options do fd_install(),
> > and if BPF_CGROUP_RUN_PROG_GETSOCKOPT hook returns an error after success of
> > the original handler sctp_getsockopt(...), userspace will receive an error
> > from getsockopt syscall and will be not aware that fd was successfully
> > installed into a fdtable.
> >
> > As pointed by Marcelo Ricardo Leitner it seems reasonable to skip
> > bpf getsockopt hook for SCTP_SOCKOPT_CONNECTX3 sockopt too.
> > Because internaly, it triggers connect() and if error is masked
> > then userspace will be confused.
> >
> > This patch was born as a result of discussion around a new SCM_PIDFD interface:
> > https://lore.kernel.org/all/[email protected]/
> >
> > Fixes: 0d01da6afc54 ("bpf: implement getsockopt and setsockopt hooks")
> > Cc: Daniel Borkmann <[email protected]>
> > Cc: Christian Brauner <[email protected]>
> > Cc: Stanislav Fomichev <[email protected]>
> > Cc: Neil Horman <[email protected]>
> > Cc: Marcelo Ricardo Leitner <[email protected]>
> > Cc: Xin Long <[email protected]>
> > Cc: [email protected]
> > Cc: [email protected]
> > Cc: [email protected]
> > Suggested-by: Stanislav Fomichev <[email protected]>
> > Acked-by: Stanislav Fomichev <[email protected]>
> > Signed-off-by: Alexander Mikhalitsyn <[email protected]>
>
> Thx!
>
> Acked-by: Marcelo Ricardo Leitner <[email protected]>
Acked-by: Xin Long <[email protected]>