Re: [PATCH 03/04] Add encryption ops to the keyctl syscall

From: David Härdeman
Date: Wed Jan 25 2006 - 15:39:53 EST


On Tue, Jan 24, 2006 at 10:58:24AM +0000, David Howells wrote:
+ key = key_ref_to_ptr(key_ref);
+
+ /* see if we can read it directly */
+ ret = key_permission(key_ref, KEY_READ);

You don't actually need to calculate key until after you've done all those
checks, so I'd move it further down the file. You can use the function to
release key references in the error handling or have a separate error handling
return path.

Do you mean that I should move the key_ref_to_ptr call to right after the can_read_key label? If that is the case, shouldn't the same thing be done for keyctl_read_key?

+ down_read(&key->sem);
+ ret = key->type->encrypt(key, data, dlen, result, rlen);
+ up_read(&key->sem);

Do we really want to restrict the key type implementor to using the r/w
semaphore. Would it be better to let the type decide whether it wants to use
the semaphore or let it use RCU if it so desires?

Ok, I'll move the semaphore into the dsa key type instead and change the appropriate comments.

Re,
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/