]> Git Repo - linux.git/commit
ubifs: ubifs_link: Fix wrong name len calculating when UBIFS is encrypted
authorZhihao Cheng <[email protected]>
Sat, 23 Sep 2023 03:28:59 +0000 (11:28 +0800)
committerRichard Weinberger <[email protected]>
Sat, 28 Oct 2023 21:19:08 +0000 (23:19 +0200)
commit75690493591fe283e4c92a3ba7c4420e9858abdb
tree6a9e05748db7f109e8106e93b9d3bf2824398bf9
parentd07cec9c238ae8fc6c1a9f3f5d30a2f8ec6cdc71
ubifs: ubifs_link: Fix wrong name len calculating when UBIFS is encrypted

The length of dentry name is calculated after the raw name is encrypted,
except for ubifs_link(), which could make the size of dir underflow.
Here is a reproducer:

 touch $TMP/file
 mkdir $TMP/dir
 stat $TMP/dir
 for i in $(seq 1 8)
 do
   ln $TMP/file $TMP/dir/$i
   unlink $TMP/dir/$i
 done
 stat $TMP/dir

The size of dir will be underflow(-96).

Fix it by calculating dentry name's length after the name is encrypted.

Fixes: f4f61d2cc6d8 ("ubifs: Implement encrypted filenames")
Reported-by: Roland Ruckerbauer <[email protected]>
Link: https://lore.kernel.org/linux-mtd/[email protected]/T/#u
Signed-off-by: Zhihao Cheng <[email protected]>
Signed-off-by: Richard Weinberger <[email protected]>
fs/ubifs/dir.c
This page took 0.053842 seconds and 4 git commands to generate.