Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] pNFS: fix uninitialized pointer access
@ 2025-07-16 14:38 Antonio Quartulli
  2025-07-17  0:27 ` Sergey Bashirov
  0 siblings, 1 reply; 6+ messages in thread
From: Antonio Quartulli @ 2025-07-16 14:38 UTC (permalink / raw)
  To: linux-nfs
  Cc: Antonio Quartulli, Trond Myklebust, Anna Schumaker,
	Sergey Bashirov, Konstantin Evtushenko, linux-kernel

In ext_tree_encode_commit() if no block extent is encoded due to lack
of buffer space, ret is set to -ENOSPC and we end up accessing be_prev
despite it being uninitialized.

Fix this behaviour by bailing out right away when no extent is encoded.

Fixes: d84c4754f874 ("pNFS: Fix extent encoding in block/scsi layout")
Addresses-Coverity-ID: 1647611 ("Memory - illegal accesses  (UNINIT)")
Signed-off-by: Antonio Quartulli <antonio@mandelbit.com>
---
 fs/nfs/blocklayout/extent_tree.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/nfs/blocklayout/extent_tree.c b/fs/nfs/blocklayout/extent_tree.c
index 315949a7e92d..82e19205f425 100644
--- a/fs/nfs/blocklayout/extent_tree.c
+++ b/fs/nfs/blocklayout/extent_tree.c
@@ -598,6 +598,11 @@ ext_tree_encode_commit(struct pnfs_block_layout *bl, __be32 *p,
 		if (ext_tree_layoutupdate_size(bl, *count) > buffer_size) {
 			(*count)--;
 			ret = -ENOSPC;
+			/* bail out right away if no extent was encoded */
+			if (!*count) {
+				spin_unlock(&bl->bl_ext_lock);
+				return ret;
+			}
 			break;
 		}
 
-- 
2.49.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-17 14:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-16 14:38 [PATCH] pNFS: fix uninitialized pointer access Antonio Quartulli
2025-07-17  0:27 ` Sergey Bashirov
2025-07-17  4:56   ` Dan Carpenter
2025-07-17  8:01     ` Antonio Quartulli
2025-07-17  8:50       ` Sergey Bashirov
2025-07-17 14:02       ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox