diff options
author | Reshetova, Elena <elena.reshetova@intel.com> | 2017-07-04 08:53:30 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2017-07-04 17:35:19 -0400 |
commit | 39f25d42c04959f0ddb5b14b01b27ea221736509 (patch) | |
tree | d4750770cd0abc22cc98669a8a734673a84b5424 | |
parent | 07f2282fc6a169980b08cedf3beaf8334b7b9dde (diff) |
net, ax25: convert ax25_route.refcount 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: David S. Miller <davem@davemloft.net>
-rw-r--r-- | include/net/ax25.h | 6 | ||||
-rw-r--r-- | net/ax25/ax25_route.c | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/include/net/ax25.h b/include/net/ax25.h index edd82f0a4d27..e3467ba81f6e 100644 --- a/include/net/ax25.h +++ b/include/net/ax25.h | |||
@@ -185,7 +185,7 @@ typedef struct { | |||
185 | 185 | ||
186 | typedef struct ax25_route { | 186 | typedef struct ax25_route { |
187 | struct ax25_route *next; | 187 | struct ax25_route *next; |
188 | atomic_t refcount; | 188 | refcount_t refcount; |
189 | ax25_address callsign; | 189 | ax25_address callsign; |
190 | struct net_device *dev; | 190 | struct net_device *dev; |
191 | ax25_digi *digipeat; | 191 | ax25_digi *digipeat; |
@@ -194,14 +194,14 @@ typedef struct ax25_route { | |||
194 | 194 | ||
195 | static inline void ax25_hold_route(ax25_route *ax25_rt) | 195 | static inline void ax25_hold_route(ax25_route *ax25_rt) |
196 | { | 196 | { |
197 | atomic_inc(&ax25_rt->refcount); | 197 | refcount_inc(&ax25_rt->refcount); |
198 | } | 198 | } |
199 | 199 | ||
200 | void __ax25_put_route(ax25_route *ax25_rt); | 200 | void __ax25_put_route(ax25_route *ax25_rt); |
201 | 201 | ||
202 | static inline void ax25_put_route(ax25_route *ax25_rt) | 202 | static inline void ax25_put_route(ax25_route *ax25_rt) |
203 | { | 203 | { |
204 | if (atomic_dec_and_test(&ax25_rt->refcount)) | 204 | if (refcount_dec_and_test(&ax25_rt->refcount)) |
205 | __ax25_put_route(ax25_rt); | 205 | __ax25_put_route(ax25_rt); |
206 | } | 206 | } |
207 | 207 | ||
diff --git a/net/ax25/ax25_route.c b/net/ax25/ax25_route.c index e1fda27cb27c..0446b892618a 100644 --- a/net/ax25/ax25_route.c +++ b/net/ax25/ax25_route.c | |||
@@ -114,7 +114,7 @@ static int __must_check ax25_rt_add(struct ax25_routes_struct *route) | |||
114 | return -ENOMEM; | 114 | return -ENOMEM; |
115 | } | 115 | } |
116 | 116 | ||
117 | atomic_set(&ax25_rt->refcount, 1); | 117 | refcount_set(&ax25_rt->refcount, 1); |
118 | ax25_rt->callsign = route->dest_addr; | 118 | ax25_rt->callsign = route->dest_addr; |
119 | ax25_rt->dev = ax25_dev->dev; | 119 | ax25_rt->dev = ax25_dev->dev; |
120 | ax25_rt->digipeat = NULL; | 120 | ax25_rt->digipeat = NULL; |