Skip to content

Commit 68625b7

Browse files
wyqkpborkmann
authored andcommitted
bpf, doc: clarification for the meaning of 'id'
For me, as a reader whose mother language isn't English, the old words bring a little difficulty to catch the meaning, this patch rewords the subsection in a more clarificatory way. This patch also add blank lines as separator at two places to improve readability. Signed-off-by: Wang YanQing <udknight@gmail.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 96112e9 commit 68625b7

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

Documentation/networking/filter.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1142,6 +1142,7 @@ into a register from memory, the register's top 56 bits are known zero, while
11421142
the low 8 are unknown - which is represented as the tnum (0x0; 0xff). If we
11431143
then OR this with 0x40, we get (0x40; 0xbf), then if we add 1 we get (0x0;
11441144
0x1ff), because of potential carries.
1145+
11451146
Besides arithmetic, the register state can also be updated by conditional
11461147
branches. For instance, if a SCALAR_VALUE is compared > 8, in the 'true' branch
11471148
it will have a umin_value (unsigned minimum value) of 9, whereas in the 'false'
@@ -1150,14 +1151,16 @@ BPF_JSGE) would instead update the signed minimum/maximum values. Information
11501151
from the signed and unsigned bounds can be combined; for instance if a value is
11511152
first tested < 8 and then tested s> 4, the verifier will conclude that the value
11521153
is also > 4 and s< 8, since the bounds prevent crossing the sign boundary.
1154+
11531155
PTR_TO_PACKETs with a variable offset part have an 'id', which is common to all
11541156
pointers sharing that same variable offset. This is important for packet range
1155-
checks: after adding some variable to a packet pointer, if you then copy it to
1156-
another register and (say) add a constant 4, both registers will share the same
1157-
'id' but one will have a fixed offset of +4. Then if it is bounds-checked and
1158-
found to be less than a PTR_TO_PACKET_END, the other register is now known to
1159-
have a safe range of at least 4 bytes. See 'Direct packet access', below, for
1160-
more on PTR_TO_PACKET ranges.
1157+
checks: after adding a variable to a packet pointer register A, if you then copy
1158+
it to another register B and then add a constant 4 to A, both registers will
1159+
share the same 'id' but the A will have a fixed offset of +4. Then if A is
1160+
bounds-checked and found to be less than a PTR_TO_PACKET_END, the register B is
1161+
now known to have a safe range of at least 4 bytes. See 'Direct packet access',
1162+
below, for more on PTR_TO_PACKET ranges.
1163+
11611164
The 'id' field is also used on PTR_TO_MAP_VALUE_OR_NULL, common to all copies of
11621165
the pointer returned from a map lookup. This means that when one copy is
11631166
checked and found to be non-NULL, all copies can become PTR_TO_MAP_VALUEs.

0 commit comments

Comments
 (0)