[LTP] [PATCH v3] read_all: Fix buffer too small for long paths

Cyril Hrubis chrubis@suse.cz
Tue Sep 15 14:57:27 CEST 2026


Hi!
> diff --git a/testcases/kernel/fs/read_all/read_all.c b/testcases/kernel/fs/read_all/read_all.c
> index 5720ffb99..ec9454fc9 100644
> --- a/testcases/kernel/fs/read_all/read_all.c
> +++ b/testcases/kernel/fs/read_all/read_all.c
> @@ -51,8 +51,8 @@
>  #include "tst_timer.h"
>  
>  #define QUEUE_SIZE 16384
> -#define BUFFER_SIZE 1024
> -#define MAX_PATH 4096
> +#define BUFFER_SIZE PATH_MAX
> +#define MAX_PATH PATH_MAX
>  #define MAX_DISPLAY 40

This part looks good.

>  struct queue {
> @@ -131,7 +131,7 @@ static int queue_pop(struct queue *q)
>  	while (q->data[i]) {
>  		q->popped[j] = q->data[i];
>  
> -		if (++j >= BUFFER_SIZE - 1)
> +		if (++j >= BUFFER_SIZE)
>  			tst_brk(TBROK, "Buffer is too small for path");
>  
>  		 i = (i + 1) % QUEUE_SIZE;

However here we do:

q->popped[j] = '\0';

So j must be at most BUFFER_SIZE-1 and with the change above j may end
up equal to BUFFER_SIZE and we will land off by one in the array.

-- 
Cyril Hrubis
chrubis@suse.cz


More information about the ltp mailing list