Skip to contentSkip to conversation

proc: test lseek on /proc/net/dev

PATCH Applied Alexey Dobriyan 2 participants 3 messages Aug 19, 2025 – Aug 23, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 proc: test lseek on /proc/net/dev

From 0991340050b201c6fcbe623b9869ef3a96c133c9 Mon Sep 17 00:00:00 2001
From: Alexey Dobriyan <[email protected]>
Date: Tue, 19 Aug 2025 21:19:17 +0300
Subject: [PATCH 1/1] proc: test lseek on /proc/net/dev

This line in tools/testing/selftests/proc/read.c was added to catch oopses, not to verify lseek correctness:

        (void)lseek(fd, 0, SEEK_SET);

Oh, well. Prevent more embarassement with simple test.

---
 tools/testing/selftests/proc/.gitignore       |  1 +
 tools/testing/selftests/proc/Makefile         |  1 +
 .../selftests/proc/proc-net-dev-lseek.c       | 68 +++++++++++++++++++
 3 files changed, 70 insertions(+)
 create mode 100644 tools/testing/selftests/proc/proc-net-dev-lseek.c
tools/testing/selftests/proc/.gitignore +1 -0
index 19bb333e2485..243f4537a670 100644
@@ -7,6 +7,7 @@
 /proc-loadavg-001
 /proc-maps-race
 /proc-multiple-procfs
+/proc-net-dev-lseek
 /proc-empty-vm
 /proc-pid-vm
 /proc-self-map-files-001
tools/testing/selftests/proc/Makefile +1 -0
index 50aba102201a..2a9547630115 100644
@@ -10,6 +10,7 @@ TEST_GEN_PROGS += fd-003-kthread
 TEST_GEN_PROGS += proc-2-is-kthread
 TEST_GEN_PROGS += proc-loadavg-001
 TEST_GEN_PROGS += proc-maps-race
+TEST_GEN_PROGS += proc-net-dev-lseek
 TEST_GEN_PROGS += proc-empty-vm
 TEST_GEN_PROGS += proc-pid-vm
 TEST_GEN_PROGS += proc-self-map-files-001
tools/testing/selftests/proc/proc-net-dev-lseek.c new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
2.49.1
#1 lore raw
Quoted 4 lines · On Tue, 19 Aug 2025 21:29:16 +0300 Alexey Dobriyan <[email protected]> wrote:

This line in tools/testing/selftests/proc/read.c was added to catch oopses, not to verify lseek correctness:

        (void)lseek(fd, 0, SEEK_SET);

Can you expand on this? Was some issue discovered with /proc/net/dev? If so, what was it?

Quoted 1 line

Oh, well. Prevent more embarassement with simple test.

#2 lore raw
Quoted 9 lines · Andrew Morton
Quoted 4 lines · On Tue, 19 Aug 2025 21:29:16 +0300 Alexey Dobriyan <[email protected]> wrote:

This line in tools/testing/selftests/proc/read.c was added to catch oopses, not to verify lseek correctness:

        (void)lseek(fd, 0, SEEK_SET);

Can you expand on this? Was some issue discovered with /proc/net/dev? If so, what was it?

Retroactively it would prevented the bug:

	assert(lseek(fd, 0, SEEK_SET) == 0);

But I didn't want to compile the list of exceptions and maintain it.

Quoted 1 line
Quoted 1 line

Oh, well. Prevent more embarassement with simple test.