Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftest: af_unix: Add test case for backtrack after finalising SCC.

syzkaller reported a KMSAN splat in __unix_walk_scc() while backtracking
edge_stack after finalising SCC.

Let's add a test case exercising the path.

Signed-off-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Signed-off-by: Shigeru Yoshida <syoshida@redhat.com>
Link: https://patch.msgid.link/20240702160428.10153-2-syoshida@redhat.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Kuniyuki Iwashima and committed by
Jakub Kicinski
2a79651b 927fa5b3

+23 -2
+23 -2
tools/testing/selftests/net/af_unix/scm_rights.c
··· 14 14 15 15 FIXTURE(scm_rights) 16 16 { 17 - int fd[16]; 17 + int fd[32]; 18 18 }; 19 19 20 20 FIXTURE_VARIANT(scm_rights) 21 21 { 22 - char name[16]; 22 + char name[32]; 23 23 int type; 24 24 int flags; 25 25 bool test_listener; ··· 172 172 const FIXTURE_VARIANT(scm_rights) *variant, 173 173 int n) 174 174 { 175 + ASSERT_LE(n * 2, sizeof(self->fd) / sizeof(self->fd[0])); 176 + 175 177 if (variant->test_listener) 176 178 create_listeners(_metadata, self, n); 177 179 else ··· 283 281 send_fd(7, 6); 284 282 285 283 close_sockets(8); 284 + } 285 + 286 + TEST_F(scm_rights, backtrack_from_scc) 287 + { 288 + create_sockets(10); 289 + 290 + send_fd(0, 1); 291 + send_fd(0, 4); 292 + send_fd(1, 2); 293 + send_fd(2, 3); 294 + send_fd(3, 1); 295 + 296 + send_fd(5, 6); 297 + send_fd(5, 9); 298 + send_fd(6, 7); 299 + send_fd(7, 8); 300 + send_fd(8, 6); 301 + 302 + close_sockets(10); 286 303 } 287 304 288 305 TEST_HARNESS_MAIN