Skip to content

Commit a42effb

Browse files
davemarchevskyAlexei Starovoitov
authored andcommitted
bpf: Clarify data_len param in bpf_snprintf and bpf_seq_printf comments
Since the data_len in these two functions is a byte len of the preceding u64 *data array, it must always be a multiple of 8. If this isn't the case both helpers error out, so let's make the requirement explicit so users don't need to infer it. Signed-off-by: Dave Marchevsky <davemarchevsky@fb.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20210917182911.2426606-10-davemarchevsky@fb.com
1 parent 7606729 commit a42effb

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

  • include/uapi/linux
  • tools/include/uapi/linux

‎include/uapi/linux/bpf.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,7 +4046,7 @@ union bpf_attr {
40464046
* arguments. The *data* are a **u64** array and corresponding format string
40474047
* values are stored in the array. For strings and pointers where pointees
40484048
* are accessed, only the pointer values are stored in the *data* array.
4049-
* The *data_len* is the size of *data* in bytes.
4049+
* The *data_len* is the size of *data* in bytes - must be a multiple of 8.
40504050
*
40514051
* Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory.
40524052
* Reading kernel memory may fail due to either invalid address or
@@ -4751,7 +4751,8 @@ union bpf_attr {
47514751
* Each format specifier in **fmt** corresponds to one u64 element
47524752
* in the **data** array. For strings and pointers where pointees
47534753
* are accessed, only the pointer values are stored in the *data*
4754-
* array. The *data_len* is the size of *data* in bytes.
4754+
* array. The *data_len* is the size of *data* in bytes - must be
4755+
* a multiple of 8.
47554756
*
47564757
* Formats **%s** and **%p{i,I}{4,6}** require to read kernel
47574758
* memory. Reading kernel memory may fail due to either invalid

‎tools/include/uapi/linux/bpf.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4046,7 +4046,7 @@ union bpf_attr {
40464046
* arguments. The *data* are a **u64** array and corresponding format string
40474047
* values are stored in the array. For strings and pointers where pointees
40484048
* are accessed, only the pointer values are stored in the *data* array.
4049-
* The *data_len* is the size of *data* in bytes.
4049+
* The *data_len* is the size of *data* in bytes - must be a multiple of 8.
40504050
*
40514051
* Formats **%s**, **%p{i,I}{4,6}** requires to read kernel memory.
40524052
* Reading kernel memory may fail due to either invalid address or
@@ -4751,7 +4751,8 @@ union bpf_attr {
47514751
* Each format specifier in **fmt** corresponds to one u64 element
47524752
* in the **data** array. For strings and pointers where pointees
47534753
* are accessed, only the pointer values are stored in the *data*
4754-
* array. The *data_len* is the size of *data* in bytes.
4754+
* array. The *data_len* is the size of *data* in bytes - must be
4755+
* a multiple of 8.
47554756
*
47564757
* Formats **%s** and **%p{i,I}{4,6}** require to read kernel
47574758
* memory. Reading kernel memory may fail due to either invalid

0 commit comments

Comments
 (0)