Re: [PATCH 1/7] KEYS: Fix an RCU warning in the reading of user keys

From: David Howells
Date: Tue May 04 2010 - 08:49:19 EST


Serge E. Hallyn <serue@xxxxxxxxxx> wrote:

> heck it also serves to document it a bit, as looking at the fn
> itself it's not clear that it is called under key->sem.

Give or take the banner comment on user_read() where it states this explicitly:

/*
* read the key data
* - the key's semaphore is read-locked
*/
long user_read(const struct key *key, char __user *buffer, size_t buflen)

and Documentation/keys.txt where it also states this explicitly:

(*) long (*read)(const struct key *key, char __user *buffer, size_t buflen);

...

This method will be called with the key's semaphore read-locked. This will
prevent the key's payload changing. It is not necessary to use RCU locking
when accessing the key's payload. It is safe to sleep in this method, such
as might happen when the userspace buffer is accessed.

:-)

David

David
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/