diff options
author | Elena Reshetova <elena.reshetova@intel.com> | 2017-03-03 04:04:05 -0500 |
---|---|---|
committer | Miklos Szeredi <mszeredi@redhat.com> | 2017-04-18 10:58:37 -0400 |
commit | 095fc40ace5ffccd306f39fdd1a40b4faa41b8a0 (patch) | |
tree | 389961004529678f773dc359e78cf9614bce9ae0 /fs/fuse | |
parent | ec99f6d31f2590a4c0ff2dae8fb1fa27f0647a42 (diff) |
fuse: convert fuse_conn.count from atomic_t to refcount_t
refcount_t type and corresponding API should be
used instead of atomic_t when the variable is used as
a reference counter. This allows to avoid accidental
refcounter overflows that might lead to use-after-free
situations.
Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Signed-off-by: David Windsor <dwindsor@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/fuse')
-rw-r--r-- | fs/fuse/fuse_i.h | 2 | ||||
-rw-r--r-- | fs/fuse/inode.c | 6 |
2 files changed, 4 insertions, 4 deletions
diff --git a/fs/fuse/fuse_i.h b/fs/fuse/fuse_i.h index 9d4374032290..6c649f0c58f9 100644 --- a/fs/fuse/fuse_i.h +++ b/fs/fuse/fuse_i.h | |||
@@ -449,7 +449,7 @@ struct fuse_conn { | |||
449 | spinlock_t lock; | 449 | spinlock_t lock; |
450 | 450 | ||
451 | /** Refcount */ | 451 | /** Refcount */ |
452 | atomic_t count; | 452 | refcount_t count; |
453 | 453 | ||
454 | /** Number of fuse_dev's */ | 454 | /** Number of fuse_dev's */ |
455 | atomic_t dev_count; | 455 | atomic_t dev_count; |
diff --git a/fs/fuse/inode.c b/fs/fuse/inode.c index 6fe6a88ecb4a..3961c5f886be 100644 --- a/fs/fuse/inode.c +++ b/fs/fuse/inode.c | |||
@@ -608,7 +608,7 @@ void fuse_conn_init(struct fuse_conn *fc) | |||
608 | memset(fc, 0, sizeof(*fc)); | 608 | memset(fc, 0, sizeof(*fc)); |
609 | spin_lock_init(&fc->lock); | 609 | spin_lock_init(&fc->lock); |
610 | init_rwsem(&fc->killsb); | 610 | init_rwsem(&fc->killsb); |
611 | atomic_set(&fc->count, 1); | 611 | refcount_set(&fc->count, 1); |
612 | atomic_set(&fc->dev_count, 1); | 612 | atomic_set(&fc->dev_count, 1); |
613 | init_waitqueue_head(&fc->blocked_waitq); | 613 | init_waitqueue_head(&fc->blocked_waitq); |
614 | init_waitqueue_head(&fc->reserved_req_waitq); | 614 | init_waitqueue_head(&fc->reserved_req_waitq); |
@@ -631,7 +631,7 @@ EXPORT_SYMBOL_GPL(fuse_conn_init); | |||
631 | 631 | ||
632 | void fuse_conn_put(struct fuse_conn *fc) | 632 | void fuse_conn_put(struct fuse_conn *fc) |
633 | { | 633 | { |
634 | if (atomic_dec_and_test(&fc->count)) { | 634 | if (refcount_dec_and_test(&fc->count)) { |
635 | if (fc->destroy_req) | 635 | if (fc->destroy_req) |
636 | fuse_request_free(fc->destroy_req); | 636 | fuse_request_free(fc->destroy_req); |
637 | fc->release(fc); | 637 | fc->release(fc); |
@@ -641,7 +641,7 @@ EXPORT_SYMBOL_GPL(fuse_conn_put); | |||
641 | 641 | ||
642 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) | 642 | struct fuse_conn *fuse_conn_get(struct fuse_conn *fc) |
643 | { | 643 | { |
644 | atomic_inc(&fc->count); | 644 | refcount_inc(&fc->count); |
645 | return fc; | 645 | return fc; |
646 | } | 646 | } |
647 | EXPORT_SYMBOL_GPL(fuse_conn_get); | 647 | EXPORT_SYMBOL_GPL(fuse_conn_get); |