diff mbox series

[net-next,v3,4/7] vsock/test: Adapt send_byte()/recv_byte() to handle MSG_ZEROCOPY

Message ID 20241218-test-vsock-leaks-v3-4-f1a4dcef9228@rbox.co (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series vsock/test: Tests for memory leaks | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next, async
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/build_tools success Errors and warnings before: 0 (+23) this patch: 0 (+23)
netdev/cc_maintainers warning 1 maintainers not CCed: virtualization@lists.linux.dev
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-12-19--00-00 (tests: 880)

Commit Message

Michal Luczaj Dec. 18, 2024, 2:32 p.m. UTC
For a zercopy send(), buffer (always byte 'A') needs to be preserved (thus
it can not be on the stack) or the data recv()ed check in recv_byte() might
fail.

While there, change the printf format to 0x%02x so the '\0' bytes can be
seen.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 tools/testing/vsock/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Stefano Garzarella Dec. 18, 2024, 5:55 p.m. UTC | #1
On Wed, Dec 18, 2024 at 03:32:37PM +0100, Michal Luczaj wrote:
>For a zercopy send(), buffer (always byte 'A') needs to be preserved (thus
>it can not be on the stack) or the data recv()ed check in recv_byte() might
>fail.
>
>While there, change the printf format to 0x%02x so the '\0' bytes can be
>seen.
>
>Signed-off-by: Michal Luczaj <mhal@rbox.co>
>---
> tools/testing/vsock/util.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)

Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>

>
>diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
>index 81b9a31059d8173a47ea87324da50e7aedd7308a..7058dc614c25f546fc3219d6b9ade2dcef21a9bd 100644
>--- a/tools/testing/vsock/util.c
>+++ b/tools/testing/vsock/util.c
>@@ -401,7 +401,7 @@ void recv_buf(int fd, void *buf, size_t len, int flags, ssize_t expected_ret)
>  */
> void send_byte(int fd, int expected_ret, int flags)
> {
>-	const uint8_t byte = 'A';
>+	static const uint8_t byte = 'A';
>
> 	send_buf(fd, &byte, sizeof(byte), flags, expected_ret);
> }
>@@ -420,7 +420,7 @@ void recv_byte(int fd, int expected_ret, int flags)
> 	recv_buf(fd, &byte, sizeof(byte), flags, expected_ret);
>
> 	if (byte != 'A') {
>-		fprintf(stderr, "unexpected byte read %c\n", byte);
>+		fprintf(stderr, "unexpected byte read 0x%02x\n", byte);
> 		exit(EXIT_FAILURE);
> 	}
> }
>
>-- 
>2.47.1
>
Michal Luczaj Dec. 19, 2024, 9:19 a.m. UTC | #2
On 12/18/24 15:32, Michal Luczaj wrote:
> For a zercopy send(), buffer (always byte 'A') needs to be preserved (thus
        ^^^^^^^

And this is how I've learnt how checkpatch's spellcheck works.
Should I resend with this typo fixed?

My bad, sorry,
Michal
Stefano Garzarella Dec. 19, 2024, 9:29 a.m. UTC | #3
On Thu, Dec 19, 2024 at 10:19:56AM +0100, Michal Luczaj wrote:
>On 12/18/24 15:32, Michal Luczaj wrote:
>> For a zercopy send(), buffer (always byte 'A') needs to be preserved (thus
>        ^^^^^^^
>
>And this is how I've learnt how checkpatch's spellcheck works.
>Should I resend with this typo fixed?

I think it depends more on you than on me :-)

If you want to send a v4, I don't think there's any problem, just bring 
all my R-b's with them, so the net maintainers will merge it directly.

FYI I will be off from tomorrow afternoon until and including Jan. 6.

Thanks,
Stefano
Michal Luczaj Dec. 19, 2024, 9:52 a.m. UTC | #4
On 12/19/24 10:29, Stefano Garzarella wrote:
> On Thu, Dec 19, 2024 at 10:19:56AM +0100, Michal Luczaj wrote:
>> On 12/18/24 15:32, Michal Luczaj wrote:
>>> For a zercopy send(), buffer (always byte 'A') needs to be preserved (thus
>>        ^^^^^^^
>>
>> And this is how I've learnt how checkpatch's spellcheck works.
>> Should I resend with this typo fixed?
> 
> I think it depends more on you than on me :-)
> 
> If you want to send a v4, I don't think there's any problem, just bring 
> all my R-b's with them, so the net maintainers will merge it directly. [...]

OK then; here it is:
https://lore.kernel.org/netdev/20241219-test-vsock-leaks-v4-0-a416e554d9d7@rbox.co/

Thanks,
Michal
diff mbox series

Patch

diff --git a/tools/testing/vsock/util.c b/tools/testing/vsock/util.c
index 81b9a31059d8173a47ea87324da50e7aedd7308a..7058dc614c25f546fc3219d6b9ade2dcef21a9bd 100644
--- a/tools/testing/vsock/util.c
+++ b/tools/testing/vsock/util.c
@@ -401,7 +401,7 @@  void recv_buf(int fd, void *buf, size_t len, int flags, ssize_t expected_ret)
  */
 void send_byte(int fd, int expected_ret, int flags)
 {
-	const uint8_t byte = 'A';
+	static const uint8_t byte = 'A';
 
 	send_buf(fd, &byte, sizeof(byte), flags, expected_ret);
 }
@@ -420,7 +420,7 @@  void recv_byte(int fd, int expected_ret, int flags)
 	recv_buf(fd, &byte, sizeof(byte), flags, expected_ret);
 
 	if (byte != 'A') {
-		fprintf(stderr, "unexpected byte read %c\n", byte);
+		fprintf(stderr, "unexpected byte read 0x%02x\n", byte);
 		exit(EXIT_FAILURE);
 	}
 }