History log of /linux/fs/d_path.c (Results 1 – 24 of 24)
Revision Date Author Comments
# df67cb4c 16-May-2023 Arnd Bergmann <arnd@arndb.de>

fs: d_path: include internal.h

make W=1 warns about a missing prototype that is defined but
not visible at point where simple_dname() is defined:

fs/d_path.c:317:7: error: no previous prototype for

fs: d_path: include internal.h

make W=1 warns about a missing prototype that is defined but
not visible at point where simple_dname() is defined:

fs/d_path.c:317:7: error: no previous prototype for 'simple_dname' [-Werror=missing-prototypes]

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Message-Id: <20230516195444.551461-1-arnd@kernel.org>
Signed-off-by: Christian Brauner <brauner@kernel.org>

show more ...


# c4c84511 31-Jan-2022 Al Viro <viro@zeniv.linux.org.uk>

d_path.c: typo fix...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 0f60d288 30-Jan-2022 Al Viro <viro@zeniv.linux.org.uk>

dynamic_dname(): drop unused dentry argument

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# d41b6035 05-Nov-2021 Jia He <justin.he@arm.com>

d_path: fix Kernel doc validator complaining

Kernel doc validator complains:
Function parameter or member 'p' not described in 'prepend_name'
Excess function parameter 'buffer' description in 'p

d_path: fix Kernel doc validator complaining

Kernel doc validator complains:
Function parameter or member 'p' not described in 'prepend_name'
Excess function parameter 'buffer' description in 'prepend_name'

Link: https://lkml.kernel.org/r/20211011005614.26189-1-justin.he@arm.com
Fixes: ad08ae586586 ("d_path: introduce struct prepend_buffer")
Signed-off-by: Jia He <justin.he@arm.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

show more ...


# b0cfcdd9 16-Jul-2021 Linus Torvalds <torvalds@linux-foundation.org>

d_path: make 'prepend()' fill up the buffer exactly on overflow

Instead of just marking the buffer as having overflowed, fill it up as
much as we can. That will allow the overflow case to then retu

d_path: make 'prepend()' fill up the buffer exactly on overflow

Instead of just marking the buffer as having overflowed, fill it up as
much as we can. That will allow the overflow case to then return
whatever truncated result if it wants to.

Cc: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

show more ...


# e4b27553 17-May-2021 Al Viro <viro@zeniv.linux.org.uk>

getcwd(2): clean up error handling

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# cf4febc1 17-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: prepend_path() is unlikely to return non-zero

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 008673ff 12-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: prepend_path(): lift the inner loop into a new helper

... and leave the rename_lock/mount_lock handling in prepend_path()
itself

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 2dac0ad1 12-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: prepend_path(): lift resetting b in case when we'd return 3 out of loop

preparation to extracting the loop into helper (next commit)

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 7c0d552f 12-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: prepend_path(): get rid of vfsmnt

it's kept equal to &mnt->mnt all along.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# ad08ae58 12-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: introduce struct prepend_buffer

We've a lot of places where we have pairs of form (pointer to end
of buffer, amount of space left in front of that). These sit in pairs of
variables

d_path: introduce struct prepend_buffer

We've a lot of places where we have pairs of form (pointer to end
of buffer, amount of space left in front of that). These sit in pairs of
variables located next to each other and usually passed by reference.
Turn those into instances of new type (struct prepend_buffer) and pass
reference to the pair instead of pairs of references to its fields.

Declared and initialized by DECLARE_BUFFER(name, buf, buflen).

extract_string(prepend_buffer) returns the buffer contents if
no overflow has happened, ERR_PTR(ENAMETOOLONG) otherwise.
All places where we used to have that boilerplate converted to use
of that helper.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# 95b55c42 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: make prepend_name() boolean

It returns only 0 or -ENAMETOOLONG and both callers only check if
the result is negative. Might as well return true on success and
false on failure...

Signed-of

d_path: make prepend_name() boolean

It returns only 0 or -ENAMETOOLONG and both callers only check if
the result is negative. Might as well return true on success and
false on failure...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# 01a4428e 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: lift -ENAMETOOLONG handling into callers of prepend_path()

The only negative value ever returned by prepend_path() is -ENAMETOOLONG
and callers can recognize that situation (overflow) by loo

d_path: lift -ENAMETOOLONG handling into callers of prepend_path()

The only negative value ever returned by prepend_path() is -ENAMETOOLONG
and callers can recognize that situation (overflow) by looking at the
sign of buflen. Lift that into the callers; we already have the
same logics (buf if buflen is non-negative, ERR_PTR(-ENAMETOOLONG) otherwise)
in several places and that'll become a new primitive several commits down
the road.

Make prepend_path() return 0 instead of -ENAMETOOLONG. That makes for
saner calling conventions (0/1/2/3/-ENAMETOOLONG is obnoxious) and
callers actually get simpler, especially once the aforementioned
primitive gets added.

In prepend_path() itself we switch prepending the / (in case of
empty path) to use of prepend() - no need to open-code that, compiler
will do the right thing. It's exactly the same logics as in
__dentry_path().

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# d8548232 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: don't bother with return value of prepend()

Only simple_dname() checks it, and there we can simply do those
calls and check for overflow (by looking of negative buflen)
in the end.

Signed-o

d_path: don't bother with return value of prepend()

Only simple_dname() checks it, and there we can simply do those
calls and check for overflow (by looking of negative buflen)
in the end.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# a0378fb9 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

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_u

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@zeniv.linux.org.uk>

show more ...


# 9024348f 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: get rid of path_with_deleted()

expand in the sole caller; transform the initial prepends similar to
what we'd done in dentry_path() (prepend_path() will fail the right
way if we call it with

d_path: get rid of path_with_deleted()

expand in the sole caller; transform the initial prepends similar to
what we'd done in dentry_path() (prepend_path() will fail the right
way if we call it with negative buflen, same as __dentry_path() does).

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# 3acca043 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: regularize handling of root dentry in __dentry_path()

All path-forming primitives boil down to sequence of prepend_name()
on dentries encountered along the way toward root. Each time we pre

d_path: regularize handling of root dentry in __dentry_path()

All path-forming primitives boil down to sequence of prepend_name()
on dentries encountered along the way toward root. Each time we prepend
/ + dentry name to the buffer. Normally that does exactly what we want,
but there's a corner case when we don't call prepend_name() at all (in case
of __dentry_path() that happens if we are given root dentry). We obviously
want to end up with "/", rather than "", so this corner case needs to be
handled.

__dentry_path() used to manually put '/' in the end of buffer before
doing anything else, to be overwritten by the first call of prepend_name()
if one happens and to be left in place if we don't call prepend_name() at
all. That required manually checking that we had space in the buffer
(prepend_name() and prepend() take care of such checks themselves) and lead
to clumsy keeping track of return value.

A better approach is to check if the main loop has added anything
into the buffer and prepend "/" if it hasn't. A side benefit of using prepend()
is that it does the right thing if we'd already run out of buffer, making
the overflow-handling logics simpler.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# 3a291c97 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: saner calling conventions for __dentry_path()

1) lift NUL-termination into the callers
2) pass pointer to the end of buffer instead of that to beginning.

(1) allows to simplify dentry_path(

d_path: saner calling conventions for __dentry_path()

1) lift NUL-termination into the callers
2) pass pointer to the end of buffer instead of that to beginning.

(1) allows to simplify dentry_path() - we don't need to play silly
games with restoring the leading / of "//deleted" after __dentry_path()
would've overwritten it with NUL.

We also do not need to check if (either) prepend() in there fails -
if the buffer is not large enough, we'll end with negative buflen
after prepend() and __dentry_path() will return the right value
(ERR_PTR(-ENAMETOOLONG)) just fine.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>

show more ...


# dfe50876 18-May-2021 Al Viro <viro@zeniv.linux.org.uk>

d_path: "\0" is {0,0}, not {0}

Single-element array consisting of one NUL is spelled ""...

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# a2bbe664 07-Jul-2019 Al Viro <viro@zeniv.linux.org.uk>

constify dentry argument of dentry_path()/dentry_path_raw()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 09cad075 14-Oct-2020 Andrii Nakryiko <andrii@kernel.org>

fs: fix NULL dereference due to data race in prepend_path()

Fix data race in prepend_path() with re-reading mnt->mnt_ns twice
without holding the lock.

is_mounted() does check for NULL, but is_anon

fs: fix NULL dereference due to data race in prepend_path()

Fix data race in prepend_path() with re-reading mnt->mnt_ns twice
without holding the lock.

is_mounted() does check for NULL, but is_anon_ns(mnt->mnt_ns) might
re-read the pointer again which could be NULL already, if in between
reads one of kern_unmount()/kern_unmount_array()/umount_tree() sets
mnt->mnt_ns to NULL.

This is seen in production with the following stack trace:

BUG: kernel NULL pointer dereference, address: 0000000000000048
...
RIP: 0010:prepend_path.isra.4+0x1ce/0x2e0
Call Trace:
d_path+0xe6/0x150
proc_pid_readlink+0x8f/0x100
vfs_readlink+0xf8/0x110
do_readlinkat+0xfd/0x120
__x64_sys_readlinkat+0x1a/0x20
do_syscall_64+0x42/0x110
entry_SYSCALL_64_after_hwframe+0x44/0xa9

Fixes: f2683bd8d5bd ("[PATCH] fix d_absolute_path() interplay with fsmount()")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Reviewed-by: Josef Bacik <josef@toxicpanda.com>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

show more ...


# f2683bd8 30-Aug-2019 Al Viro <viro@zeniv.linux.org.uk>

[PATCH] fix d_absolute_path() interplay with fsmount()

stuff in anon namespace should be treated as unattached.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 7e5f7bb0 20-May-2019 Al Viro <viro@zeniv.linux.org.uk>

unexport simple_dname()

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>


# 7a5cf791 06-Mar-2018 Al Viro <viro@zeniv.linux.org.uk>

split d_path() and friends into a separate file

Those parts of fs/dcache.c are pretty much self-contained.

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>