Commit 8dca1e0
committed
fs: fix UAF/GPF bug in nilfs_mdt_destroy
jira VULN-155283
cve CVE-2022-50367
commit-author Dongliang Mu <[email protected]>
commit 2e488f1
upstream-diff |
Adjusted context in inode_init_always to due rh specific variable
rh_reserved2 being initialized to 0 added in commit:
dbb05b7 ("Rebuild centos8 with kernel-4.18.0-80.el8")
In alloc_inode, inode_init_always() could return -ENOMEM if
security_inode_alloc() fails, which causes inode->i_private
uninitialized. Then nilfs_is_metadata_file_inode() returns
true and nilfs_free_inode() wrongly calls nilfs_mdt_destroy(),
which frees the uninitialized inode->i_private
and leads to crashes(e.g., UAF/GPF).
Fix this by moving security_inode_alloc just prior to
this_cpu_inc(nr_inodes)
Link: https://lkml.kernel.org/r/CAFcO6XOcf1Jj2SeGt=jJV59wmhESeSKpfR0omdFRq+J9nD1vfQ@mail.gmail.com
Reported-by: butt3rflyh4ck <[email protected]>
Reported-by: Hao Sun <[email protected]>
Reported-by: Jiacheng Xu <[email protected]>
Reviewed-by: Christian Brauner (Microsoft) <[email protected]>
Signed-off-by: Dongliang Mu <[email protected]>
Cc: Al Viro <[email protected]>
Cc: [email protected]
Signed-off-by: Al Viro <[email protected]>
(cherry picked from commit 2e488f1)
Signed-off-by: Roxana Nicolescu <[email protected]>1 parent 8aed17c commit 8dca1e0
1 file changed
+3
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
171 | | - | |
172 | | - | |
173 | 171 | | |
174 | 172 | | |
175 | 173 | | |
| |||
200 | 198 | | |
201 | 199 | | |
202 | 200 | | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
203 | 204 | | |
204 | 205 | | |
205 | 206 | | |
206 | | - | |
207 | | - | |
208 | 207 | | |
209 | 208 | | |
210 | 209 | | |
| |||
0 commit comments