[LTP] [PATCH v3] read_all :catch alignment faults while reading sys entries seen in commit :1bbc21785b7336619fb6a67f1fff5afdaf229acc

Cyril Hrubis chrubis@suse.cz
Fri Apr 19 15:39:22 CEST 2024


Hi!
> ---
>  testcases/kernel/fs/read_all/read_all.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c
> index ddc48edd8..e87f47979 100644
> --- a/testcases/kernel/fs/read_all/read_all.c
> +++ b/testcases/kernel/fs/read_all/read_all.c
> @@ -251,17 +251,11 @@ static void read_test(const int worker, const char *const path)
>  	worker_heartbeat(worker);
>  	/*
>  	 * This could catch any alignment faults while reading sys entries
> -	 * seen in commit :1bbc21785b7336619fb6a67f1fff5afdaf229acc so reading 1024 bytes
> -	 * in chunks of 8 bytes 128 times
> +	 * seen in commit :1bbc21785b7336619fb6a67f1fff5afdaf229acc

The commit id should go into tags.

>  	 */
>  	char check_buf[7];
> -	unsigned int i;
>  
> -	for (i = 0; i < 128; i++) {
> -		count = read(fd, check_buf, sizeof(check_buf));
> -		if (count == 0 || count < 0)
> -			break;
> -	}
> +	count = pread(fd, check_buf, sizeof(check_buf), 1);
>  
>  	count = pread(fd, buf, sizeof(buf) - 1, 0);
>  	elapsed = worker_elapsed(worker);

This is a patch on a top of a patch that does not apply...


What about this change? That should enough to trigger the problem:

diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c
index 266678ea7..86fc6fb61 100644
--- a/testcases/kernel/fs/read_all/read_all.c
+++ b/testcases/kernel/fs/read_all/read_all.c
@@ -228,6 +228,7 @@ static int worker_ttl(const int worker)
 static void read_test(const int worker, const char *const path)
 {
        char buf[BUFFER_SIZE];
+       char odd_buff[7];
        int fd;
        ssize_t count;
        const pid_t pid = workers[worker].pid;
@@ -250,6 +251,8 @@ static void read_test(const int worker, const char *const path)
 
        worker_heartbeat(worker);
        count = read(fd, buf, sizeof(buf) - 1);
+       /* read at odd offset triggers bug fixed by 1bbc21785b73 */
+       pread(fd, odd_buf, sizeof(odd_buf), 1);
        elapsed = worker_elapsed(worker);
 
        if (count > 0 && verbose) {
@@ -714,4 +717,8 @@ static struct tst_test test = {
        .test_all = run,
        .forks_child = 1,
        .max_runtime = 100,
+       .tags = (const struct tst_tag[]) {
+               {"linux-git", "1bbc21785b73"},
+               {}
+       }
 };


-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list