kernfs: fix ino wrap-around detection
authorTejun Heo <tj@kernel.org>
Mon, 4 Nov 2019 23:54:29 +0000 (15:54 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:42:53 +0000 (08:42 +0100)
commit01e7ab5b9b0549f249c854e6783a3d0618cd825e
tree9c32333d1339f861d036b029968f782bd4bf57a2
parent451b1d966a4e907bd73a9793139d7a68dc2b6209
kernfs: fix ino wrap-around detection

commit e23f568aa63f64cd6b355094224cc9356c0f696b upstream.

When the 32bit ino wraps around, kernfs increments the generation
number to distinguish reused ino instances.  The wrap-around detection
tests whether the allocated ino is lower than what the cursor but the
cursor is pointing to the next ino to allocate so the condition never
triggers.

Fix it by remembering the last ino and comparing against that.

Signed-off-by: Tejun Heo <tj@kernel.org>
Reviewed-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Fixes: 4a3ef68acacf ("kernfs: implement i_generation")
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: stable@vger.kernel.org # v4.14+
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
fs/kernfs/dir.c
include/linux/kernfs.h