I'm writing a small kernel module designed solely for accessing a particular key using the kernel's key retention service. Since I couldn't find a simple function to return a key's contents given its ID, I had to resort to request_key
as outlined in the kernel documentation.
This line is what gives the error:
struct key *my_key = request_key(&key_type_user, "test key", NULL);
I'm referencing the proper key type and I still get this error. The function in security/keys/request_key.c that my code should be calling is declared:
struct key *request_key(struct key_type *type,
const char *description,
const char *callout_info)
I don't see anything there about *type
need to be a constant. I've read that the error message might have to do with false advertising on the part of C as to what makes something "constant", but I can't see how that could relate to the above function. Any help?
You are missing to show us the context of your declaration, but from the error you get I'd guess that it is in file scope, declaring a global. Statically allocated objects like that are initialized at compile time, therefore you can't use function calls and other run-time constructs to initialize it.