When working with multiple files and multiple threads, the following scenario can occur: 1. File Close -> Key cache removal -> context switch 2. Open new file -> occupy the entry cleaned in 1 -> TZ_ES_SET_ICE_KEY -> context switch 3. Back to 1 -> TZ_ES_INVALIDATE_ICE_KEY 4. Back to 2 -> ICE uses the key that is already invalid 5. Crash due to PARTIALLY_SET_KEY_USED To fix this, pfk must know when requests using some key are completed. Only then key removal shall be allowed and until then key invalidation must wait. A new callback was added to let clients inform PFK when requests end. Change-Id: Id7f8a3302fac9fafd1203d8d56ca13d59b45bbd5 Signed-off-by: Gilad Broner <gbroner@codeaurora.org> Signed-off-by: Andrey Markovytch <andreym@codeaurora.org>
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
/* Copyright (c) 2015-2016, The Linux Foundation. All rights reserved.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU General Public License version 2 and
|
|
* only version 2 as published by the Free Software Foundation.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*/
|
|
|
|
#ifndef PFK_H_
|
|
#define PFK_H_
|
|
|
|
#include <linux/bio.h>
|
|
|
|
struct ice_crypto_setting;
|
|
|
|
#ifdef CONFIG_PFK
|
|
|
|
int pfk_load_key_start(const struct bio *bio,
|
|
struct ice_crypto_setting *ice_setting, bool *is_pfe, bool);
|
|
int pfk_load_key_end(const struct bio *bio, bool *is_pfe);
|
|
int pfk_remove_key(const unsigned char *key, size_t key_size);
|
|
bool pfk_allow_merge_bio(struct bio *bio1, struct bio *bio2);
|
|
|
|
#else
|
|
static inline int pfk_load_key_start(const struct bio *bio,
|
|
struct ice_crypto_setting *ice_setting, bool *is_pfe, bool async)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int pfk_load_key_end(const struct bio *bio, bool *is_pfe)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline int pfk_remove_key(const unsigned char *key, size_t key_size)
|
|
{
|
|
return -ENODEV;
|
|
}
|
|
|
|
static inline bool pfk_allow_merge_bio(const struct bio *bio1,
|
|
const struct bio *bio2)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline void pfk_remove_all_keys(void)
|
|
{
|
|
}
|
|
|
|
#endif /* CONFIG_PFK */
|
|
|
|
#endif /* PFK_H */
|