From: Peng Tao <bergwolf@gmail.com>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org,
"John L. Hammond" <john.hammond@intel.com>,
Peng Tao <bergwolf@gmail.com>,
Andreas Dilger <andreas.dilger@intel.com>
Subject: [PATCH 05/40] staging/lustre: validate open handle cookies
Date: Fri, 15 Nov 2013 00:13:07 +0800 [thread overview]
Message-ID: <1384445622-12346-6-git-send-email-bergwolf@gmail.com> (raw)
In-Reply-To: <1384445622-12346-1-git-send-email-bergwolf@gmail.com>
From: "John L. Hammond" <john.hammond@intel.com>
Add a const void *h_owner member to struct portals_handle. Add a const
void *owner parameter to class_handle2object() which must be matched
by the h_owner member of the handle in addition to the cookie. Adjust
the callers of class_handle2object() accordingly, using NULL as the
argument to the owner parameter, except in the case of
mdt_handle2mfd() where we add an explicit mdt_export_data parameter
which we use as the owner when searching for a MFD. When allocating a
new MFD, pass a pointer to the mdt_export_data into mdt_mfd_new() and
store it in h_owner. This allows the MDT to validate that the client
has not sent the wrong open handle cookie, or sent the right cookie to
the wrong MDT.
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3233
Lustre-change: http://review.whamcloud.com/6938
Signed-off-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Mike Pershin <mike.pershin@intel.com>
Signed-off-by: Peng Tao <bergwolf@gmail.com>
Signed-off-by: Andreas Dilger <andreas.dilger@intel.com>
---
.../staging/lustre/lustre/include/lustre_handles.h | 5 +++--
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c | 2 +-
drivers/staging/lustre/lustre/lov/lov_internal.h | 4 ++--
drivers/staging/lustre/lustre/obdclass/genops.c | 2 +-
.../lustre/lustre/obdclass/lustre_handles.c | 4 ++--
5 files changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/lustre_handles.h b/drivers/staging/lustre/lustre/include/lustre_handles.h
index fcd40f3..5671f62 100644
--- a/drivers/staging/lustre/lustre/include/lustre_handles.h
+++ b/drivers/staging/lustre/lustre/include/lustre_handles.h
@@ -66,7 +66,8 @@ struct portals_handle_ops {
struct portals_handle {
struct list_head h_link;
__u64 h_cookie;
- struct portals_handle_ops *h_ops;
+ const void *h_owner;
+ struct portals_handle_ops *h_ops;
/* newly added fields to handle the RCU issue. -jxiong */
cfs_rcu_head_t h_rcu;
@@ -83,7 +84,7 @@ void class_handle_hash(struct portals_handle *,
struct portals_handle_ops *ops);
void class_handle_unhash(struct portals_handle *);
void class_handle_hash_back(struct portals_handle *);
-void *class_handle2object(__u64 cookie);
+void *class_handle2object(__u64 cookie, const void *owner);
void class_handle_free_cb(cfs_rcu_head_t *);
int class_handle_init(void);
void class_handle_cleanup(void);
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
index 3900a69..d81ca5c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
@@ -570,7 +570,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
LASSERT(handle);
- lock = class_handle2object(handle->cookie);
+ lock = class_handle2object(handle->cookie, NULL);
if (lock == NULL)
return NULL;
diff --git a/drivers/staging/lustre/lustre/lov/lov_internal.h b/drivers/staging/lustre/lustre/lov/lov_internal.h
index 796da89..79ac458 100644
--- a/drivers/staging/lustre/lustre/lov/lov_internal.h
+++ b/drivers/staging/lustre/lustre/lov/lov_internal.h
@@ -107,10 +107,10 @@ static inline void lov_put_reqset(struct lov_request_set *set)
}
static inline struct lov_lock_handles *
-lov_handle2llh(struct lustre_handle *handle)
+lov_handle2llh(const struct lustre_handle *handle)
{
LASSERT(handle != NULL);
- return(class_handle2object(handle->cookie));
+ return class_handle2object(handle->cookie, NULL);
}
static inline void lov_llh_put(struct lov_lock_handles *llh)
diff --git a/drivers/staging/lustre/lustre/obdclass/genops.c b/drivers/staging/lustre/lustre/obdclass/genops.c
index f6fae16..0da0034 100644
--- a/drivers/staging/lustre/lustre/obdclass/genops.c
+++ b/drivers/staging/lustre/lustre/obdclass/genops.c
@@ -701,7 +701,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn)
}
CDEBUG(D_INFO, "looking for export cookie "LPX64"\n", conn->cookie);
- export = class_handle2object(conn->cookie);
+ export = class_handle2object(conn->cookie, NULL);
return export;
}
EXPORT_SYMBOL(class_conn2export);
diff --git a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
index be31d32..c6406c3 100644
--- a/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
+++ b/drivers/staging/lustre/lustre/obdclass/lustre_handles.c
@@ -147,7 +147,7 @@ void class_handle_hash_back(struct portals_handle *h)
}
EXPORT_SYMBOL(class_handle_hash_back);
-void *class_handle2object(__u64 cookie)
+void *class_handle2object(__u64 cookie, const void *owner)
{
struct handle_bucket *bucket;
struct portals_handle *h;
@@ -161,7 +161,7 @@ void *class_handle2object(__u64 cookie)
rcu_read_lock();
list_for_each_entry_rcu(h, &bucket->head, h_link) {
- if (h->h_cookie != cookie)
+ if (h->h_cookie != cookie || h->h_owner != owner)
continue;
spin_lock(&h->h_lock);
--
1.7.9.5
next prev parent reply other threads:[~2013-11-14 16:15 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-14 16:13 [PATCH 00/40] staging/lustre: patch bomb 1 Peng Tao
2013-11-14 16:13 ` [PATCH 01/40] staging/lustre/llite: restore ll_fiemap Peng Tao
2013-11-14 16:13 ` [PATCH 02/40] staging/lustre: remove lu_target.h Peng Tao
2013-11-14 16:13 ` [PATCH 03/40] staging/lustre: remove llog_server.c Peng Tao
2013-11-14 16:13 ` [PATCH 04/40] staging/lustre/llite: Access to released file trigs a restore Peng Tao
2013-11-15 4:09 ` Greg Kroah-Hartman
2013-11-15 9:55 ` Peng Tao
2013-11-16 10:36 ` Dilger, Andreas
2013-11-16 19:59 ` Greg Kroah-Hartman
2013-11-18 3:07 ` Peng Tao
2013-11-18 4:39 ` Greg Kroah-Hartman
2013-11-18 6:07 ` Peng Tao
2013-11-18 13:52 ` Greg Kroah-Hartman
2013-11-19 13:29 ` Peng Tao
2013-11-14 16:13 ` Peng Tao [this message]
2013-11-15 4:13 ` [PATCH 05/40] staging/lustre: validate open handle cookies Greg Kroah-Hartman
2013-11-15 10:22 ` Peng Tao
2013-11-15 20:57 ` Greg Kroah-Hartman
2013-11-16 11:20 ` Dilger, Andreas
2013-11-16 19:50 ` Greg Kroah-Hartman
2013-11-18 2:36 ` Peng Tao
2013-11-18 4:35 ` Greg Kroah-Hartman
2013-11-18 6:18 ` Peng Tao
2013-11-18 8:57 ` Dilger, Andreas
2013-11-14 16:13 ` [PATCH 06/40] staging/lustre/llite: use correct FID in ll_och_fill() Peng Tao
2013-11-14 16:13 ` [PATCH 07/40] staging/lustre/hsm: Implementation of exclusive open Peng Tao
2013-11-15 4:17 ` Greg Kroah-Hartman
2013-11-15 10:26 ` Peng Tao
2013-11-14 16:13 ` [PATCH 08/40] staging/lustre/lnet: Fix assert on empty group in selftest module Peng Tao
2013-11-14 16:13 ` [PATCH 09/40] staging/lustre/ldlm: fix resource/fid check, use DLDLMRES Peng Tao
2013-11-14 16:13 ` [PATCH 10/40] staging/lustre/server: use unified request handler for MGS Peng Tao
2013-11-14 16:13 ` [PATCH 11/40] staging/lustre/llog: MGC to use OSD API for backup logs Peng Tao
2013-11-14 16:13 ` [PATCH 12/40] staging/lustre/nfs: writing to new files will return ENOENT Peng Tao
2013-11-14 16:22 ` Cheng Shao
2013-11-14 16:28 ` Peng Tao
2013-11-15 4:01 ` Greg Kroah-Hartman
2013-11-14 16:13 ` [PATCH 13/40] staging/lustre/autoconf: remove vectored fops tests Peng Tao
2013-11-14 16:13 ` [PATCH 14/40] staging/lustre/autoconf: remove LIBCFS_HAVE_IS_COMPAT_TASK test Peng Tao
2013-11-14 16:13 ` [PATCH 15/40] staging/lustre/llog: fix return value of llog_alloc_handle Peng Tao
2013-11-14 16:13 ` [PATCH 16/40] staging/lustre/lov: convert magic to host-endian in lov_dump_lmm() Peng Tao
2013-11-14 16:13 ` [PATCH 17/40] staging/lustre/ptlrpc: Fix race during exp_flock_hash creation Peng Tao
2013-11-14 16:13 ` [PATCH 18/40] staging/lustre/mdc: prevent fall through in mdc_iocontrol() Peng Tao
2013-11-14 16:13 ` [PATCH 19/40] staging/lustre/lu: shrink lu_object by 8 bytes on x86_64 Peng Tao
2013-11-14 16:13 ` [PATCH 20/40] staging/lustre/mdt: HSM coordinator client interface Peng Tao
2013-11-14 16:13 ` [PATCH 21/40] staging/lustre/mdt: HSM coordinator agent interface Peng Tao
2013-11-14 16:13 ` [PATCH 22/40] staging/lustre/scrub: OI scrub on OST Peng Tao
2013-11-14 16:13 ` [PATCH 23/40] staging/lustre/scrub: control OI scrub on OST from user space Peng Tao
2013-11-14 16:13 ` [PATCH 24/40] staging/lustre/llite: don't check for O_CREAT in it_create_mode Peng Tao
2013-11-14 16:13 ` [PATCH 25/40] staging/lustre/build: clean up unused variables and dead code Peng Tao
2013-11-14 16:13 ` [PATCH 26/40] staging/lustre/build: fix compilation issue with is_compat_task Peng Tao
2013-11-14 16:13 ` [PATCH 27/40] staging/lustre/ptlrpc: Fix a crash when dereferencing NULL pointer Peng Tao
2013-11-14 16:13 ` [PATCH 28/40] staging/lustre/hsm: Add hsm_release feature Peng Tao
2013-11-14 16:13 ` [PATCH 29/40] staging/lustre/llite: extended attribute cache Peng Tao
2013-11-14 16:13 ` [PATCH 30/40] staging/lustre/xattr: separate ACL and XATTR caches Peng Tao
2013-11-14 16:13 ` [PATCH 31/40] staging/lustre/lnet: Add LNet Router Priority parameter Peng Tao
2013-11-14 16:13 ` [PATCH 32/40] staging/lustre/api: HSM import uses new released pattern Peng Tao
2013-11-14 16:13 ` [PATCH 33/40] staging/lustre/target: move OUT to the unified target code Peng Tao
2013-11-14 16:13 ` [PATCH 34/40] staging/lustre/seq: unified SEQ handler Peng Tao
2013-11-14 16:13 ` [PATCH 35/40] staging/lustre/llite: remove ll_d_root_ops Peng Tao
2013-11-14 16:13 ` [PATCH 36/40] staging/lustre/llite: pass correct pointer to obd_iocontrol() Peng Tao
2013-11-14 16:13 ` [PATCH 37/40] staging/lustre/idl: remove LASSERT/CLASSERT from lustre_idl.h Peng Tao
2013-11-14 16:13 ` [PATCH 38/40] staging/lustre/mgs: set_param -P option that sets value permanently Peng Tao
2013-11-14 16:13 ` [PATCH 39/40] staging/lustre/utils: HSM Posix CopyTool Peng Tao
2013-11-14 16:13 ` [PATCH 40/40] staging/lustre/ptlrpc: flock deadlock detection does not work Peng Tao
2013-11-15 3:59 ` [PATCH 00/40] staging/lustre: patch bomb 1 Greg Kroah-Hartman
2013-11-15 9:51 ` Peng Tao
2013-11-15 20:54 ` Greg Kroah-Hartman
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=1384445622-12346-6-git-send-email-bergwolf@gmail.com \
--to=bergwolf@gmail.com \
--cc=andreas.dilger@intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=john.hammond@intel.com \
--cc=linux-kernel@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).