* [PATCH bpf-next 0/2] Split bpf_sk_lookup remote_port field
@ 2022-02-07 13:14 Jakub Sitnicki
2022-02-07 13:14 ` [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Jakub Sitnicki
2022-02-07 13:14 ` [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup Jakub Sitnicki
0 siblings, 2 replies; 13+ messages in thread
From: Jakub Sitnicki @ 2022-02-07 13:14 UTC (permalink / raw)
To: bpf
Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
Following the recent split-up of the bpf_sock dst_port field, apply the same to
technique to the bpf_sk_lookup remote_port field to make uAPI more user
friendly.
Jakub Sitnicki (2):
bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup
include/uapi/linux/bpf.h | 3 ++-
net/core/filter.c | 3 ++-
tools/include/uapi/linux/bpf.h | 3 ++-
tools/testing/selftests/bpf/progs/test_sk_lookup.c | 6 ++++++
4 files changed, 12 insertions(+), 3 deletions(-)
--
2.31.1
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-07 13:14 [PATCH bpf-next 0/2] Split bpf_sk_lookup remote_port field Jakub Sitnicki
@ 2022-02-07 13:14 ` Jakub Sitnicki
2022-02-07 19:14 ` Yonghong Song
2022-02-07 22:04 ` kernel test robot
2022-02-07 13:14 ` [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup Jakub Sitnicki
1 sibling, 2 replies; 13+ messages in thread
From: Jakub Sitnicki @ 2022-02-07 13:14 UTC (permalink / raw)
To: bpf
Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
remote_port is another case of a BPF context field documented as a 32-bit
value in network byte order for which the BPF context access converter
generates a load of a zero-padded 16-bit integer in network byte order.
First such case was dst_port in bpf_sock which got addressed in commit
4421a582718a ("bpf: Make dst_port field in struct bpf_sock 16-bit wide").
Loading 4-bytes from the remote_port offset and converting the value with
bpf_ntohl() leads to surprising results, as the expected value is shifted
by 16 bits.
Reduce the confusion by splitting the field in two - a 16-bit field holding
a big-endian integer, and a 16-bit zero-padding anonymous field that
follows it.
Suggested-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
include/uapi/linux/bpf.h | 3 ++-
net/core/filter.c | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/uapi/linux/bpf.h b/include/uapi/linux/bpf.h
index a7f0ddedac1f..afe3d0d7f5f2 100644
--- a/include/uapi/linux/bpf.h
+++ b/include/uapi/linux/bpf.h
@@ -6453,7 +6453,8 @@ struct bpf_sk_lookup {
__u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */
__u32 remote_ip4; /* Network byte order */
__u32 remote_ip6[4]; /* Network byte order */
- __u32 remote_port; /* Network byte order */
+ __be16 remote_port; /* Network byte order */
+ __u16 :16; /* Zero padding */
__u32 local_ip4; /* Network byte order */
__u32 local_ip6[4]; /* Network byte order */
__u32 local_port; /* Host byte order */
diff --git a/net/core/filter.c b/net/core/filter.c
index 99a05199a806..83f06d3b2c52 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -10843,7 +10843,8 @@ static bool sk_lookup_is_valid_access(int off, int size,
case bpf_ctx_range(struct bpf_sk_lookup, local_ip4):
case bpf_ctx_range_till(struct bpf_sk_lookup, remote_ip6[0], remote_ip6[3]):
case bpf_ctx_range_till(struct bpf_sk_lookup, local_ip6[0], local_ip6[3]):
- case bpf_ctx_range(struct bpf_sk_lookup, remote_port):
+ case offsetof(struct bpf_sk_lookup, remote_port) ...
+ offsetof(struct bpf_sk_lookup, local_ip4) - 1:
case bpf_ctx_range(struct bpf_sk_lookup, local_port):
case bpf_ctx_range(struct bpf_sk_lookup, ingress_ifindex):
bpf_ctx_record_field_size(info, sizeof(__u32));
--
2.31.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup
2022-02-07 13:14 [PATCH bpf-next 0/2] Split bpf_sk_lookup remote_port field Jakub Sitnicki
2022-02-07 13:14 ` [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Jakub Sitnicki
@ 2022-02-07 13:14 ` Jakub Sitnicki
2022-02-07 19:20 ` Yonghong Song
1 sibling, 1 reply; 13+ messages in thread
From: Jakub Sitnicki @ 2022-02-07 13:14 UTC (permalink / raw)
To: bpf
Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
Extend the context access tests for sk_lookup prog to cover the surprising
case of a 4-byte load from the remote_port field, where the expected value
is actually shifted by 16 bits.
Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
---
tools/include/uapi/linux/bpf.h | 3 ++-
tools/testing/selftests/bpf/progs/test_sk_lookup.c | 6 ++++++
2 files changed, 8 insertions(+), 1 deletion(-)
diff --git a/tools/include/uapi/linux/bpf.h b/tools/include/uapi/linux/bpf.h
index a7f0ddedac1f..afe3d0d7f5f2 100644
--- a/tools/include/uapi/linux/bpf.h
+++ b/tools/include/uapi/linux/bpf.h
@@ -6453,7 +6453,8 @@ struct bpf_sk_lookup {
__u32 protocol; /* IP protocol (IPPROTO_TCP, IPPROTO_UDP) */
__u32 remote_ip4; /* Network byte order */
__u32 remote_ip6[4]; /* Network byte order */
- __u32 remote_port; /* Network byte order */
+ __be16 remote_port; /* Network byte order */
+ __u16 :16; /* Zero padding */
__u32 local_ip4; /* Network byte order */
__u32 local_ip6[4]; /* Network byte order */
__u32 local_port; /* Host byte order */
diff --git a/tools/testing/selftests/bpf/progs/test_sk_lookup.c b/tools/testing/selftests/bpf/progs/test_sk_lookup.c
index 83b0aaa52ef7..bf5b7caefdd0 100644
--- a/tools/testing/selftests/bpf/progs/test_sk_lookup.c
+++ b/tools/testing/selftests/bpf/progs/test_sk_lookup.c
@@ -392,6 +392,7 @@ int ctx_narrow_access(struct bpf_sk_lookup *ctx)
{
struct bpf_sock *sk;
int err, family;
+ __u32 val_u32;
bool v4;
v4 = (ctx->family == AF_INET);
@@ -418,6 +419,11 @@ int ctx_narrow_access(struct bpf_sk_lookup *ctx)
if (LSW(ctx->remote_port, 0) != SRC_PORT)
return SK_DROP;
+ /* Load from remote_port field with zero padding (backward compatibility) */
+ val_u32 = *(__u32 *)&ctx->remote_port;
+ if (val_u32 != bpf_htonl(bpf_ntohs(SRC_PORT) << 16))
+ return SK_DROP;
+
/* Narrow loads from local_port field. Expect DST_PORT. */
if (LSB(ctx->local_port, 0) != ((DST_PORT >> 0) & 0xff) ||
LSB(ctx->local_port, 1) != ((DST_PORT >> 8) & 0xff) ||
--
2.31.1
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-07 13:14 ` [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Jakub Sitnicki
@ 2022-02-07 19:14 ` Yonghong Song
2022-02-07 22:04 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: Yonghong Song @ 2022-02-07 19:14 UTC (permalink / raw)
To: Jakub Sitnicki, bpf
Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
On 2/7/22 5:14 AM, Jakub Sitnicki wrote:
> remote_port is another case of a BPF context field documented as a 32-bit
> value in network byte order for which the BPF context access converter
> generates a load of a zero-padded 16-bit integer in network byte order.
>
> First such case was dst_port in bpf_sock which got addressed in commit
> 4421a582718a ("bpf: Make dst_port field in struct bpf_sock 16-bit wide").
>
> Loading 4-bytes from the remote_port offset and converting the value with
> bpf_ntohl() leads to surprising results, as the expected value is shifted
> by 16 bits.
>
> Reduce the confusion by splitting the field in two - a 16-bit field holding
> a big-endian integer, and a 16-bit zero-padding anonymous field that
> follows it.
>
> Suggested-by: Alexei Starovoitov <ast@kernel.org>
> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup
2022-02-07 13:14 ` [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup Jakub Sitnicki
@ 2022-02-07 19:20 ` Yonghong Song
0 siblings, 0 replies; 13+ messages in thread
From: Yonghong Song @ 2022-02-07 19:20 UTC (permalink / raw)
To: Jakub Sitnicki, bpf
Cc: netdev, Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
On 2/7/22 5:14 AM, Jakub Sitnicki wrote:
> Extend the context access tests for sk_lookup prog to cover the surprising
> case of a 4-byte load from the remote_port field, where the expected value
> is actually shifted by 16 bits.
>
> Signed-off-by: Jakub Sitnicki <jakub@cloudflare.com>
Acked-by: Yonghong Song <yhs@fb.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-07 13:14 ` [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Jakub Sitnicki
@ 2022-02-07 22:04 ` kernel test robot
2022-02-07 22:04 ` kernel test robot
1 sibling, 0 replies; 13+ messages in thread
From: kernel test robot @ 2022-02-07 22:04 UTC (permalink / raw)
To: Jakub Sitnicki, bpf
Cc: kbuild-all, netdev, Alexei Starovoitov, Daniel Borkmann,
Andrii Nakryiko, kernel-team
Hi Jakub,
I love your patch! Perhaps something to improve:
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Jakub-Sitnicki/Split-bpf_sk_lookup-remote_port-field/20220207-215137
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: sparc-randconfig-s031-20220207 (https://download.01.org/0day-ci/archive/20220208/202202080631.n8UjqRXy-lkp@intel.com/config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/b859a90e4c32a55e71d2731dd8dae96d7ad1defe
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jakub-Sitnicki/Split-bpf_sk_lookup-remote_port-field/20220207-215137
git checkout b859a90e4c32a55e71d2731dd8dae96d7ad1defe
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash net/bpf/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> net/bpf/test_run.c:1149:55: sparse: sparse: restricted __be16 degrades to integer
vim +1149 net/bpf/test_run.c
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1111
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1112 int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, const union bpf_attr *kattr,
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1113 union bpf_attr __user *uattr)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1114 {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1115 struct bpf_test_timer t = { NO_PREEMPT };
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1116 struct bpf_prog_array *progs = NULL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1117 struct bpf_sk_lookup_kern ctx = {};
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1118 u32 repeat = kattr->test.repeat;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1119 struct bpf_sk_lookup *user_ctx;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1120 u32 retval, duration;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1121 int ret = -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1122
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1123 if (prog->type != BPF_PROG_TYPE_SK_LOOKUP)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1124 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1125
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1126 if (kattr->test.flags || kattr->test.cpu)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1127 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1128
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1129 if (kattr->test.data_in || kattr->test.data_size_in || kattr->test.data_out ||
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1130 kattr->test.data_size_out)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1131 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1132
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1133 if (!repeat)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1134 repeat = 1;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1135
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1136 user_ctx = bpf_ctx_init(kattr, sizeof(*user_ctx));
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1137 if (IS_ERR(user_ctx))
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1138 return PTR_ERR(user_ctx);
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1139
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1140 if (!user_ctx)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1141 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1142
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1143 if (user_ctx->sk)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1144 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1145
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1146 if (!range_is_zero(user_ctx, offsetofend(typeof(*user_ctx), local_port), sizeof(*user_ctx)))
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1147 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1150 ret = -ERANGE;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1151 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1152 }
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1153
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1154 ctx.family = (u16)user_ctx->family;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1155 ctx.protocol = (u16)user_ctx->protocol;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1156 ctx.dport = (u16)user_ctx->local_port;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1157 ctx.sport = (__force __be16)user_ctx->remote_port;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1158
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1159 switch (ctx.family) {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1160 case AF_INET:
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1161 ctx.v4.daddr = (__force __be32)user_ctx->local_ip4;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1162 ctx.v4.saddr = (__force __be32)user_ctx->remote_ip4;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1163 break;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1164
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
@ 2022-02-07 22:04 ` kernel test robot
0 siblings, 0 replies; 13+ messages in thread
From: kernel test robot @ 2022-02-07 22:04 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 5640 bytes --]
Hi Jakub,
I love your patch! Perhaps something to improve:
[auto build test WARNING on bpf-next/master]
url: https://github.com/0day-ci/linux/commits/Jakub-Sitnicki/Split-bpf_sk_lookup-remote_port-field/20220207-215137
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
config: sparc-randconfig-s031-20220207 (https://download.01.org/0day-ci/archive/20220208/202202080631.n8UjqRXy-lkp(a)intel.com/config)
compiler: sparc64-linux-gcc (GCC) 11.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-dirty
# https://github.com/0day-ci/linux/commit/b859a90e4c32a55e71d2731dd8dae96d7ad1defe
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Jakub-Sitnicki/Split-bpf_sk_lookup-remote_port-field/20220207-215137
git checkout b859a90e4c32a55e71d2731dd8dae96d7ad1defe
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=sparc SHELL=/bin/bash net/bpf/
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
sparse warnings: (new ones prefixed by >>)
>> net/bpf/test_run.c:1149:55: sparse: sparse: restricted __be16 degrades to integer
vim +1149 net/bpf/test_run.c
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1111
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1112 int bpf_prog_test_run_sk_lookup(struct bpf_prog *prog, const union bpf_attr *kattr,
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1113 union bpf_attr __user *uattr)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1114 {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1115 struct bpf_test_timer t = { NO_PREEMPT };
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1116 struct bpf_prog_array *progs = NULL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1117 struct bpf_sk_lookup_kern ctx = {};
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1118 u32 repeat = kattr->test.repeat;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1119 struct bpf_sk_lookup *user_ctx;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1120 u32 retval, duration;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1121 int ret = -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1122
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1123 if (prog->type != BPF_PROG_TYPE_SK_LOOKUP)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1124 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1125
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1126 if (kattr->test.flags || kattr->test.cpu)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1127 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1128
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1129 if (kattr->test.data_in || kattr->test.data_size_in || kattr->test.data_out ||
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1130 kattr->test.data_size_out)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1131 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1132
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1133 if (!repeat)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1134 repeat = 1;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1135
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1136 user_ctx = bpf_ctx_init(kattr, sizeof(*user_ctx));
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1137 if (IS_ERR(user_ctx))
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1138 return PTR_ERR(user_ctx);
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1139
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1140 if (!user_ctx)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1141 return -EINVAL;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1142
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1143 if (user_ctx->sk)
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1144 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1145
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1146 if (!range_is_zero(user_ctx, offsetofend(typeof(*user_ctx), local_port), sizeof(*user_ctx)))
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1147 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1150 ret = -ERANGE;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1151 goto out;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1152 }
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1153
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1154 ctx.family = (u16)user_ctx->family;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1155 ctx.protocol = (u16)user_ctx->protocol;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1156 ctx.dport = (u16)user_ctx->local_port;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1157 ctx.sport = (__force __be16)user_ctx->remote_port;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1158
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1159 switch (ctx.family) {
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1160 case AF_INET:
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1161 ctx.v4.daddr = (__force __be32)user_ctx->local_ip4;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1162 ctx.v4.saddr = (__force __be32)user_ctx->remote_ip4;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1163 break;
7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1164
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-07 22:04 ` kernel test robot
@ 2022-02-08 19:28 ` Alexei Starovoitov
-1 siblings, 0 replies; 13+ messages in thread
From: Alexei Starovoitov @ 2022-02-08 19:28 UTC (permalink / raw)
To: kernel test robot
Cc: Jakub Sitnicki, bpf, kbuild-all, Network Development,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
Jakub,
are you planning to respin and remove that check?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
@ 2022-02-08 19:28 ` Alexei Starovoitov
0 siblings, 0 replies; 13+ messages in thread
From: Alexei Starovoitov @ 2022-02-08 19:28 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 305 bytes --]
On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
Jakub,
are you planning to respin and remove that check?
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-08 19:28 ` Alexei Starovoitov
@ 2022-02-08 20:42 ` Jakub Sitnicki
-1 siblings, 0 replies; 13+ messages in thread
From: Jakub Sitnicki @ 2022-02-08 20:42 UTC (permalink / raw)
To: Alexei Starovoitov
Cc: kernel test robot, bpf, kbuild-all, Network Development,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
On Tue, Feb 08, 2022 at 08:28 PM CET, Alexei Starovoitov wrote:
> On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
>> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
>> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
>
> Jakub,
> are you planning to respin and remove that check?
Yes, certainly. Just didn't get to it today.
Can either respin the series or send a follow-up. Whatever works.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
@ 2022-02-08 20:42 ` Jakub Sitnicki
0 siblings, 0 replies; 13+ messages in thread
From: Jakub Sitnicki @ 2022-02-08 20:42 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 496 bytes --]
On Tue, Feb 08, 2022 at 08:28 PM CET, Alexei Starovoitov wrote:
> On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
>> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
>> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
>
> Jakub,
> are you planning to respin and remove that check?
Yes, certainly. Just didn't get to it today.
Can either respin the series or send a follow-up. Whatever works.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
2022-02-08 20:42 ` Jakub Sitnicki
@ 2022-02-08 20:58 ` Alexei Starovoitov
-1 siblings, 0 replies; 13+ messages in thread
From: Alexei Starovoitov @ 2022-02-08 20:58 UTC (permalink / raw)
To: Jakub Sitnicki
Cc: kernel test robot, bpf, kbuild-all, Network Development,
Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
kernel-team
On Tue, Feb 8, 2022 at 12:42 PM Jakub Sitnicki <jakub@cloudflare.com> wrote:
>
> On Tue, Feb 08, 2022 at 08:28 PM CET, Alexei Starovoitov wrote:
> > On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
> >> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
> >> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
> >
> > Jakub,
> > are you planning to respin and remove that check?
>
> Yes, certainly. Just didn't get to it today.
>
> Can either respin the series or send a follow-up. Whatever works.
I think respin is better.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide
@ 2022-02-08 20:58 ` Alexei Starovoitov
0 siblings, 0 replies; 13+ messages in thread
From: Alexei Starovoitov @ 2022-02-08 20:58 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 626 bytes --]
On Tue, Feb 8, 2022 at 12:42 PM Jakub Sitnicki <jakub@cloudflare.com> wrote:
>
> On Tue, Feb 08, 2022 at 08:28 PM CET, Alexei Starovoitov wrote:
> > On Mon, Feb 7, 2022 at 2:05 PM kernel test robot <lkp@intel.com> wrote:
> >> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 1148
> >> 7c32e8f8bc33a5f Lorenz Bauer 2021-03-03 @1149 if (user_ctx->local_port > U16_MAX || user_ctx->remote_port > U16_MAX) {
> >
> > Jakub,
> > are you planning to respin and remove that check?
>
> Yes, certainly. Just didn't get to it today.
>
> Can either respin the series or send a follow-up. Whatever works.
I think respin is better.
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2022-02-08 22:23 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-07 13:14 [PATCH bpf-next 0/2] Split bpf_sk_lookup remote_port field Jakub Sitnicki
2022-02-07 13:14 ` [PATCH bpf-next 1/2] bpf: Make remote_port field in struct bpf_sk_lookup 16-bit wide Jakub Sitnicki
2022-02-07 19:14 ` Yonghong Song
2022-02-07 22:04 ` kernel test robot
2022-02-07 22:04 ` kernel test robot
2022-02-08 19:28 ` Alexei Starovoitov
2022-02-08 19:28 ` Alexei Starovoitov
2022-02-08 20:42 ` Jakub Sitnicki
2022-02-08 20:42 ` Jakub Sitnicki
2022-02-08 20:58 ` Alexei Starovoitov
2022-02-08 20:58 ` Alexei Starovoitov
2022-02-07 13:14 ` [PATCH bpf-next 2/2] selftests/bpf: Cover 4-byte load from remote_port in bpf_sk_lookup Jakub Sitnicki
2022-02-07 19:20 ` Yonghong Song
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.