RE: [PATCH 05/14] getcwd(2): saner logics around prepend_path() call

From: Justin He
Date: Wed Jul 07 2021 - 03:41:55 EST




> -----Original Message-----
> From: Al Viro <viro@xxxxxxxxxxxxxxxx> On Behalf Of Al Viro
> Sent: Wednesday, May 19, 2021 8:49 AM
> To: Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx>
> Cc: Justin He <Justin.He@xxxxxxx>; Petr Mladek <pmladek@xxxxxxxx>; Steven
> Rostedt <rostedt@xxxxxxxxxxx>; Sergey Senozhatsky
> <senozhatsky@xxxxxxxxxxxx>; Andy Shevchenko
> <andriy.shevchenko@xxxxxxxxxxxxxxx>; Rasmus Villemoes
> <linux@xxxxxxxxxxxxxxxxxx>; Jonathan Corbet <corbet@xxxxxxx>; Heiko
> Carstens <hca@xxxxxxxxxxxxx>; Vasily Gorbik <gor@xxxxxxxxxxxxx>; Christian
> Borntraeger <borntraeger@xxxxxxxxxx>; Eric W . Biederman
> <ebiederm@xxxxxxxxxxxx>; Darrick J. Wong <darrick.wong@xxxxxxxxxx>; Peter
> Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>; Ira Weiny <ira.weiny@xxxxxxxxx>;
> Eric Biggers <ebiggers@xxxxxxxxxx>; Ahmed S. Darwish
> <a.darwish@xxxxxxxxxxxxx>; open list:DOCUMENTATION <linux-
> doc@xxxxxxxxxxxxxxx>; Linux Kernel Mailing List <linux-
> kernel@xxxxxxxxxxxxxxx>; linux-s390 <linux-s390@xxxxxxxxxxxxxxx>; linux-
> fsdevel <linux-fsdevel@xxxxxxxxxxxxxxx>
> Subject: [PATCH 05/14] getcwd(2): saner logics around prepend_path() call
>
> The only negative value that might get returned by prepend_path() is
> -ENAMETOOLONG, and that happens only on overflow. The same goes for
> prepend_unreachable(). Overflow is detectable by observing negative
> buflen, so we can simplify the control flow around the prepend_path()
> call. Expand prepend_unreachable(), while we are at it - that's the
> only caller.
>
> Signed-off-by: Al Viro <viro@xxxxxxxxxxxxxxxxxx>

Reviewed-by: Jia He <justin.he@xxxxxxx>

--
Cheers,
Justin (Jia He)