diff mbox series

[nfs-utils] nfsdcld: don't send null client ids to the kernel

Message ID 20240905193623.408531-1-smayhew@redhat.com (mailing list archive)
State New
Headers show
Series [nfs-utils] nfsdcld: don't send null client ids to the kernel | expand

Commit Message

Scott Mayhew Sept. 5, 2024, 7:36 p.m. UTC
It's apparently possible for the sqlite database to get corrupted and
cause one or more rows to have null in the id column.

The knfsd fix was posted here:
https://lore.kernel.org/linux-nfs/20240903111446.659884-1-lilingfeng3@huawei.com/

nfsdcld should have a similar fix.  If we encounter a client record with
a null id, just skip it instead of sending it to the kernel.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 utils/nfsdcld/sqlite.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/utils/nfsdcld/sqlite.c b/utils/nfsdcld/sqlite.c
index 03016fb9..88636848 100644
--- a/utils/nfsdcld/sqlite.c
+++ b/utils/nfsdcld/sqlite.c
@@ -1337,6 +1337,11 @@  sqlite_iterate_recovery(int (*cb)(struct cld_client *clnt), struct cld_client *c
 		id_len = sqlite3_column_bytes(stmt, 0);
 		if (id_len > NFS4_OPAQUE_LIMIT)
 			id_len = NFS4_OPAQUE_LIMIT;
+		if (id_len == 0) {
+			xlog(L_ERROR, "%s: Skipping client record with null id",
+				__func__);
+			continue;
+		}
 
 		memset(&cmsg->cm_u, 0, sizeof(cmsg->cm_u));
 #if UPCALL_VERSION >= 2