[LTP] [PATCH v2] Add test for possible writev() issues with NULL buffer in iovec

Petr Vorel pvorel@suse.cz
Tue Feb 23 12:46:09 CET 2021


Hi Martin,

> Fixes #790

> Signed-off-by: Martin Doucha <mdoucha@suse.cz>
> ---

> This test triggers temporary write of invalid data into test file on some
> file systems on kernel 4.4.21 and older.

> Changes since v1:
> - Simplify main thread
> - Use atomic load/store when passing read limit between threads (I hope I'm
>   doing it correctly)
> - Check for too big writes just in case
> - Require at least 2 CPUs, the bugs are not reproducible on single-CPU systems

Reviewed-by: Petr Vorel <pvorel@suse.cz>

It takes some time to run due .all_filesystems, but I guess there is a reason to
test it on all available fs.

...
> diff --git a/testcases/kernel/syscalls/writev/writev03.c b/testcases/kernel/syscalls/writev/writev03.c
> new file mode 100644
> index 000000000..58d6931d2
> --- /dev/null
> +++ b/testcases/kernel/syscalls/writev/writev03.c
> @@ -0,0 +1,145 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Copyright (C) 2021 SUSE LLC <mdoucha@suse.cz>
> + *
> + * Check for potential issues in writev() if the first iovec entry is NULL
> + * and the next one is not present in RAM. This can result in a brief window
> + * where writev() first writes uninitialized data into the file (possibly
> + * exposing internal kernel structures) and then overwrites it with the real
> + * iovec contents later. Bugs fixed in:
Maybe this doc part should be in * [DESCRIPTION] to get into docparse.

The rest LGTM.

Kind regards,
Petr


More information about the ltp mailing list