Ilya Leoshkevich
d9b8aadaff
bpf: fix narrower loads on s390
...
The very first check in test_pkt_md_access is failing on s390, which
happens because loading a part of a struct __sk_buff field produces
an incorrect result.
The preprocessed code of the check is:
{
__u8 tmp = *((volatile __u8 *)&skb->len +
((sizeof(skb->len) - sizeof(__u8)) / sizeof(__u8)));
if (tmp != ((*(volatile __u32 *)&skb->len) & 0xFF)) return 2;
};
clang generates the following code for it:
0: 71 21 00 03 00 00 00 00 r2 = *(u8 *)(r1 + 3)
1: 61 31 00 00 00 00 00 00 r3 = *(u32 *)(r1 + 0)
2: 57 30 00 00 00 00 00 ff r3 &= 255
3: 5d 23 00 1d 00 00 00 00 if r2 != r3 goto +29 <LBB0_10>
Finally, verifier transforms it to:
0: (61) r2 = *(u32 *)(r1 +104)
1: (bc) w2 = w2
2: (74) w2 >>= 24
3: (bc) w2 = w2
4: (54) w2 &= 255
5: (bc) w2 = w2
The problem is that when verifier emits the code to replace a partial
load of a struct __sk_buff field (*(u8 *)(r1 + 3)) with a full load of
struct sk_buff field (*(u32 *)(r1 + 104)), an optional shift and a
bitwise AND, it assumes that the machine is little endian and
incorrectly decides to use a shift.
Adjust shift count calculation to account for endianness.
Fixes: 31fd85816d ("bpf: permits narrower load from bpf program context fields")
Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com >
Signed-off-by: Alexei Starovoitov <ast@kernel.org >
2019-07-23 13:59:33 -07:00
..
2019-06-19 17:09:55 +02:00
2019-06-26 09:18:54 -07:00
2019-06-19 17:09:55 +02:00
2019-07-03 16:57:18 +02:00
2019-06-19 17:09:55 +02:00
2019-07-13 15:42:44 -07:00
2019-06-19 17:09:55 +02:00
2019-06-21 16:01:06 +02:00
2019-06-19 17:09:55 +02:00
2019-07-13 15:02:27 -07:00
2019-06-20 09:23:22 +02:00
2019-06-19 17:09:55 +02:00
2019-07-13 14:40:42 -07:00
2019-07-08 11:01:13 -07:00
2019-07-03 17:52:08 -04:00
2019-06-19 17:09:55 +02:00
2019-07-12 12:24:03 -07:00
2019-07-11 15:06:37 -07:00
2019-07-11 18:11:21 -07:00
2019-07-13 15:42:44 -07:00
2019-06-25 01:32:59 +02:00
2019-07-08 09:54:55 -07:00
2019-07-13 15:02:27 -07:00
2019-07-11 18:45:29 -07:00
2019-06-19 17:09:55 +02:00
2019-06-17 20:20:36 -07:00
2019-07-04 17:34:34 +01:00
2019-06-19 17:09:55 +02:00
2019-07-11 10:09:44 -07:00
2019-07-01 11:52:43 +05:30
2019-07-04 17:35:11 +01:00
2019-07-10 21:22:43 -07:00
2019-07-12 15:13:55 -07:00
2019-06-19 17:09:07 +02:00
2019-06-19 17:09:55 +02:00
2019-07-09 10:05:22 -07:00
2019-06-19 17:09:07 +02:00
2019-06-24 19:23:39 +02:00
2019-07-08 18:55:42 -07:00
2019-07-01 08:18:54 -06:00
2019-06-20 10:29:22 -06:00
2019-06-20 10:32:34 -06:00
2019-06-20 10:29:22 -06:00
2019-06-20 13:03:51 -06:00
2019-06-27 15:25:16 -07:00
2019-06-20 00:06:27 -04:00
2019-06-27 15:25:16 -07:00
2019-06-27 15:25:16 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:08 +02:00
2019-07-08 21:35:12 -07:00
2019-07-11 10:55:49 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-20 07:56:13 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-08 11:00:02 +02:00
2019-07-12 12:24:03 -07:00
2019-06-19 17:09:06 +02:00
2019-06-19 17:09:06 +02:00
2019-07-08 20:57:08 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-12 12:24:03 -07:00
2019-06-25 13:46:40 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:07 +02:00
2019-06-24 10:23:16 +02:00
2019-07-10 13:17:30 +02:00
2019-07-08 14:19:33 -07:00
2019-07-12 11:05:41 -07:00
2019-06-27 23:02:12 +01:00
2019-06-19 17:09:55 +02:00
2019-06-24 23:57:50 +03:00
2019-06-20 10:29:22 -06:00
2019-06-24 19:23:39 +02:00
2019-06-14 14:21:07 -06:00
2019-06-19 17:09:55 +02:00
2019-07-23 13:59:33 -07:00
2019-06-24 09:16:47 +10:00
2019-06-14 14:18:53 -06:00
2019-07-12 16:54:37 -07:00
2019-06-19 17:09:11 +02:00
2019-07-03 18:52:20 +02:00
2019-07-10 20:09:17 -07:00
2019-06-20 14:47:54 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-12 15:13:55 -07:00
2019-06-22 21:21:04 +02:00
2019-06-22 21:21:04 +02:00
2019-07-12 11:05:45 -07:00
2019-06-19 17:09:55 +02:00
2019-07-09 14:52:14 -07:00
2019-07-01 19:15:46 -07:00
2019-06-22 08:59:24 -04:00
2019-07-05 21:34:50 +02:00
2019-07-08 19:25:19 -07:00
2019-07-08 20:28:59 -07:00
2019-06-26 13:19:46 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-04 17:26:48 +02:00
2019-06-26 14:08:11 +02:00
2019-07-04 17:26:48 +02:00
2019-06-19 17:09:56 +02:00
2019-06-25 12:51:25 +01:00
2019-06-19 17:09:56 +02:00
2019-06-27 17:28:40 -07:00
2019-07-04 17:26:48 +02:00
2019-06-14 14:31:48 -06:00
2019-06-20 09:58:07 +02:00
2019-06-19 17:09:55 +02:00
2019-06-20 17:32:21 -04:00
2019-06-14 19:31:47 -07:00
2019-06-17 12:09:22 +02:00
2019-07-12 11:05:42 -07:00
2019-07-12 11:05:42 -07:00
2019-06-29 16:43:45 +08:00
2019-07-08 19:36:47 -07:00
2019-07-10 18:43:43 -07:00
2019-06-19 17:09:08 +02:00
2019-07-11 15:14:16 +02:00
2019-06-19 17:09:07 +02:00
2019-06-19 17:09:56 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-29 01:31:08 +02:00
2019-07-11 15:30:05 -07:00
2019-07-08 16:12:03 -07:00
2019-06-24 19:23:44 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-12 11:05:47 -07:00
2019-06-13 17:34:56 -10:00
2019-06-19 17:09:55 +02:00
2019-07-12 11:05:42 -07:00
2019-06-19 17:09:55 +02:00
2019-07-12 11:05:46 -07:00
2019-07-03 19:28:40 +02:00
2019-07-08 19:25:19 -07:00
2019-07-01 19:34:46 -07:00
2019-06-21 17:21:11 +02:00
2019-07-01 19:12:10 -07:00
2019-06-21 11:08:37 +02:00
2019-06-21 11:12:22 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-07-12 11:05:47 -07:00
2019-07-12 11:05:43 -07:00
2019-07-12 11:05:43 -07:00
2019-07-12 11:05:43 -07:00
2019-07-12 11:05:43 -07:00
2019-06-21 22:05:42 -04:00
2019-06-19 17:09:55 +02:00
2019-07-08 16:12:03 -07:00
2019-07-08 18:04:41 +02:00
2019-06-24 19:19:23 +02:00
2019-07-12 11:05:42 -07:00
2019-07-12 15:26:29 -07:00
2019-07-08 19:48:57 -07:00
2019-06-28 12:17:55 +02:00
2019-06-26 10:53:57 +02:00
2019-06-22 11:28:37 +02:00
2019-07-04 10:50:40 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-15 12:25:49 +02:00
2019-07-09 10:28:47 -07:00
2019-06-19 17:09:55 +02:00
2019-06-13 22:34:55 -07:00
2019-06-26 11:39:11 +02:00
2019-06-19 17:09:55 +02:00
2019-06-28 19:46:47 +02:00
2019-07-09 12:34:26 -07:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:07 +02:00
2019-06-17 12:28:06 +02:00
2019-06-20 15:21:33 -04:00
2019-06-19 17:09:55 +02:00
2019-07-08 19:19:37 -07:00
2019-06-14 09:02:42 -04:00
2019-06-29 10:33:57 -06:00
2019-07-03 17:52:50 -04:00
2019-06-21 10:18:43 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:55 +02:00
2019-06-19 17:09:06 +02:00
2019-06-29 16:43:45 +08:00
2019-07-09 09:07:00 -07:00
2019-07-09 11:35:38 -07:00
2019-07-09 12:11:59 -07:00
2019-07-22 16:04:17 +02:00
2019-07-12 11:05:44 -07:00
2019-06-19 17:09:55 +02:00
2019-07-08 16:12:03 -07:00
2019-07-09 14:32:14 -06:00
2019-06-17 20:20:36 -07:00
2019-06-15 12:25:55 +02:00
2019-07-03 17:52:50 -04:00
2019-07-08 10:51:25 +02:00
2019-07-12 11:05:43 -07:00
2019-06-19 17:09:55 +02:00
2019-07-11 10:09:44 -07:00
2019-06-14 20:18:27 -07:00
2019-06-19 17:09:55 +02:00
2019-06-22 16:30:37 -07:00
2019-06-19 17:09:55 +02:00
2019-06-25 08:54:51 +02:00
2019-07-07 11:50:03 +02:00
2019-06-19 17:09:55 +02:00
2019-06-24 23:57:49 +03:00
2019-06-19 17:09:55 +02:00
2019-07-08 19:19:37 -07:00
2019-06-19 17:09:55 +02:00
2019-07-13 10:36:53 -07:00
2019-06-19 23:45:09 -04:00
2019-06-26 21:02:32 +01:00
2019-06-19 17:09:55 +02:00
2019-07-12 11:05:47 -07:00
2019-07-12 11:05:43 -07:00
2019-06-21 16:04:05 +02:00
2019-06-19 17:09:55 +02:00
2019-06-27 14:12:15 -07:00