Commit 8015e180 authored by John L. Hammond's avatar John L. Hammond Committed by Greg Kroah-Hartman

staging: lustre: obd: validate open handle cookies

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.
Signed-off-by: default avatarJohn L. Hammond <john.hammond@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3233
Reviewed-on: http://review.whamcloud.com/6938Reviewed-by: default avatarAndreas Dilger <andreas.dilger@intel.com>
Reviewed-by: default avatarFan Yong <fan.yong@intel.com>
Reviewed-by: default avatarMike Pershin <mike.pershin@intel.com>
Signed-off-by: default avatarJames Simmons <jsimmons@infradead.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 6a42e615
...@@ -66,6 +66,7 @@ struct portals_handle_ops { ...@@ -66,6 +66,7 @@ struct portals_handle_ops {
struct portals_handle { struct portals_handle {
struct list_head h_link; struct list_head h_link;
__u64 h_cookie; __u64 h_cookie;
const void *h_owner;
struct portals_handle_ops *h_ops; struct portals_handle_ops *h_ops;
/* newly added fields to handle the RCU issue. -jxiong */ /* newly added fields to handle the RCU issue. -jxiong */
...@@ -83,7 +84,7 @@ struct portals_handle { ...@@ -83,7 +84,7 @@ struct portals_handle {
void class_handle_hash(struct portals_handle *, void class_handle_hash(struct portals_handle *,
struct portals_handle_ops *ops); struct portals_handle_ops *ops);
void class_handle_unhash(struct portals_handle *); void class_handle_unhash(struct portals_handle *);
void *class_handle2object(__u64 cookie); void *class_handle2object(__u64 cookie, const void *owner);
void class_handle_free_cb(struct rcu_head *rcu); void class_handle_free_cb(struct rcu_head *rcu);
int class_handle_init(void); int class_handle_init(void);
void class_handle_cleanup(void); void class_handle_cleanup(void);
......
...@@ -542,7 +542,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle, ...@@ -542,7 +542,7 @@ struct ldlm_lock *__ldlm_handle2lock(const struct lustre_handle *handle,
LASSERT(handle); LASSERT(handle);
lock = class_handle2object(handle->cookie); lock = class_handle2object(handle->cookie, NULL);
if (!lock) if (!lock)
return NULL; return NULL;
......
...@@ -618,7 +618,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn) ...@@ -618,7 +618,7 @@ struct obd_export *class_conn2export(struct lustre_handle *conn)
} }
CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie); CDEBUG(D_INFO, "looking for export cookie %#llx\n", conn->cookie);
export = class_handle2object(conn->cookie); export = class_handle2object(conn->cookie, NULL);
return export; return export;
} }
EXPORT_SYMBOL(class_conn2export); EXPORT_SYMBOL(class_conn2export);
......
...@@ -130,7 +130,7 @@ void class_handle_unhash(struct portals_handle *h) ...@@ -130,7 +130,7 @@ void class_handle_unhash(struct portals_handle *h)
} }
EXPORT_SYMBOL(class_handle_unhash); EXPORT_SYMBOL(class_handle_unhash);
void *class_handle2object(__u64 cookie) void *class_handle2object(__u64 cookie, const void *owner)
{ {
struct handle_bucket *bucket; struct handle_bucket *bucket;
struct portals_handle *h; struct portals_handle *h;
...@@ -145,7 +145,7 @@ void *class_handle2object(__u64 cookie) ...@@ -145,7 +145,7 @@ void *class_handle2object(__u64 cookie)
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(h, &bucket->head, h_link) { 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; continue;
spin_lock(&h->h_lock); spin_lock(&h->h_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment