Linux NFS development
 help / color / mirror / Atom feed
* [PATCH] nfsd: fix memory corruption due to uninitialized variable
@ 2015-01-18 12:29 Junxiao Bi
  2015-01-18 14:43 ` Trond Myklebust
  0 siblings, 1 reply; 9+ messages in thread
From: Junxiao Bi @ 2015-01-18 12:29 UTC (permalink / raw)
  To: linux-nfs; +Cc: bfields

nfsd4_decode_open() doesn't initialize variable open->op_file and
open->op_stp, they are initialized in nfsd4_process_open1(), but if
any error happens before initializing them, nfsd4_open() will call
into nfsd4_cleanup_open_state() and corrupt the memory.

Since nfsd4_process_open1() will initialize these two variables and
open->op_openowner, make them default to null at the beginning.

Signed-off-by: Junxiao Bi <junxiao.bi@oracle.com>
---
 fs/nfsd/nfs4state.c |    4 ++++
 1 file changed, 4 insertions(+)

diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
index c06a1ba..6e74a91 100644
--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3547,6 +3547,10 @@ nfsd4_process_open1(struct nfsd4_compound_state *cstate,
 	struct nfs4_openowner *oo = NULL;
 	__be32 status;
 
+	open->op_file = NULL;
+	open->op_openowner = NULL;
+	open->op_stp = NULL;
+
 	if (STALE_CLIENTID(&open->op_clientid, nn))
 		return nfserr_stale_clientid;
 	/*
-- 
1.7.9.5


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

end of thread, other threads:[~2015-01-21  1:32 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-18 12:29 [PATCH] nfsd: fix memory corruption due to uninitialized variable Junxiao Bi
2015-01-18 14:43 ` Trond Myklebust
2015-01-19  1:17   ` Junxiao Bi
2015-01-19 14:29     ` Jeff Layton
2015-01-20 11:49       ` Junxiao Bi
2015-01-20 12:23         ` Jeff Layton
2015-01-20 12:26           ` Junxiao Bi
2015-01-20 14:36             ` Bruce Fields
2015-01-21  1:30               ` Junxiao Bi

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