Skip to content

Commit

Permalink
certs: Add wrapper function to check blacklisted binary hash
Browse files Browse the repository at this point in the history
The -EKEYREJECTED error returned by existing is_hash_blacklisted() is
misleading when called for checking against blacklisted hash of a
binary.

This patch adds a wrapper function is_binary_blacklisted() to return
-EPERM error if binary is blacklisted.

Signed-off-by: Nayna Jain <[email protected]>
Reviewed-by: Mimi Zohar <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
  • Loading branch information
naynajain authored and mpe committed Nov 12, 2019
1 parent e14555e commit 2434f7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
9 changes: 9 additions & 0 deletions certs/blacklist.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,15 @@ int is_hash_blacklisted(const u8 *hash, size_t hash_len, const char *type)
}
EXPORT_SYMBOL_GPL(is_hash_blacklisted);

int is_binary_blacklisted(const u8 *hash, size_t hash_len)
{
if (is_hash_blacklisted(hash, hash_len, "bin") == -EKEYREJECTED)
return -EPERM;

return 0;
}
EXPORT_SYMBOL_GPL(is_binary_blacklisted);

/*
* Initialise the blacklist
*/
Expand Down
6 changes: 6 additions & 0 deletions include/keys/system_keyring.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,18 @@ extern int restrict_link_by_builtin_and_secondary_trusted(
extern int mark_hash_blacklisted(const char *hash);
extern int is_hash_blacklisted(const u8 *hash, size_t hash_len,
const char *type);
extern int is_binary_blacklisted(const u8 *hash, size_t hash_len);
#else
static inline int is_hash_blacklisted(const u8 *hash, size_t hash_len,
const char *type)
{
return 0;
}

static inline int is_binary_blacklisted(const u8 *hash, size_t hash_len)
{
return 0;
}
#endif

#ifdef CONFIG_IMA_BLACKLIST_KEYRING
Expand Down

0 comments on commit 2434f7d

Please sign in to comment.