Bug 208405 - 【ubifs】A potential space leak problem while linking tmpfile
Summary: 【ubifs】A potential space leak problem while linking tmpfile
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: Other (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_other
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-07-01 08:42 UTC by Zhihao Cheng
Modified: 2024-04-01 07:41 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.8
Subsystem:
Regression: No
Bisected commit-id:


Attachments
reproduce.patch (3.49 KB, patch)
2020-07-01 08:42 UTC, Zhihao Cheng
Details | Diff
a.c (689 bytes, text/x-csrc)
2020-07-01 08:42 UTC, Zhihao Cheng
Details
diff (1.37 KB, patch)
2024-04-01 07:40 UTC, Zhihao Cheng
Details | Diff
a.c (1.17 KB, text/plain)
2024-04-01 07:40 UTC, Zhihao Cheng
Details
test.sh (1.54 KB, application/x-shellscript)
2024-04-01 07:41 UTC, Zhihao Cheng
Details

Description Zhihao Cheng 2020-07-01 08:42:07 UTC
There is a potential space leak problem while linking tmpfile, in which case, inode node(with nlink=0) is valid in tnc (on flash), which leads to space leak. Meanwhile, the corresponding data nodes won't be released from tnc.

The reproducer:
Step 1. Apply reproduce.patch
Step 2. mount **fresh** ubifs on '/root/temp'
Step 3. gcc -o aa a.c
Step 4. ./aa && dmesg
[ 3810.325408] NOT FOUND
[ 3811.215275] COMMIT START
[ 3811.216363] orphan commit orpahns 1
[ 3811.217532] commmit noorphan 0
[ 3811.218545] COMMIT END
[ 3811.222095] total orphans 0
[ 3811.223224] COMMIT START
[ 3811.224177] orphan commit orpahns 0
[ 3811.225450] commmit noorphan 1
[ 3811.226586] COMMIT END
[ 3811.227350] delete 65 from orphan
Step 5. Manually powercut when see 'delete 65 from orphan' in dmesg
Step 6. mount ubifs
[ 3863.152517] COMMIT START
[ 3863.152901] orphan commit orpahns 0
[ 3863.153491] commmit noorphan 1
[ 3863.153920] COMMIT END
[ 3863.154256] UBIFS (ubi0:0): recovery completed
[ 3863.154455] Found 65 0              # Find inode 65, nlink=0
Comment 1 Zhihao Cheng 2020-07-01 08:42:28 UTC
Created attachment 290021 [details]
reproduce.patch
Comment 2 Zhihao Cheng 2020-07-01 08:42:38 UTC
Created attachment 290023 [details]
a.c
Comment 3 Zhihao Cheng 2024-04-01 07:40:25 UTC
New reproducer:
1. Apply diff
2. ./test.sh 1
3. powercut when you see "Do powercut"
4. ./test.sh

df stat (Used 54M)
Filesystem     Type   Size  Used Avail Use% Mounted on
/dev/ubi0_0    ubifs  110M   54M   52M  51% /root/temp

du stat (Used 0 bytes)
0	/root/temp/dir
0	/root/temp/f2
Comment 4 Zhihao Cheng 2024-04-01 07:40:38 UTC
Created attachment 306072 [details]
diff
Comment 5 Zhihao Cheng 2024-04-01 07:40:58 UTC
Created attachment 306073 [details]
a.c
Comment 6 Zhihao Cheng 2024-04-01 07:41:11 UTC
Created attachment 306074 [details]
test.sh

Note You need to log in before you can comment on or make changes to this bug.