Re: [PATCH v2] x86: bring back rep movsq for user access on CPUs without ERMS

From: Linus Torvalds
Date: Sun Sep 03 2023 - 16:08:30 EST


On Sun, 3 Sept 2023 at 11:49, Linus Torvalds
<torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> So I have no idea why you claim that "currently they have no choice".
> glibc is simply being incredibly stupid, and using newfstatat() for no
> good reason.

Do you have any good benchmark that shows the effects of this?

And if you do, does the attached patch (ENTIRELY UNTESTED!) fix the
silly glibc mis-feature?

Linus
fs/stat.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/fs/stat.c b/fs/stat.c
index f19b124974f2..e187dc79a313 100644
--- a/fs/stat.c
+++ b/fs/stat.c
@@ -311,6 +311,15 @@ int vfs_fstatat(int dfd, const char __user *filename,
int statx_flags = flags | AT_NO_AUTOMOUNT;
struct filename *name;

+ /* Work around glibc being silly */
+ if (dfd >= 0 && flags == AT_EMPTY_PATH) {
+ char c;
+ if (!get_user(c, filename)) {
+ if (!c)
+ return vfs_fstat(dfd, stat);
+ }
+ }
+
name = getname_flags(filename, getname_statx_lookup_flags(statx_flags), NULL);
ret = vfs_statx(dfd, name, statx_flags, stat, STATX_BASIC_STATS);
putname(name);