Skip to contentSkip to conversation

nfsdcld: don't send null client ids to the kernel

PATCH In review Scott Mayhew 2 participants 2 messages Sep 5, 2024 – Sep 20, 2024

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

PATCH 1/1 nfsdcld: don't send null client ids to the kernel

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/[email protected]/

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.

---
 utils/nfsdcld/sqlite.c | 5 +++++
 1 file changed, 5 insertions(+)
utils/nfsdcld/sqlite.c +5 -0
index 03016fb9..88636848 100644
@@ -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
Signature · 1 line
2.46.0
#1 lore raw
Quoted 10 lines · Scott Mayhew

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/[email protected]/

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.

Committed... (tag: nfs-utils-2-7-2-rc1

steved

Quoted 20 lines
---
  utils/nfsdcld/sqlite.c | 5 +++++
  1 file changed, 5 insertions(+)
utils/nfsdcld/sqlite.c +5 -0
index 03016fb9..88636848 100644
@@ -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