diff options
author | Wen Yang <[email protected]> | 2024-02-07 00:35:18 +0800 |
---|---|---|
committer | Christian Brauner <[email protected]> | 2024-02-08 10:12:26 +0100 |
commit | d31563b5f9bb601a805c4a1b491edf69ada79688 (patch) | |
tree | a217095efc9b412390ebc743d88783d6315d0038 /tools/perf/scripts/python/export-to-postgresql.py | |
parent | 11b3f8ae7081607a783d60e8098d46b787f79cad (diff) |
eventfd: strictly check the count parameter of eventfd_write to avoid inputting illegal strings
Since eventfd's document has clearly stated: A write(2) call adds
the 8-byte integer value supplied in its buffer to the counter.
However, in the current implementation, the following code snippet
did not cause an error:
char str[16] = "hello world";
uint64_t value;
ssize_t size;
int fd;
fd = eventfd(0, 0);
size = write(fd, &str, strlen(str));
printf("eventfd: test writing a string, size=%ld\n", size);
size = read(fd, &value, sizeof(value));
printf("eventfd: test reading as uint64, size=%ld, valus=0x%lX\n",
size, value);
close(fd);
And its output is:
eventfd: test writing a string, size=8
eventfd: test reading as uint64, size=8, valus=0x6F77206F6C6C6568
By checking whether count is equal to sizeof(ucnt), such errors
could be detected. It also follows the requirements of the manual.
Signed-off-by: Wen Yang <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Cc: Alexander Viro <[email protected]>
Cc: Jens Axboe <[email protected]>
Cc: Christian Brauner <[email protected]>
Cc: Jan Kara <[email protected]>
Cc: David Woodhouse <[email protected]>
Cc: Matthew Wilcox <[email protected]>
Cc: Eric Biggers <[email protected]>
Cc: [email protected]
Cc: [email protected]
Signed-off-by: Christian Brauner <[email protected]>
Diffstat (limited to 'tools/perf/scripts/python/export-to-postgresql.py')
0 files changed, 0 insertions, 0 deletions