Files
linux-st/include/linux
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
..
2018-05-26 09:16:44 +02:00
2019-05-14 19:52:50 -07:00
2019-07-01 08:18:54 -06:00
2019-04-09 17:05:46 -07:00
2019-05-07 08:39:02 -06:00
2018-06-15 18:10:01 -03:00
2019-05-09 15:25:13 -04:00
2019-06-12 20:27:13 +02:00
2019-07-08 11:00:02 +02:00
2018-03-26 15:09:38 +02:00
2018-08-22 10:52:48 -07:00
2016-10-28 08:48:16 -06:00
2019-07-10 13:17:30 +02:00
2018-11-13 21:55:24 +01:00
2019-02-28 03:28:53 -05:00
2018-01-01 12:40:27 -07:00
2019-06-12 20:30:39 +02:00
2019-02-28 08:24:23 -07:00
2019-07-23 13:59:33 -07:00
2018-12-19 10:42:08 +01:00
2019-06-14 14:18:53 -06:00
2019-04-22 09:48:12 -06:00
2019-07-05 21:34:50 +02:00
2019-06-26 13:19:46 -07:00
2018-11-07 13:42:32 -07:00
2018-06-22 13:43:27 +09:00
2018-07-12 21:35:28 +02:00
2018-04-12 09:41:19 -07:00
2018-06-07 17:34:35 -07:00
2018-03-26 13:14:43 -04:00
2019-01-30 20:51:47 -05:00
2018-10-17 13:56:58 -07:00
2019-07-08 19:25:19 -07:00
2019-02-08 15:02:49 -08:00
2018-01-08 08:22:45 -06:00
2018-10-21 10:46:39 -04:00
2017-11-09 10:23:28 +01:00
2017-11-17 16:10:04 -08:00
2019-06-28 12:17:55 +02:00
2018-10-08 22:53:10 +11:00
2019-05-14 19:52:51 -07:00
2019-06-12 11:42:13 +02:00
2019-06-15 12:25:49 +02:00
2018-07-20 01:11:45 +02:00
2019-04-02 17:57:35 +02:00
2019-05-08 22:14:36 +02:00
2018-09-25 20:17:35 -07:00
2019-05-31 12:37:46 -07:00
2019-05-16 15:51:55 -07:00
2019-07-09 14:32:14 -06:00
2019-02-07 16:38:35 +01:00
2018-01-15 12:07:46 -08:00
2019-07-08 10:51:25 +02:00
2018-06-20 11:35:56 +02:00
2019-07-12 11:05:43 -07:00
2018-09-29 22:47:49 -04:00
2019-06-14 20:18:27 -07:00
2018-10-11 09:16:44 -07:00
2019-02-07 00:13:27 +01:00
2019-07-07 11:50:03 +02:00
2018-12-10 10:17:45 +01:00
2019-01-11 18:05:40 -08:00
2019-06-05 11:54:38 +02:00
2019-05-15 17:35:54 +01:00
2019-04-09 15:14:49 -06:00
2018-12-22 12:15:29 +01:00
2018-05-14 09:51:34 -04:00
2017-08-15 09:02:08 -07:00