2020-11-26 10:21:39

by Yicong Yang

[permalink] [raw]
Subject: [PATCH] fs: export vfs_stat() and vfs_fstatat()

The public function vfs_stat() and vfs_fstatat() are
unexported after moving out of line in
commit 09f1bde4017e ("fs: move vfs_fstatat out of line"),
which will prevent the using in kernel modules.
So make them exported.

Fixes: 09f1bde4017e ("fs: move vfs_fstatat out of line")
Reported-by: Yang Shen <[email protected]>
Signed-off-by: Yicong Yang <[email protected]>
---
fs/stat.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/fs/stat.c b/fs/stat.c
index dacecdd..7d690c6 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -147,6 +147,7 @@ int vfs_fstat(int fd, struct kstat *stat)
fdput(f);
return error;
}
+EXPORT_SYMBOL(vfs_fstat);

/**
* vfs_statx - Get basic and extra attributes by filename
@@ -207,6 +208,7 @@ int vfs_fstatat(int dfd, const char __user *filename,
return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
stat, STATX_BASIC_STATS);
}
+EXPORT_SYMBOL(vfs_fstatat);

#ifdef __ARCH_WANT_OLD_STAT

--
2.8.1


2020-11-26 11:09:29

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

On Thu, Nov 26, 2020 at 05:08:26PM +0800, Yicong Yang wrote:
> > And why would you want to use them in kernel module? Please explain
> > that in the patch that exports them, and please send that patch in the
> > same series as the patches adding the users.
>
> we're using it in the modules for testing our crypto driver on our CI system.
> is it mandatory to upstream it if we want to use this function?

Yes. And chances are that you do not actaully need these functions
either, but to suggest a better placement I need to actually see the
code.

2020-11-26 11:37:00

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

On 2020/11/26 17:15, Christoph Hellwig wrote:
> On Thu, Nov 26, 2020 at 05:08:26PM +0800, Yicong Yang wrote:
>>> And why would you want to use them in kernel module? Please explain
>>> that in the patch that exports them, and please send that patch in the
>>> same series as the patches adding the users.
>> we're using it in the modules for testing our crypto driver on our CI system.
>> is it mandatory to upstream it if we want to use this function?
> Yes. And chances are that you do not actaully need these functions
> either, but to suggest a better placement I need to actually see the
> code.
> .

Sorry for not describing the issues I met correctly in the commit message.
Actually we're using inline function vfs_stat() for getting the
attributes, which calls vfs_fstatat():

static inline int vfs_stat(const char __user *filename, struct kstat *stat)
{
return vfs_fstatat(AT_FDCWD, filename, stat, 0);
}

after the vfs_fstatat is out-of-line it will make the moduler user of vfs_stat()
broken:

[ 5328.903677] crypto_zip_perf_test: Unknown symbol vfs_fstatat (err -2)

so the simplest way i think is directly export the vfs_fstatat().

Thanks,
Yicong




>

2020-11-26 11:58:29

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

On 2020/11/26 17:50, Christoph Hellwig wrote:
> On Thu, Nov 26, 2020 at 05:48:25PM +0800, Yicong Yang wrote:
>> Sorry for not describing the issues I met correctly in the commit message.
>> Actually we're using inline function vfs_stat() for getting the
>> attributes, which calls vfs_fstatat():
> Again, there generally isn't much need to look at the stat data
> for an in-kernel caller. But without you submitting the code I can't
> really help you anyway.
> .

sure. we'll check to see whether it's necessary or there is other way.

many thanks!



2020-11-26 22:59:56

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

On Thu, Nov 26, 2020 at 03:15:48PM +0800, Yicong Yang wrote:
> The public function vfs_stat() and vfs_fstatat() are
> unexported after moving out of line in
> commit 09f1bde4017e ("fs: move vfs_fstatat out of line"),
> which will prevent the using in kernel modules.
> So make them exported.

And why would you want to use them in kernel module? Please explain
that in the patch that exports them, and please send that patch in the
same series as the patches adding the users.

2020-11-27 05:12:18

by Yicong Yang

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

Hi Christoph,

On 2020/11/26 15:18, Christoph Hellwig wrote:
> On Thu, Nov 26, 2020 at 03:15:48PM +0800, Yicong Yang wrote:
>> The public function vfs_stat() and vfs_fstatat() are
>> unexported after moving out of line in
>> commit 09f1bde4017e ("fs: move vfs_fstatat out of line"),
>> which will prevent the using in kernel modules.
>> So make them exported.
> And why would you want to use them in kernel module? Please explain
> that in the patch that exports them, and please send that patch in the
> same series as the patches adding the users.

we're using it in the modules for testing our crypto driver on our CI system.
is it mandatory to upstream it if we want to use this function?

Thanks,
Yicong


> .
>

2020-11-27 06:12:09

by Christoph Hellwig

[permalink] [raw]
Subject: Re: [PATCH] fs: export vfs_stat() and vfs_fstatat()

On Thu, Nov 26, 2020 at 05:48:25PM +0800, Yicong Yang wrote:
> Sorry for not describing the issues I met correctly in the commit message.
> Actually we're using inline function vfs_stat() for getting the
> attributes, which calls vfs_fstatat():

Again, there generally isn't much need to look at the stat data
for an in-kernel caller. But without you submitting the code I can't
really help you anyway.