In the Linux kernel, the following vulnerability has been resolved:
blk-crypto: make blkcryptoevict_key() more robust
If blkcryptoevictkey() sees that the key is still in-use (due to a bug) or that ->keyslotevict failed, it currently just returns while leaving the key linked into the keyslot management structures.
However, blkcryptoevictkey() is only called in contexts such as inode eviction where failure is not an option. So actually the caller proceeds with freeing the blkcryptokey regardless of the return value of blkcryptoevictkey().
These two assumptions don't match, and the result is that there can be a use-after-free in blkcryptoreprogramallkeys() after one of these errors occurs. (Note, these errors shouldn't happen; we're just talking about what happens if they do anyway.)
Fix this by making blkcryptoevict_key() unlink the key from the keyslot management structures even on failure.
Also improve some comments.