Commit 3af2d3a
ubifs: Fix unattached inode when powercut happens in creating
For selinux or encryption scenarios, UBIFS could become inconsistent
while creating new files in powercut case. Encryption/selinux related
xattrs will be created before creating file dentry, which makes creation
process is not atomic, details are shown as:
Encryption case:
ubifs_create
ubifs_new_inode
fscrypt_set_context
ubifs_xattr_set
create_xattr
ubifs_jnl_update // Disk: xentry xinode inode(LAST_OF_NODE_GROUP)
>> power cut <<
ubifs_jnl_update // Disk: dentry inode parent_inode(LAST_OF_NODE_GROUP)
Selinux case:
ubifs_create
ubifs_new_inode
ubifs_init_security
security_inode_init_security
ubifs_xattr_set
create_xattr
ubifs_jnl_update // Disk: xentry xinode inode(LAST_OF_NODE_GROUP)
>> power cut <<
ubifs_jnl_update // Disk: dentry inode parent_inode(LAST_OF_NODE_GROUP)
Above process will make chk_fs failed in next mounting:
UBIFS error (ubi0:0 pid 7995): dbg_check_filesystem [ubifs]: inode 66
nlink is 1, but calculated nlink is 0
Fix it by allocating orphan inode for each non-xattr file creation, then
removing orphan list in journal writing process, which ensures that both
xattr and dentry be effective in atomic when powercut happens.
Fixes: d7f0b70 ("UBIFS: Add security.* XATTR support for the UBIFS")
Fixes: d475a50 ("ubifs: Add skeleton for fscrypto")
Link: https://bugzilla.kernel.org/show_bug.cgi?id=218309
Suggested-by: Zhang Yi <[email protected]>
Signed-off-by: Zhihao Cheng <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>1 parent b25e6a5 commit 3af2d3a
3 files changed
+51
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
75 | | - | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
76 | 81 | | |
77 | 82 | | |
78 | 83 | | |
| |||
163 | 168 | | |
164 | 169 | | |
165 | 170 | | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
166 | 183 | | |
167 | 184 | | |
168 | 185 | | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
169 | 190 | | |
170 | 191 | | |
171 | 192 | | |
| |||
320 | 341 | | |
321 | 342 | | |
322 | 343 | | |
| 344 | + | |
323 | 345 | | |
324 | 346 | | |
325 | 347 | | |
326 | 348 | | |
327 | 349 | | |
328 | | - | |
| 350 | + | |
329 | 351 | | |
330 | 352 | | |
331 | 353 | | |
| |||
340 | 362 | | |
341 | 363 | | |
342 | 364 | | |
| 365 | + | |
343 | 366 | | |
344 | | - | |
345 | 367 | | |
346 | 368 | | |
347 | 369 | | |
| |||
386 | 408 | | |
387 | 409 | | |
388 | 410 | | |
389 | | - | |
390 | 411 | | |
391 | 412 | | |
392 | 413 | | |
| |||
470 | 491 | | |
471 | 492 | | |
472 | 493 | | |
| 494 | + | |
473 | 495 | | |
474 | 496 | | |
475 | 497 | | |
| |||
479 | 501 | | |
480 | 502 | | |
481 | 503 | | |
482 | | - | |
| 504 | + | |
483 | 505 | | |
484 | 506 | | |
485 | 507 | | |
| |||
492 | 514 | | |
493 | 515 | | |
494 | 516 | | |
495 | | - | |
496 | 517 | | |
497 | 518 | | |
498 | 519 | | |
| |||
1011 | 1032 | | |
1012 | 1033 | | |
1013 | 1034 | | |
| 1035 | + | |
1014 | 1036 | | |
1015 | 1037 | | |
1016 | 1038 | | |
| |||
1019 | 1041 | | |
1020 | 1042 | | |
1021 | 1043 | | |
1022 | | - | |
| 1044 | + | |
1023 | 1045 | | |
1024 | 1046 | | |
1025 | 1047 | | |
| |||
1036 | 1058 | | |
1037 | 1059 | | |
1038 | 1060 | | |
| 1061 | + | |
1039 | 1062 | | |
1040 | | - | |
1041 | 1063 | | |
1042 | 1064 | | |
1043 | 1065 | | |
| |||
1107 | 1129 | | |
1108 | 1130 | | |
1109 | 1131 | | |
| 1132 | + | |
1110 | 1133 | | |
1111 | 1134 | | |
1112 | 1135 | | |
1113 | 1136 | | |
1114 | 1137 | | |
1115 | 1138 | | |
1116 | | - | |
| 1139 | + | |
1117 | 1140 | | |
1118 | 1141 | | |
1119 | 1142 | | |
| |||
1128 | 1151 | | |
1129 | 1152 | | |
1130 | 1153 | | |
| 1154 | + | |
1131 | 1155 | | |
1132 | | - | |
1133 | 1156 | | |
1134 | 1157 | | |
1135 | 1158 | | |
| |||
1208 | 1231 | | |
1209 | 1232 | | |
1210 | 1233 | | |
| 1234 | + | |
1211 | 1235 | | |
1212 | 1236 | | |
1213 | 1237 | | |
1214 | 1238 | | |
1215 | 1239 | | |
1216 | 1240 | | |
1217 | | - | |
| 1241 | + | |
1218 | 1242 | | |
1219 | 1243 | | |
1220 | 1244 | | |
| |||
1228 | 1252 | | |
1229 | 1253 | | |
1230 | 1254 | | |
| 1255 | + | |
1231 | 1256 | | |
1232 | 1257 | | |
1233 | 1258 | | |
1234 | | - | |
1235 | 1259 | | |
1236 | 1260 | | |
1237 | 1261 | | |
| |||
1399 | 1423 | | |
1400 | 1424 | | |
1401 | 1425 | | |
1402 | | - | |
1403 | | - | |
1404 | | - | |
1405 | | - | |
1406 | | - | |
1407 | 1426 | | |
1408 | 1427 | | |
1409 | 1428 | | |
| 1429 | + | |
1410 | 1430 | | |
1411 | 1431 | | |
1412 | 1432 | | |
| |||
1485 | 1505 | | |
1486 | 1506 | | |
1487 | 1507 | | |
1488 | | - | |
| 1508 | + | |
1489 | 1509 | | |
1490 | 1510 | | |
1491 | 1511 | | |
| |||
1538 | 1558 | | |
1539 | 1559 | | |
1540 | 1560 | | |
| 1561 | + | |
1541 | 1562 | | |
1542 | 1563 | | |
1543 | 1564 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
643 | 643 | | |
644 | 644 | | |
645 | 645 | | |
646 | | - | |
| 646 | + | |
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| |||
665 | 665 | | |
666 | 666 | | |
667 | 667 | | |
668 | | - | |
| 668 | + | |
669 | 669 | | |
670 | 670 | | |
671 | 671 | | |
| |||
751 | 751 | | |
752 | 752 | | |
753 | 753 | | |
754 | | - | |
| 754 | + | |
755 | 755 | | |
756 | 756 | | |
757 | 757 | | |
| |||
807 | 807 | | |
808 | 808 | | |
809 | 809 | | |
810 | | - | |
| 810 | + | |
811 | 811 | | |
812 | 812 | | |
813 | 813 | | |
| |||
1340 | 1340 | | |
1341 | 1341 | | |
1342 | 1342 | | |
| 1343 | + | |
1343 | 1344 | | |
1344 | 1345 | | |
1345 | 1346 | | |
| |||
1352 | 1353 | | |
1353 | 1354 | | |
1354 | 1355 | | |
1355 | | - | |
| 1356 | + | |
1356 | 1357 | | |
1357 | 1358 | | |
1358 | 1359 | | |
| |||
1569 | 1570 | | |
1570 | 1571 | | |
1571 | 1572 | | |
| 1573 | + | |
| 1574 | + | |
| 1575 | + | |
1572 | 1576 | | |
1573 | 1577 | | |
1574 | 1578 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1800 | 1800 | | |
1801 | 1801 | | |
1802 | 1802 | | |
1803 | | - | |
| 1803 | + | |
1804 | 1804 | | |
1805 | 1805 | | |
1806 | 1806 | | |
| |||
1817 | 1817 | | |
1818 | 1818 | | |
1819 | 1819 | | |
1820 | | - | |
| 1820 | + | |
1821 | 1821 | | |
1822 | 1822 | | |
1823 | 1823 | | |
| |||
0 commit comments