ioctl_loop06: no validate block size
PATCH 1/1 ioctl_loop06: no validate block size
Since commit 9423c653fe6110 ("loop: Don't bother validating blocksize") kernel drop validating blocksize for both loop_configure and loop_set_block_size so that set large block size succeeds.
Error log:
12 ioctl_loop06.c:76: TINFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE 13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: Using LOOP_CONFIGURE with block_size > PAGE_SIZE 19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +9 -0
@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;
@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); +if ((*(tc->setvalue) == invalid_value) && novalidate_blocksize) { +tst_res (TCONF ,"Kernel doesn't validate block size, skip invalid value test" ); +return ; + } +if (tc->ioctl_flag ==LOOP_SET_BLOCK_SIZE ) {if (!attach_flag) {tst_attach_device (dev_path,"test.img" );
@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void )
Signature · 5 lines
2.46.0 -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 2 lines · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validating blocksize") kernel
This commit above says "The block queue limits validation does this for us now.",
shouldn't that still catch the errors?
Quoted 52 lines
drop validating blocksize for both
loop_configureandloop_set_block_sizeso that set large block size succeeds.Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZE13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZE19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedlySigned-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/syscalls/ioctl/ioctl_loop06.c +9
-1@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); +if ((*(tc->setvalue) == invalid_value) && novalidate_blocksize) { +tst_res (TCONF ,"Kernel doesn't validate block size, skip invalid value test" ); +return ; + } +if (tc->ioctl_flag ==LOOP_SET_BLOCK_SIZE ) {if (!attach_flag) {tst_attach_device (dev_path,"test.img" );@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
Signature · 1 line
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 9 lines · Jan Stancek
Quoted 2 lines · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validating blocksize")kernel
This commit above says "The block queue limits validation does this for us now.",
shouldn't that still catch the errors?
Yes, I overlooked that before, after removing the blk_validate_block_size() from
kernel side, test ioctl_loop06 always failed on ppc64le/aarch64. Weirdly, x86_64 and s390x work well. I guess it's probably a kernel new bug.
Quoted 60 lines
Quoted 1 line
drop validating blocksize for both
loop_configureand
loop_set_block_sizesoQuoted 4 lines
that set large block size succeeds.
Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >
PAGE_SIZEQuoted 3 lines
13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>
PAGE_SIZEReview
Quoted 8 lines
19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)(quoted diff) +0
-0
b/testcases/kernel/syscalls/ioctl/ioctl_loop06.ctestcases/kernel/syscalls/ioctl/ioctl_loop06.c static char dev_path[1024]; · line 23
Quoted 5 lines
index
317f693a0..4aacd284a100644testcases/kernel/syscalls/ioctl/ioctl_loop06.c +0
-0@@ -23,6 +23,7 @@ static char dev_path[1024]; static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1;
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static void run(unsigned int n) · line 79
Quoted 12 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +3
-0static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); +if ((*(tc->setvalue) == invalid_value) && novalidate_blocksize) { + tst_res(TCONF, "Kernel doesn't validate block size, skipinvalid value test");
Quoted 19 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +6
-1+return ; + } +if (tc->ioctl_flag ==LOOP_SET_BLOCK_SIZE ) {if (!attach_flag) {tst_attach_device (dev_path,"test.img" );@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Hi All,
Quoted 6 lines · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validating blocksize") kernel
drop validating blocksize for bothloop_configureandloop_set_block_sizeso
that set large block size succeeds.
Quoted 9 lines
Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZE
13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZE
19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
Hmm, maybe I was wrong here, the commit says
"The block queue limits validation does this for us now."
which indicates the validation is still on.
So the test failure probably means a kernel bug but not a test problem.
CC block devs to give some advice.
Quoted 50 lines
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/syscalls/ioctl/ioctl_loop06.c +6
-0@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); +if ((*(tc->setvalue) == invalid_value) && novalidate_blocksize) { + tst_res(TCONF, "Kernel doesn't validate block size, skip invalid value test"); + return; + } + if (tc->ioctl_flag == LOOP_SET_BLOCK_SIZE) { if (!attach_flag) {tst_attach_device(dev_path, "test.img");testcases/kernel/syscalls/ioctl/ioctl_loop06.c +3
-1@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 21 lines · Li Wang
Hi All,
Quoted 6 lines · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validating blocksize") kernel
drop validating blocksize for bothloop_configureandloop_set_block_sizeso
that set large block size succeeds.Quoted 9 lines
Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZE
13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZE
19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
Quoted 7 lines
Hmm, maybe I was wrong here, the commit says
"The block queue limits validation does this for us now."
which indicates the validation is still on.
So the test failure probably means a kernel bug but not a test problem.
Before the patch, blk_validate_block_size() did validate original value as unsigned long,
after patch it's validated after cast to unsigned short.
In LTP thread you mentioned it failed on ppc64le/aarch64 and worked on x86_64 and s390x.
Is it by chance now failing only on kernels with 64k page size? (Test attempts to set block size to 2*page size.)
Quoted 62 lines
CC block devs to give some advice.
Quoted 46 lines
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)testcases/kernel/syscalls/ioctl/ioctl_loop06.c +6
-0@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup =1 ;static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); +if ((*(tc->setvalue) == invalid_value) && novalidate_blocksize) { + tst_res(TCONF, "Kernel doesn't validate block size, skip invalid value test"); + return; + } + if (tc->ioctl_flag == LOOP_SET_BLOCK_SIZE) { if (!attach_flag) {tst_attach_device(dev_path, "test.img");testcases/kernel/syscalls/ioctl/ioctl_loop06.c +3
-1@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
Quoted 4 lines
--
Mailing list info: https://lists.linux.it/listinfo/ltp--
Regards,
Li Wang--
Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 31 lines · Jan Stancek
Quoted 8 lines · Li Wang
Hi All,
Quoted 3 lines · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validating blocksize") kernel
drop validating blocksize for bothloop_configureand
loop_set_block_sizeQuoted 13 lines
Quoted 12 lines
so
that set large block size succeeds.Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZE
13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZE
19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedlyQuoted 7 lines
Hmm, maybe I was wrong here, the commit says
"The block queue limits validation does this for us now."
which indicates the validation is still on.
So the test failure probably means a kernel bug but not a test problem.
Quoted 8 lines
Before the patch,
blk_validate_block_size()did validate original value as unsigned long,
after patch it's validated after cast to unsigned short.In LTP thread you mentioned it failed on ppc64le/aarch64 and worked on
x86_64and s390x.
Is it by chance now failing only on kernels with 64k page size?
Right, I checked the automation jobs, all recent (v6.11) aarch64-kernel-64k reports that fail.
Quoted 69 lines
(Test attempts to set block size to 2*page size.)
Quoted 11 lines
CC block devs to give some advice.
Quoted 6 lines
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static char dev_path[1024]; · line 23
Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +0
-0@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup= 1;
Quoted 11 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static void run(unsigned int n) · line 78
Quoted 11 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +2
-0static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];tst_res (TINFO ,"%s" , tc->message); + if ((*(tc->setvalue) == invalid_value) &&
novalidate_blocksize) {Quoted 1 line
Quoted 1 line
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-0+ tst_res(TCONF, "Kernel doesn't validate block size,skip
Quoted 32 lines
Quoted 21 lines
invalid value test");
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +6
-1+return ; + } +if (tc->ioctl_flag ==LOOP_SET_BLOCK_SIZE ) {if (!attach_flag) {tst_attach_device (dev_path,"test.img" );@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
Quoted 4 lines
--
Mailing list info: https://lists.linux.it/listinfo/ltp--
Regards,
Li Wang--
Mailing list info: https://lists.linux.it/listinfo/ltp
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp
Quoted 40 lines · Li Wang
Quoted 36 lines · Jan Stancek
Quoted 6 lines · Li Wang
Hi All,
Quoted 1 line · Li Wang
Since commit
9423c653fe6110("loop: Don't bother validatingblocksize")
Quoted 2 lines
Quoted 2 lines
kernel
drop validating blocksize for bothloop_configureand
loop_set_block_sizeQuoted 13 lines
Quoted 12 lines
so
that set large block size succeeds.Error log:
12 ioctl_loop06.c:76: TINFO: UsingLOOP_SET_BLOCK_SIZEwith arg >PAGE_SIZE
13 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedly
...
18 ioctl_loop06.c:76: TINFO: UsingLOOP_CONFIGUREwithblock_size>PAGE_SIZE
19 ioctl_loop06.c:59: TFAIL: Set block size succeed unexpectedlyQuoted 7 lines
Hmm, maybe I was wrong here, the commit says
"The block queue limits validation does this for us now."
which indicates the validation is still on.
So the test failure probably means a kernel bug but not a test problem.
Before the patch,
blk_validate_block_size()did validate original value as unsigned long,
after patch it's validated after cast to unsigned short.
Quoted 8 lines
Quoted 4 lines
In LTP thread you mentioned it failed on ppc64le/aarch64 and worked on
x86_64and s390x.
Is it by chance now failing only on kernels with 64k page size?Right, I checked the automation jobs, all recent (v6.11) aarch64-kernel-64k reports that fail.
And I verified your inference. Once I lower the invalid_value to 'pg_size + 1'
the test passed on my ppc64le platform.
And looking at the code, seems from loop_reconfigure_limits() cast to 'unsined short'
caused that. That's why another patch John submitted fe3d508ba95bc63a ("block: Validate logical block size in blk_validate_limits()") doesn't make the
behavior consistent on all arches (with different page size).
Quoted 76 lines
Quoted 32 lines
(Test attempts to set block size to 2*page size.)
Quoted 11 lines
CC block devs to give some advice.
Quoted 6 lines
Signed-off-by Li Wang <[email protected]>--- testcases/kernel/syscalls/ioctl/ioctl_loop06.c | 9 +++++++++ 1 file changed, 9 insertions(+)Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static char dev_path[1024]; · line 23
Quoted 7 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +0
-0@@ -23,6 +23,7 @@ static char dev_path[1024];static int dev_num, dev_fd, file_fd, attach_flag, loop_configure_sup= 1;
Quoted 9 lines
Quoted 9 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-0static unsigned int invalid_value, half_value, unalign_value;static struct loop_config loopconfig; +static int novalidate_blocksize =0 ; static struct tcase { unsigned int *setvalue;@@ -74,6 +75,11 @@ static void run(unsigned int n)struct tcase *tc = &tcases[n];Quoted 39 lines
Quoted 2 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c static void run(unsigned int n) · line 78
Quoted 2 lines
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-0tst_res (TINFO ,"%s" , tc->message); + if ((*(tc->setvalue) == invalid_value) &&
novalidate_blocksize) {Quoted 1 line
Quoted 1 line
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +1
-0+ tst_res(TCONF, "Kernel doesn't validate block size,skip
Quoted 32 lines
Quoted 21 lines
invalid value test");
testcases/kernel/syscalls/ioctl/ioctl_loop06.c +6
-1+return ; + } +if (tc->ioctl_flag ==LOOP_SET_BLOCK_SIZE ) {if (!attach_flag) {tst_attach_device (dev_path,"test.img" );@@ -126,6 +132,9 @@ static void setup(void)return ; } loopconfig.fd = file_fd; + +if ((tst_kvercmp (6 ,11 ,0 )) >=0 ) + novalidate_blocksize =1 ; }static void cleanup (void ) --2.46.0
Quoted 4 lines
--
Mailing list info: https://lists.linux.it/listinfo/ltp--
Regards,
Li Wang--
Mailing list info: https://lists.linux.it/listinfo/ltp--
Regards,
Li Wang
Signature · 5 lines
Regards, Li Wang -- Mailing list info: https://lists.linux.it/listinfo/ltp