Liping Zhang
10596608c4
netfilter: nf_tables: fix mismatch in big-endian system
...
Currently, there are two different methods to store an u16 integer to
the u32 data register. For example:
u32 *dest = ®s->data[priv->dreg];
1. *dest = 0; *(u16 *) dest = val_u16;
2. *dest = val_u16;
For method 1, the u16 value will be stored like this, either in
big-endian or little-endian system:
0 15 31
+-+-+-+-+-+-+-+-+-+-+-+-+
| Value | 0 |
+-+-+-+-+-+-+-+-+-+-+-+-+
For method 2, in little-endian system, the u16 value will be the same
as listed above. But in big-endian system, the u16 value will be stored
like this:
0 15 31
+-+-+-+-+-+-+-+-+-+-+-+-+
| 0 | Value |
+-+-+-+-+-+-+-+-+-+-+-+-+
So later we use "memcmp(®s->data[priv->sreg], data, 2);" to do
compare in nft_cmp, nft_lookup expr ..., method 2 will get the wrong
result in big-endian system, as 0~15 bits will always be zero.
For the similar reason, when loading an u16 value from the u32 data
register, we should use "*(u16 *) sreg;" instead of "(u16)*sreg;",
the 2nd method will get the wrong value in the big-endian system.
So introduce some wrapper functions to store/load an u8 or u16
integer to/from the u32 data register, and use them in the right
place.
Signed-off-by: Liping Zhang <zlpnobody@gmail.com >
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org >
2017-03-13 13:30:28 +01:00
..
2017-02-19 19:08:47 +01:00
2017-02-27 18:43:47 -08:00
2017-02-02 14:31:56 +01:00
2017-02-08 14:17:09 +01:00
2017-02-08 14:16:21 +01:00
2017-02-03 16:58:20 -05:00
2016-08-30 11:43:08 +02:00
2017-02-26 17:06:59 +01:00
2016-07-11 11:47:50 +02:00
2017-02-27 18:43:47 -08:00
2016-07-11 12:32:45 +02:00
2016-09-24 21:29:53 +02:00
2017-02-06 12:03:35 +01:00
2016-07-21 02:31:53 +02:00
2016-07-22 17:05:10 +02:00
2017-02-06 12:49:05 +01:00
2016-08-30 11:43:09 +02:00
2017-02-02 14:31:51 +01:00
2016-08-13 13:27:13 +02:00
2016-11-18 10:59:15 -05:00
2017-02-02 14:31:51 +01:00
2017-02-02 14:31:51 +01:00
2017-02-02 14:31:51 +01:00
2016-12-04 21:17:25 +01:00
2016-07-21 02:31:53 +02:00
2016-09-25 14:54:01 +02:00
2017-03-03 13:48:31 +01:00
2017-02-02 14:31:56 +01:00
2016-07-21 02:31:53 +02:00
2015-12-14 12:48:58 +01:00
2016-12-06 21:48:22 +01:00
2016-11-03 11:52:59 +01:00
2016-12-04 20:45:33 +01:00
2016-12-04 20:45:33 +01:00
2017-02-03 16:58:20 -05:00
2016-12-04 20:45:32 +01:00
2017-02-02 14:31:53 +01:00
2016-12-04 20:45:30 +01:00
2017-03-08 18:04:06 +01:00
2017-01-03 14:33:25 +01:00
2015-10-27 06:54:56 +01:00
2016-12-06 21:42:15 +01:00
2016-11-18 10:59:15 -05:00
2017-03-03 13:48:34 +01:00
2016-11-09 23:42:23 +01:00
2016-09-12 19:54:45 +02:00
2016-09-12 19:54:45 +02:00
2016-11-03 11:52:34 +01:00
2016-08-25 13:11:00 +02:00
2017-02-27 18:43:46 -08:00
2016-08-25 13:11:30 +02:00
2016-12-25 17:21:22 +01:00
2016-12-25 17:21:22 +01:00
2017-02-23 10:59:15 -05:00
2016-11-09 23:42:23 +01:00
2016-11-09 23:42:23 +01:00
2016-11-09 23:42:23 +01:00
2016-07-23 12:25:00 +02:00
2016-12-11 10:01:05 -05:00
2017-03-13 13:30:28 +01:00
2016-01-03 21:04:23 +01:00
2017-01-23 23:36:50 +01:00
2017-02-08 14:17:09 +01:00
2016-11-03 11:52:34 +01:00
2016-12-06 21:42:20 +01:00
2016-12-06 21:48:22 +01:00
2016-12-03 12:29:53 -05:00
2016-11-09 23:42:23 +01:00
2016-10-04 08:59:03 +02:00
2017-01-24 21:46:29 +01:00
2017-01-23 23:36:50 +01:00
2016-12-04 21:17:16 +01:00
2017-03-13 13:30:28 +01:00
2017-03-13 13:30:28 +01:00
2016-10-26 16:35:16 +02:00
2017-01-23 23:36:50 +01:00
2016-12-14 23:39:11 +01:00
2016-12-14 23:39:01 +01:00
2016-12-14 23:38:51 +01:00
2016-12-03 12:29:53 -05:00
2016-12-04 21:17:16 +01:00
2016-11-03 11:52:34 +01:00
2016-08-25 12:55:34 +02:00
2016-11-03 11:52:34 +01:00
2017-03-13 13:16:42 +01:00
2017-02-12 14:45:14 +01:00
2017-03-03 13:48:32 +01:00
2017-02-27 18:43:46 -08:00
2016-11-03 10:56:21 +01:00
2016-11-03 10:56:21 +01:00
2017-01-09 17:24:55 +01:00
2017-01-09 17:24:55 +01:00
2016-11-03 10:56:21 +01:00
2016-12-04 21:16:50 +01:00
2016-12-04 21:16:50 +01:00
2017-01-09 17:24:55 +01:00
2016-12-04 21:16:50 +01:00
2016-12-04 21:16:50 +01:00
2016-12-04 21:16:50 +01:00
2017-02-02 14:31:56 +01:00
2016-11-03 10:56:21 +01:00
2016-11-03 10:56:21 +01:00
2017-02-23 10:59:15 -05:00
2016-12-04 21:16:50 +01:00
2016-04-29 14:28:48 +02:00
2016-10-17 17:38:19 +02:00
2016-11-03 10:56:21 +01:00
2017-01-09 17:24:55 +01:00
2016-11-03 10:56:21 +01:00
2016-12-06 21:48:20 +01:00
2016-12-04 21:16:51 +01:00
2016-12-04 21:16:51 +01:00
2016-11-03 10:56:21 +01:00
2016-11-03 10:56:21 +01:00
2016-11-03 10:56:21 +01:00
2016-11-03 10:56:21 +01:00
2017-03-02 08:42:31 +01:00
2016-08-12 00:42:14 +02:00
2017-01-18 20:32:43 +01:00
2016-11-03 10:56:21 +01:00
2017-01-09 17:24:55 +01:00
2017-01-09 17:24:55 +01:00
2017-01-09 17:24:55 +01:00
2016-11-18 10:59:15 -05:00
2016-12-04 21:16:51 +01:00
2016-09-22 03:13:26 -04:00
2016-11-10 13:28:42 +01:00
2016-12-06 21:42:00 +01:00
2016-12-04 21:16:50 +01:00
2017-01-09 17:24:55 +01:00
2016-11-03 10:56:21 +01:00
2016-07-03 10:55:07 +02:00
2017-01-09 17:24:55 +01:00
2016-12-25 17:21:22 +01:00
2016-12-06 21:42:00 +01:00
2016-06-23 13:26:49 +02:00