public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Peng Tao <bergwolf@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, Swapnil Pimpale <spimpale@ddn.com>,
	Peng Tao <bergwolf@gmail.com>,
	Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH 05/26] staging/lustre/dcache: Unsafe error handling arnd ll_splice_alias
Date: Fri, 15 Nov 2013 00:42:52 +0800	[thread overview]
Message-ID: <1384447393-13838-6-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1384447393-13838-1-git-send-email-bergwolf@gmail.com>

From: Swapnil Pimpale <spimpale@ddn.com>

Callers of ll_splice_alias() should not assign the returned pointer to
the dentry since it can be an err pointer. Fixed the above bug using a
temporary dentry pointer. This temporary pointer is assigned to dentry
only if ll_splice_alias has not returned an err pointer.

Lustre-change: http://review.whamcloud.com/7460
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3807
Signed-off-by: Swapnil Pimpale <spimpale@ddn.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
 drivers/staging/lustre/lustre/llite/namei.c     |   21 ++++++++++--------
 drivers/staging/lustre/lustre/llite/statahead.c |   27 +++++++++++++----------
 2 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/drivers/staging/lustre/lustre/llite/namei.c b/drivers/staging/lustre/lustre/llite/namei.c
index c760059..3cfd34d 100644
--- a/drivers/staging/lustre/lustre/llite/namei.c
+++ b/drivers/staging/lustre/lustre/llite/namei.c
@@ -428,12 +428,12 @@ struct dentry *ll_splice_alias(struct inode *inode, struct dentry *de)
 int ll_lookup_it_finish(struct ptlrpc_request *request,
 			struct lookup_intent *it, void *data)
 {
-	struct it_cb_data *icbd = data;
-	struct dentry **de = icbd->icbd_childp;
-	struct inode *parent = icbd->icbd_parent;
-	struct inode *inode = NULL;
-	__u64 bits = 0;
-	int rc;
+	struct it_cb_data	 *icbd = data;
+	struct dentry		**de = icbd->icbd_childp;
+	struct inode		 *parent = icbd->icbd_parent;
+	struct inode		 *inode = NULL;
+	__u64			  bits = 0;
+	int			  rc;
 
 	/* NB 1 request reference will be taken away by ll_intent_lock()
 	 * when I return */
@@ -460,9 +460,12 @@ int ll_lookup_it_finish(struct ptlrpc_request *request,
 	 * Atoimc_open may passin hashed dentries for open.
 	 */
 	if (d_unhashed(*de)) {
-		*de = ll_splice_alias(inode, *de);
-		if (IS_ERR(*de))
-			return PTR_ERR(*de);
+		struct dentry *alias;
+
+		alias = ll_splice_alias(inode, *de);
+		if (IS_ERR(alias))
+			return PTR_ERR(alias);
+		*de = alias;
 	}
 
 	if (!it_disposition(it, DISP_LOOKUP_NEG)) {
diff --git a/drivers/staging/lustre/lustre/llite/statahead.c b/drivers/staging/lustre/lustre/llite/statahead.c
index 183b415..0db4006 100644
--- a/drivers/staging/lustre/lustre/llite/statahead.c
+++ b/drivers/staging/lustre/lustre/llite/statahead.c
@@ -1500,14 +1500,14 @@ ll_sai_unplug(struct ll_statahead_info *sai, struct ll_sa_entry *entry)
 int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
 		       int only_unplug)
 {
-	struct ll_inode_info     *lli   = ll_i2info(dir);
-	struct ll_statahead_info *sai   = lli->lli_sai;
-	struct dentry	    *parent;
-	struct ll_sa_entry       *entry;
-	struct ptlrpc_thread     *thread;
-	struct l_wait_info	lwi   = { 0 };
-	int		       rc    = 0;
-	struct ll_inode_info     *plli;
+	struct ll_inode_info		*lli = ll_i2info(dir);
+	struct ll_statahead_info	*sai = lli->lli_sai;
+	struct dentry			*parent;
+	struct ll_sa_entry		*entry;
+	struct ptlrpc_thread		*thread;
+	struct l_wait_info		 lwi = { 0 };
+	int				 rc = 0;
+	struct ll_inode_info		*plli;
 
 	LASSERT(lli->lli_opendir_pid == current_pid());
 
@@ -1585,12 +1585,15 @@ int do_statahead_enter(struct inode *dir, struct dentry **dentryp,
 						ll_inode2fid(inode), &bits);
 			if (rc == 1) {
 				if ((*dentryp)->d_inode == NULL) {
-					*dentryp = ll_splice_alias(inode,
-								   *dentryp);
-					if (IS_ERR(*dentryp)) {
+					struct dentry *alias;
+
+					alias = ll_splice_alias(inode,
+								*dentryp);
+					if (IS_ERR(alias)) {
 						ll_sai_unplug(sai, entry);
-						return PTR_ERR(*dentryp);
+						return PTR_ERR(alias);
 					}
+					*dentryp = alias;
 				} else if ((*dentryp)->d_inode != inode) {
 					/* revalidate, but inode is recreated */
 					CDEBUG(D_READA,
-- 
1.7.9.5


  parent reply	other threads:[~2013-11-14 16:50 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-14 16:42 [PATCH 00/26] staging/lustre: patch bomb 3 Peng Tao
2013-11-14 16:42 ` [PATCH 01/26] staging/lustre/hsm: handle file ownership and timestamps Peng Tao
2013-11-14 16:42 ` [PATCH 02/26] staging/lustre/build: fix race issues thanks to oap_lock Peng Tao
2013-11-14 16:42 ` [PATCH 03/26] staging/lustre/clio: incorrect assertions in 'enable-invariants' Peng Tao
2013-11-14 16:42 ` [PATCH 04/26] staging/lustre/ldlm: Fix a race during FLock handling Peng Tao
2013-11-14 16:42 ` Peng Tao [this message]
2013-11-14 16:42 ` [PATCH 06/26] staging/lustre/build: fix 'NULL pointer dereference' errors Peng Tao
2013-11-14 16:42 ` [PATCH 07/26] staging/lustre/ldlm: refine LU-2665 patch for POSIX compliance Peng Tao
2013-11-14 16:42 ` [PATCH 08/26] staging/lustre/llite: speedup in unlink/rmdir Peng Tao
2013-11-14 16:42 ` [PATCH 09/26] staging/lustre/llite: error setting max_cache_mb at mount time Peng Tao
2013-11-14 16:42 ` [PATCH 10/26] staging/lustre/ldlm: MDT mount fails on MDS w/o MGS on it Peng Tao
2013-11-14 16:42 ` [PATCH 11/26] staging/lustre/ptlrpc: Return a meaningful status from ptlrpcd_init() Peng Tao
2013-11-14 16:42 ` [PATCH 12/26] staging/lustre/ldlm: Fix flock detection for different mounts Peng Tao
2013-11-14 16:43 ` [PATCH 13/26] staging/lustre/nrs: Fix a race condition in the ORR policy Peng Tao
2013-11-14 16:43 ` [PATCH 14/26] staging/lustre/ptlrpc: skip rpcs that fail ptl_send_rpc Peng Tao
2013-11-14 16:43 ` [PATCH 15/26] staging/lustre/llite: Truncate to restore file Peng Tao
2013-11-14 16:43 ` [PATCH 16/26] staging/lustre/lov: avoid subobj's coh_parent race Peng Tao
2013-11-14 16:43 ` [PATCH 17/26] staging/lustre/changelogs: Correct KUC code max changelog msg size Peng Tao
2013-11-14 16:43 ` [PATCH 18/26] staging/lustre/scrub: support dryrun mode OI scrub Peng Tao
2013-11-14 16:43 ` [PATCH 19/26] staging/lustre/mdt: return EXDEV for cross-MDT rename Peng Tao
2013-11-14 16:43 ` [PATCH 20/26] staging/lustre/hsm: reprocess LDLM resource in mdt_hsm_release() Peng Tao
2013-11-14 16:43 ` [PATCH 21/26] staging/lustre/clio: Do not shrink sublock at cancel Peng Tao
2013-11-14 16:43 ` [PATCH 22/26] staging/lustre/osc: osc_extent_wait() shouldn't be interruptible Peng Tao
2013-11-14 16:43 ` [PATCH 23/26] staging/lustre/seq: make seq_proc_write_common() safer Peng Tao
2013-11-14 16:43 ` [PATCH 24/26] staging/lustre/lprocfs: implement log2 using bitops Peng Tao
2013-11-14 16:43 ` [PATCH 25/26] staging/lustre/autoconf: remove quota_on/quota_off checks Peng Tao
2013-11-14 16:43 ` [PATCH 26/26] staging/lustre/autoconf: remove LC_BI_HW_SEGMENTS test Peng Tao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1384447393-13838-6-git-send-email-bergwolf@gmail.com \
    --to=bergwolf@gmail.com \
    --cc=andreas.dilger@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=spimpale@ddn.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox