request_key.c (41be702a542a0d14bb0b1c16e824fa9ed27616ec) | request_key.c (743162013d40ca612b4cb53d3a200dff2d9ab26e) |
---|---|
1/* Request a key from userspace 2 * 3 * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 7 unchanged lines hidden (view full) --- 16#include <linux/kmod.h> 17#include <linux/err.h> 18#include <linux/keyctl.h> 19#include <linux/slab.h> 20#include "internal.h" 21 22#define key_negative_timeout 60 /* default timeout on a negative key's existence */ 23 | 1/* Request a key from userspace 2 * 3 * Copyright (C) 2004-2007 Red Hat, Inc. All Rights Reserved. 4 * Written by David Howells (dhowells@redhat.com) 5 * 6 * This program is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU General Public License 8 * as published by the Free Software Foundation; either version --- 7 unchanged lines hidden (view full) --- 16#include <linux/kmod.h> 17#include <linux/err.h> 18#include <linux/keyctl.h> 19#include <linux/slab.h> 20#include "internal.h" 21 22#define key_negative_timeout 60 /* default timeout on a negative key's existence */ 23 |
24/* 25 * wait_on_bit() sleep function for uninterruptible waiting 26 */ 27static int key_wait_bit(void *flags) 28{ 29 schedule(); 30 return 0; 31} 32 33/* 34 * wait_on_bit() sleep function for interruptible waiting 35 */ 36static int key_wait_bit_intr(void *flags) 37{ 38 schedule(); 39 return signal_pending(current) ? -ERESTARTSYS : 0; 40} 41 | |
42/** 43 * complete_request_key - Complete the construction of a key. 44 * @cons: The key construction record. 45 * @error: The success or failute of the construction. 46 * 47 * Complete the attempt to construct a key. The key will be negated 48 * if an error is indicated. The authorisation key will be revoked 49 * unconditionally. --- 537 unchanged lines hidden (view full) --- 587 * if the key was negated; or -EKEYREVOKED or -EKEYEXPIRED if the key was 588 * revoked or expired. 589 */ 590int wait_for_key_construction(struct key *key, bool intr) 591{ 592 int ret; 593 594 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT, | 24/** 25 * complete_request_key - Complete the construction of a key. 26 * @cons: The key construction record. 27 * @error: The success or failute of the construction. 28 * 29 * Complete the attempt to construct a key. The key will be negated 30 * if an error is indicated. The authorisation key will be revoked 31 * unconditionally. --- 537 unchanged lines hidden (view full) --- 569 * if the key was negated; or -EKEYREVOKED or -EKEYEXPIRED if the key was 570 * revoked or expired. 571 */ 572int wait_for_key_construction(struct key *key, bool intr) 573{ 574 int ret; 575 576 ret = wait_on_bit(&key->flags, KEY_FLAG_USER_CONSTRUCT, |
595 intr ? key_wait_bit_intr : key_wait_bit, | |
596 intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); | 577 intr ? TASK_INTERRUPTIBLE : TASK_UNINTERRUPTIBLE); |
597 if (ret < 0) 598 return ret; | 578 if (ret) 579 return -ERESTARTSYS; |
599 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { 600 smp_rmb(); 601 return key->type_data.reject_error; 602 } 603 return key_validate(key); 604} 605EXPORT_SYMBOL(wait_for_key_construction); 606 --- 122 unchanged lines hidden --- | 580 if (test_bit(KEY_FLAG_NEGATIVE, &key->flags)) { 581 smp_rmb(); 582 return key->type_data.reject_error; 583 } 584 return key_validate(key); 585} 586EXPORT_SYMBOL(wait_for_key_construction); 587 --- 122 unchanged lines hidden --- |