aboutsummaryrefslogtreecommitdiffstats
path: root/security/keys/keyctl.c
diff options
context:
space:
mode:
Diffstat (limited to 'security/keys/keyctl.c')
-rw-r--r--security/keys/keyctl.c18
1 files changed, 2 insertions, 16 deletions
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c
index 6523599e9ac0..fb767c6cd99f 100644
--- a/security/keys/keyctl.c
+++ b/security/keys/keyctl.c
@@ -14,6 +14,7 @@
14#include <linux/sched.h> 14#include <linux/sched.h>
15#include <linux/slab.h> 15#include <linux/slab.h>
16#include <linux/syscalls.h> 16#include <linux/syscalls.h>
17#include <linux/key.h>
17#include <linux/keyctl.h> 18#include <linux/keyctl.h>
18#include <linux/fs.h> 19#include <linux/fs.h>
19#include <linux/capability.h> 20#include <linux/capability.h>
@@ -1257,10 +1258,8 @@ error:
1257 */ 1258 */
1258long keyctl_set_timeout(key_serial_t id, unsigned timeout) 1259long keyctl_set_timeout(key_serial_t id, unsigned timeout)
1259{ 1260{
1260 struct timespec now;
1261 struct key *key, *instkey; 1261 struct key *key, *instkey;
1262 key_ref_t key_ref; 1262 key_ref_t key_ref;
1263 time_t expiry;
1264 long ret; 1263 long ret;
1265 1264
1266 key_ref = lookup_user_key(id, KEY_LOOKUP_CREATE | KEY_LOOKUP_PARTIAL, 1265 key_ref = lookup_user_key(id, KEY_LOOKUP_CREATE | KEY_LOOKUP_PARTIAL,
@@ -1286,20 +1285,7 @@ long keyctl_set_timeout(key_serial_t id, unsigned timeout)
1286 1285
1287okay: 1286okay:
1288 key = key_ref_to_ptr(key_ref); 1287 key = key_ref_to_ptr(key_ref);
1289 1288 key_set_timeout(key, timeout);
1290 /* make the changes with the locks held to prevent races */
1291 down_write(&key->sem);
1292
1293 expiry = 0;
1294 if (timeout > 0) {
1295 now = current_kernel_time();
1296 expiry = now.tv_sec + timeout;
1297 }
1298
1299 key->expiry = expiry;
1300 key_schedule_gc(key->expiry + key_gc_delay);
1301
1302 up_write(&key->sem);
1303 key_put(key); 1289 key_put(key);
1304 1290
1305 ret = 0; 1291 ret = 0;