diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-08 00:28:04 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2019-05-08 00:28:04 -0400 |
commit | a9fbcd6728837268784439ad0b02ede2c024c516 (patch) | |
tree | 2a58af9a6f7573617ab482aea0998389d8b956af /fs/ext4/ext4.h | |
parent | 5abe37954e9a315c35c9490f78d55f307c3c636b (diff) | |
parent | 2c58d548f5706d085c4b009f6abb945220460632 (diff) |
Merge tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt
Pull fscrypt updates from Ted Ts'o:
"Clean up fscrypt's dcache revalidation support, and other
miscellaneous cleanups"
* tag 'fscrypt_for_linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt:
fscrypt: cache decrypted symlink target in ->i_link
vfs: use READ_ONCE() to access ->i_link
fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
fscrypt: only set dentry_operations on ciphertext dentries
fs, fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory
fscrypt: fix race allowing rename() and link() of ciphertext dentries
fscrypt: clean up and improve dentry revalidation
fscrypt: use READ_ONCE() to access ->i_crypt_info
fscrypt: remove WARN_ON_ONCE() when decryption fails
fscrypt: drop inode argument from fscrypt_get_ctx()
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 62 |
1 files changed, 47 insertions, 15 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index ef755e5f6f2f..1cb67859e051 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -2303,23 +2303,47 @@ extern unsigned ext4_free_clusters_after_init(struct super_block *sb, | |||
2303 | ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); | 2303 | ext4_fsblk_t ext4_inode_to_goal_block(struct inode *); |
2304 | 2304 | ||
2305 | #ifdef CONFIG_FS_ENCRYPTION | 2305 | #ifdef CONFIG_FS_ENCRYPTION |
2306 | static inline void ext4_fname_from_fscrypt_name(struct ext4_filename *dst, | ||
2307 | const struct fscrypt_name *src) | ||
2308 | { | ||
2309 | memset(dst, 0, sizeof(*dst)); | ||
2310 | |||
2311 | dst->usr_fname = src->usr_fname; | ||
2312 | dst->disk_name = src->disk_name; | ||
2313 | dst->hinfo.hash = src->hash; | ||
2314 | dst->hinfo.minor_hash = src->minor_hash; | ||
2315 | dst->crypto_buf = src->crypto_buf; | ||
2316 | } | ||
2317 | |||
2306 | static inline int ext4_fname_setup_filename(struct inode *dir, | 2318 | static inline int ext4_fname_setup_filename(struct inode *dir, |
2307 | const struct qstr *iname, | 2319 | const struct qstr *iname, |
2308 | int lookup, struct ext4_filename *fname) | 2320 | int lookup, |
2321 | struct ext4_filename *fname) | ||
2309 | { | 2322 | { |
2310 | struct fscrypt_name name; | 2323 | struct fscrypt_name name; |
2311 | int err; | 2324 | int err; |
2312 | 2325 | ||
2313 | memset(fname, 0, sizeof(struct ext4_filename)); | ||
2314 | |||
2315 | err = fscrypt_setup_filename(dir, iname, lookup, &name); | 2326 | err = fscrypt_setup_filename(dir, iname, lookup, &name); |
2327 | if (err) | ||
2328 | return err; | ||
2316 | 2329 | ||
2317 | fname->usr_fname = name.usr_fname; | 2330 | ext4_fname_from_fscrypt_name(fname, &name); |
2318 | fname->disk_name = name.disk_name; | 2331 | return 0; |
2319 | fname->hinfo.hash = name.hash; | 2332 | } |
2320 | fname->hinfo.minor_hash = name.minor_hash; | 2333 | |
2321 | fname->crypto_buf = name.crypto_buf; | 2334 | static inline int ext4_fname_prepare_lookup(struct inode *dir, |
2322 | return err; | 2335 | struct dentry *dentry, |
2336 | struct ext4_filename *fname) | ||
2337 | { | ||
2338 | struct fscrypt_name name; | ||
2339 | int err; | ||
2340 | |||
2341 | err = fscrypt_prepare_lookup(dir, dentry, &name); | ||
2342 | if (err) | ||
2343 | return err; | ||
2344 | |||
2345 | ext4_fname_from_fscrypt_name(fname, &name); | ||
2346 | return 0; | ||
2323 | } | 2347 | } |
2324 | 2348 | ||
2325 | static inline void ext4_fname_free_filename(struct ext4_filename *fname) | 2349 | static inline void ext4_fname_free_filename(struct ext4_filename *fname) |
@@ -2333,19 +2357,27 @@ static inline void ext4_fname_free_filename(struct ext4_filename *fname) | |||
2333 | fname->usr_fname = NULL; | 2357 | fname->usr_fname = NULL; |
2334 | fname->disk_name.name = NULL; | 2358 | fname->disk_name.name = NULL; |
2335 | } | 2359 | } |
2336 | #else | 2360 | #else /* !CONFIG_FS_ENCRYPTION */ |
2337 | static inline int ext4_fname_setup_filename(struct inode *dir, | 2361 | static inline int ext4_fname_setup_filename(struct inode *dir, |
2338 | const struct qstr *iname, | 2362 | const struct qstr *iname, |
2339 | int lookup, struct ext4_filename *fname) | 2363 | int lookup, |
2364 | struct ext4_filename *fname) | ||
2340 | { | 2365 | { |
2341 | fname->usr_fname = iname; | 2366 | fname->usr_fname = iname; |
2342 | fname->disk_name.name = (unsigned char *) iname->name; | 2367 | fname->disk_name.name = (unsigned char *) iname->name; |
2343 | fname->disk_name.len = iname->len; | 2368 | fname->disk_name.len = iname->len; |
2344 | return 0; | 2369 | return 0; |
2345 | } | 2370 | } |
2346 | static inline void ext4_fname_free_filename(struct ext4_filename *fname) { } | ||
2347 | 2371 | ||
2348 | #endif | 2372 | static inline int ext4_fname_prepare_lookup(struct inode *dir, |
2373 | struct dentry *dentry, | ||
2374 | struct ext4_filename *fname) | ||
2375 | { | ||
2376 | return ext4_fname_setup_filename(dir, &dentry->d_name, 1, fname); | ||
2377 | } | ||
2378 | |||
2379 | static inline void ext4_fname_free_filename(struct ext4_filename *fname) { } | ||
2380 | #endif /* !CONFIG_FS_ENCRYPTION */ | ||
2349 | 2381 | ||
2350 | /* dir.c */ | 2382 | /* dir.c */ |
2351 | extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *, | 2383 | extern int __ext4_check_dir_entry(const char *, unsigned int, struct inode *, |