Skip to content

Commit 51a4ae9

Browse files
tytsoBrad Figg
authored andcommitted
ext4 crypto: add missing locking for keyring_key access
BugLink: http://bugs.launchpad.net/bugs/1540532 commit db7730e upstream. Signed-off-by: Theodore Ts'o <[email protected]> Signed-off-by: Kamal Mostafa <[email protected]>
1 parent faada20 commit 51a4ae9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/ext4/crypto_key.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,9 +213,11 @@ int _ext4_get_encryption_info(struct inode *inode)
213213
res = -ENOKEY;
214214
goto out;
215215
}
216+
down_read(&keyring_key->sem);
216217
ukp = ((struct user_key_payload *)keyring_key->payload.data);
217218
if (ukp->datalen != sizeof(struct ext4_encryption_key)) {
218219
res = -EINVAL;
220+
up_read(&keyring_key->sem);
219221
goto out;
220222
}
221223
master_key = (struct ext4_encryption_key *)ukp->data;
@@ -226,10 +228,12 @@ int _ext4_get_encryption_info(struct inode *inode)
226228
"ext4: key size incorrect: %d\n",
227229
master_key->size);
228230
res = -ENOKEY;
231+
up_read(&keyring_key->sem);
229232
goto out;
230233
}
231234
res = ext4_derive_key_aes(ctx.nonce, master_key->raw,
232235
raw_key);
236+
up_read(&keyring_key->sem);
233237
if (res)
234238
goto out;
235239
got_key:

0 commit comments

Comments
 (0)