diff options
| author | Gustavo A. R. Silva <[email protected]> | 2024-03-25 19:34:01 -0600 |
|---|---|---|
| committer | Christian Brauner <[email protected]> | 2024-04-05 15:53:47 +0200 |
| commit | 68d6f4f3fbd9b1baae53e7cf33fb3362b5a21494 (patch) | |
| tree | c04a435f7313dc10206cab7d7a65f94528828ff1 /include/linux | |
| parent | 61db088eeb996225bd5b88ba2f6518f865958bd9 (diff) | |
fs: Annotate struct file_handle with __counted_by() and use struct_size()
Prepare for the coming implementation by GCC and Clang of the __counted_by
attribute. Flexible array members annotated with __counted_by can have
their accesses bounds-checked at run-time via CONFIG_UBSAN_BOUNDS (for
array indexing) and CONFIG_FORTIFY_SOURCE (for strcpy/memcpy-family
functions).
While there, use struct_size() helper, instead of the open-coded
version.
[[email protected]: contains a fix by Edward for an OOB access]
Reported-by: [email protected]
Signed-off-by: Edward Adam Davis <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Gustavo A. R. Silva <[email protected]>
Link: https://lore.kernel.org/r/ZgImCXTdGDTeBvSS@neat
Reviewed-by: Jan Kara <[email protected]>
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'include/linux')
| -rw-r--r-- | include/linux/fs.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/linux/fs.h b/include/linux/fs.h index 00fc429b0af0..914245085597 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1033,7 +1033,7 @@ struct file_handle { __u32 handle_bytes; int handle_type; /* file identifier */ - unsigned char f_handle[]; + unsigned char f_handle[] __counted_by(handle_bytes); }; static inline struct file *get_file(struct file *f) |