[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2425260.1744385645@warthog.procyon.org.uk>
Date: Fri, 11 Apr 2025 16:34:05 +0100
From: David Howells <dhowells@...hat.com>
To: Zijun Hu <zijun_hu@...oud.com>
Cc: dhowells@...hat.com, Alexander Viro <viro@...iv.linux.org.uk>,
Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: Re: [PATCH 1/5] fs/filesystems: Fix potential unsigned integer underflow in fs_name()
Zijun Hu <zijun_hu@...oud.com> wrote:
> fs_name() has @index as unsigned int, so there is underflow risk for
> operation '@...ex--'.
>
> Fix by breaking the for loop when '@...ex == 0' which is also more proper
> than '@...ex <= 0' for unsigned integer comparison.
There isn't really a risk. The list walked by "tmp" and the checks that this
is or is not NULL will prevent a problem.
I also feel that breaking out of the loop with "<= 0" - even if the variable
is unsigned - is safer, on the off chance that someone in the future changes
the signedness of the variable.
David
Powered by blists - more mailing lists