diff options
Diffstat (limited to 'fs/ubifs/dir.c')
-rw-r--r-- | fs/ubifs/dir.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index 14a226d47f4c..2315cb864c39 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c | |||
@@ -85,11 +85,26 @@ static int inherit_flags(const struct inode *dir, umode_t mode) | |||
85 | * initializes it. Returns new inode in case of success and an error code in | 85 | * initializes it. Returns new inode in case of success and an error code in |
86 | * case of failure. | 86 | * case of failure. |
87 | */ | 87 | */ |
88 | struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, | 88 | struct inode *ubifs_new_inode(struct ubifs_info *c, struct inode *dir, |
89 | umode_t mode) | 89 | umode_t mode) |
90 | { | 90 | { |
91 | int err; | ||
91 | struct inode *inode; | 92 | struct inode *inode; |
92 | struct ubifs_inode *ui; | 93 | struct ubifs_inode *ui; |
94 | bool encrypted = false; | ||
95 | |||
96 | if (ubifs_crypt_is_encrypted(dir)) { | ||
97 | err = fscrypt_get_encryption_info(dir); | ||
98 | if (err) { | ||
99 | ubifs_err(c, "fscrypt_get_encryption_info failed: %i", err); | ||
100 | return ERR_PTR(err); | ||
101 | } | ||
102 | |||
103 | if (!fscrypt_has_encryption_key(dir)) | ||
104 | return ERR_PTR(-EPERM); | ||
105 | |||
106 | encrypted = true; | ||
107 | } | ||
93 | 108 | ||
94 | inode = new_inode(c->vfs_sb); | 109 | inode = new_inode(c->vfs_sb); |
95 | ui = ubifs_inode(inode); | 110 | ui = ubifs_inode(inode); |
@@ -165,6 +180,17 @@ struct inode *ubifs_new_inode(struct ubifs_info *c, const struct inode *dir, | |||
165 | */ | 180 | */ |
166 | ui->creat_sqnum = ++c->max_sqnum; | 181 | ui->creat_sqnum = ++c->max_sqnum; |
167 | spin_unlock(&c->cnt_lock); | 182 | spin_unlock(&c->cnt_lock); |
183 | |||
184 | if (encrypted) { | ||
185 | err = fscrypt_inherit_context(dir, inode, &encrypted, true); | ||
186 | if (err) { | ||
187 | ubifs_err(c, "fscrypt_inherit_context failed: %i", err); | ||
188 | make_bad_inode(inode); | ||
189 | iput(inode); | ||
190 | return ERR_PTR(err); | ||
191 | } | ||
192 | } | ||
193 | |||
168 | return inode; | 194 | return inode; |
169 | } | 195 | } |
170 | 196 | ||