[Devel] [PATCH v2] fuse kio: Replenish netaddr_cmp() with unix sockets type

Kirill Tkhai ktkhai at virtuozzo.com
Mon Oct 15 11:41:24 MSK 2018


We met crash in unix socket comparison:

[21519.571700] kernel BUG at fs/fuse/kio/pcs/pcs_cs.c:170!
[21519.592534] RIP: 0010:[<ffffffffc080d4b0>]  [<ffffffffc080d4b0>] pcs_cs_find_create+0x300/0x310 [fuse_kio_pcs]
[21519.593817] RSP: 0018:ffff8af1f86f3d18  EFLAGS: 00010293
[21519.595102] RAX: 0000000000000000 RBX: ffff8af1d5369680 RCX: 0000000000000000
[21519.596429] RDX: 0000000000000001 RSI: ffff8af1d5369668 RDI: ffff8af234463820
[21519.597763] RBP: ffff8af1f86f3d58 R08: 0000000000000000 R09: 0000000000000000
[21519.599115] R10: ffff8af33fc07340 R11: 0000000000000001 R12: ffff8af1d5369668
[21519.600467] R13: ffff8af9e8758080 R14: ffff8af1d53696c0 R15: ffff8af234463800
[21519.602085] FS:  0000000000000000(0000) GS:ffff8afa1fac0000(0000) knlGS:0000000000000000
[21519.603509] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[21519.604918] CR2: 000000c4201db000 CR3: 000000104e744000 CR4: 00000000003607e0
[21519.606371] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[21519.607805] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[21519.609604] Call Trace:
[21519.611106]  [<ffffffffc0806b50>] cslist_alloc+0x1f0/0x400 [fuse_kio_pcs]
[21519.612567]  [<ffffffffc08070ef>] pcs_map_complete+0x38f/0x420 [fuse_kio_pcs]
[21519.614001]  [<ffffffffc07fca59>] fuse_complete_map_work+0x79/0xc0 [fuse_kio_pcs]
[21519.615388]  [<ffffffff96cb7532>] process_one_work+0x182/0x440
[21519.616772]  [<ffffffff96cb86e6>] worker_thread+0x126/0x3c0
[21519.618270]  [<ffffffff96cb85c0>] ? manage_workers.isra.24+0x2a0/0x2a0
[21519.619703]  [<ffffffff96cbf681>] kthread+0xd1/0xe0
[21519.621134]  [<ffffffff96cbf5b0>] ? create_kthread+0x60/0x60
[21519.622507]  [<ffffffff97354677>] ret_from_fork_nospec_begin+0x21/0x21
[21519.623845]  [<ffffffff96cbf5b0>] ? create_kthread+0x60/0x60

Extend netaddr_cmp() with PCS_ADDRTYPE_UNIX to make function
not to wonder unknown socket type. Note, unix sockets do not
care about address, since all of them are on local machine,
there is only port has a sense.

https://pmc.acronis.com/browse/VSTOR-16083

v2: Also teach the function about RDMA address length

Signed-off-by: Kirill Tkhai <ktkhai at virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_cs.c    |    6 +++++-
 fs/fuse/kio/pcs/pcs_types.h |    1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 56ab3adb36db..5842626c85f9 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -161,11 +161,14 @@ static inline int netaddr_cmp(PCS_NET_ADDR_T const *addr1, PCS_NET_ADDR_T const
 
 	switch (addr1->type) {
 	case PCS_ADDRTYPE_IP:
+	case PCS_ADDRTYPE_RDMA:
 		sz = sizeof(struct in_addr);
 		break;
 	case PCS_ADDRTYPE_IP6:
 		sz = sizeof(struct in6_addr);
 		break;
+	case PCS_ADDRTYPE_UNIX:
+		return 0;
 	default:
 		BUG();
 	}
@@ -173,7 +176,8 @@ static inline int netaddr_cmp(PCS_NET_ADDR_T const *addr1, PCS_NET_ADDR_T const
 	return memcmp(addr1->address, addr2->address, sz);
 }
 
-int pcs_netaddr_cmp(PCS_NET_ADDR_T const *addr1, PCS_NET_ADDR_T const *addr2)
+static int pcs_netaddr_cmp(PCS_NET_ADDR_T const *addr1,
+			   PCS_NET_ADDR_T const *addr2)
 {
 	return netaddr_cmp(addr1, addr2, 0);
 }
diff --git a/fs/fuse/kio/pcs/pcs_types.h b/fs/fuse/kio/pcs/pcs_types.h
index f5c886e49619..1170475c2226 100644
--- a/fs/fuse/kio/pcs/pcs_types.h
+++ b/fs/fuse/kio/pcs/pcs_types.h
@@ -26,6 +26,7 @@ enum
 	PCS_ADDRTYPE_IP = 1,
 	PCS_ADDRTYPE_IP6 = 2,
 	PCS_ADDRTYPE_UNIX = 3,
+	PCS_ADDRTYPE_RDMA = 4,
 };
 
 /* alignment makes it usable in binary protocols */



More information about the Devel mailing list