BPF List
 help / color / mirror / Atom feed
* [PATCH bpf] bpf: Return -EINVAL on calling bpf_setsockopt(TCP_SAVED_SYN)
@ 2022-10-25 11:22 Rongfeng Ji
  2022-10-26  0:02 ` Martin KaFai Lau
  0 siblings, 1 reply; 2+ messages in thread
From: Rongfeng Ji @ 2022-10-25 11:22 UTC (permalink / raw)
  To: bpf; +Cc: martin.lau, ast, Rongfeng Ji

TCP_SAVED_SYN is not supported by do_tcp_setsockopt(), but it is not
rejected by sol_tcp_sockopt() during calling bpf_setsockopt(), which
results in returning -ENOPROTOOPT instead of common -EINVAL.

This patch fixes the issue.

Signed-off-by: Rongfeng Ji <SikoJobs@outlook.com>
---
 net/core/filter.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/core/filter.c b/net/core/filter.c
index bb0136e7a8e4..42cd7ec8cc4c 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -5206,6 +5206,9 @@ static int sol_tcp_sockopt(struct sock *sk, int optname,
 		return do_tcp_getsockopt(sk, SOL_TCP, optname,
 					 KERNEL_SOCKPTR(optval),
 					 KERNEL_SOCKPTR(optlen));
+	} else {
+		if (optname == TCP_SAVED_SYN)
+			return -EINVAL;
 	}
 
 	return do_tcp_setsockopt(sk, SOL_TCP, optname,
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-10-26  0:03 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-25 11:22 [PATCH bpf] bpf: Return -EINVAL on calling bpf_setsockopt(TCP_SAVED_SYN) Rongfeng Ji
2022-10-26  0:02 ` Martin KaFai Lau

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox