* [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support
@ 2024-09-10 9:41 Xing Li
2024-09-10 12:09 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Xing Li @ 2024-09-10 9:41 UTC (permalink / raw)
To: musl; +Cc: wanghongliang
linux kernel add fstat and newfstatat to solve the chromium sandbox, the link as follow:
https://lore.kernel.org/loongarch/CAAhV-H7W-Ygn6tXySrip4k3P5xVbVf7GpjOzjXfQvCCbA4r5Wg@mail.gmail.com/T/#t
So we add fstat and newfstatat as linux kernel.
---
arch/loongarch64/bits/syscall.h.in | 2 ++
arch/loongarch64/kstat.h | 21 +++++++++++++++++++++
2 files changed, 23 insertions(+)
create mode 100644 arch/loongarch64/kstat.h
diff --git a/arch/loongarch64/bits/syscall.h.in b/arch/loongarch64/bits/syscall.h.in
index 2afb4ea1..43efb916 100644
--- a/arch/loongarch64/bits/syscall.h.in
+++ b/arch/loongarch64/bits/syscall.h.in
@@ -76,6 +76,8 @@
#define __NR_splice 76
#define __NR_tee 77
#define __NR_readlinkat 78
+#define __NR_newfstatat 79
+#define __NR_fstat 80
#define __NR_sync 81
#define __NR_fsync 82
#define __NR_fdatasync 83
diff --git a/arch/loongarch64/kstat.h b/arch/loongarch64/kstat.h
new file mode 100644
index 00000000..92625f36
--- /dev/null
+++ b/arch/loongarch64/kstat.h
@@ -0,0 +1,21 @@
+struct kstat {
+ dev_t st_dev;
+ ino_t st_ino;
+ mode_t st_mode;
+ nlink_t st_nlink;
+ uid_t st_uid;
+ gid_t st_gid;
+ dev_t st_rdev;
+ unsigned long __pad;
+ off_t st_size;
+ blksize_t st_blksize;
+ int __pad2;
+ blkcnt_t st_blocks;
+ long st_atime_sec;
+ long st_atime_nsec;
+ long st_mtime_sec;
+ long st_mtime_nsec;
+ long st_ctime_sec;
+ long st_ctime_nsec;
+ unsigned __unused[2];
+};
--
2.27.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support
2024-09-10 9:41 [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support Xing Li
@ 2024-09-10 12:09 ` Rich Felker
2024-10-23 0:39 ` Rich Felker
0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2024-09-10 12:09 UTC (permalink / raw)
To: Xing Li; +Cc: musl, wanghongliang
On Tue, Sep 10, 2024 at 05:41:12PM +0800, Xing Li wrote:
> linux kernel add fstat and newfstatat to solve the chromium sandbox, the link as follow:
> https://lore.kernel.org/loongarch/CAAhV-H7W-Ygn6tXySrip4k3P5xVbVf7GpjOzjXfQvCCbA4r5Wg@mail.gmail.com/T/#t
>
> So we add fstat and newfstatat as linux kernel.
> ---
> arch/loongarch64/bits/syscall.h.in | 2 ++
> arch/loongarch64/kstat.h | 21 +++++++++++++++++++++
> 2 files changed, 23 insertions(+)
> create mode 100644 arch/loongarch64/kstat.h
>
> diff --git a/arch/loongarch64/bits/syscall.h.in b/arch/loongarch64/bits/syscall.h.in
> index 2afb4ea1..43efb916 100644
> --- a/arch/loongarch64/bits/syscall.h.in
> +++ b/arch/loongarch64/bits/syscall.h.in
> @@ -76,6 +76,8 @@
> #define __NR_splice 76
> #define __NR_tee 77
> #define __NR_readlinkat 78
> +#define __NR_newfstatat 79
> +#define __NR_fstat 80
> #define __NR_sync 81
> #define __NR_fsync 82
> #define __NR_fdatasync 83
> diff --git a/arch/loongarch64/kstat.h b/arch/loongarch64/kstat.h
> new file mode 100644
> index 00000000..92625f36
> --- /dev/null
> +++ b/arch/loongarch64/kstat.h
> @@ -0,0 +1,21 @@
> +struct kstat {
> + dev_t st_dev;
> + ino_t st_ino;
> + mode_t st_mode;
> + nlink_t st_nlink;
> + uid_t st_uid;
> + gid_t st_gid;
> + dev_t st_rdev;
> + unsigned long __pad;
> + off_t st_size;
> + blksize_t st_blksize;
> + int __pad2;
> + blkcnt_t st_blocks;
> + long st_atime_sec;
> + long st_atime_nsec;
> + long st_mtime_sec;
> + long st_mtime_nsec;
> + long st_ctime_sec;
> + long st_ctime_nsec;
> + unsigned __unused[2];
> +};
> --
> 2.27.0
This can't be accepted as-is because it breaks execution of new
binaries on old kernels that lack the syscalls. We don't have a
fallback order that tries statx is legacy stat fails with ENOSYS.
I also don't think this was a good solution to the problem. The same
problem exists on riscv32 and any future 32-bit archs where legacy
stat syscalls can't be added (because they're time32-only). statx
should have just been updated to avoid the need to peek at memory to
do effective seccomp with it (e.g. by accepting a null pointer for the
empty path part).
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support
2024-09-10 12:09 ` Rich Felker
@ 2024-10-23 0:39 ` Rich Felker
2024-10-23 1:42 ` lixing
0 siblings, 1 reply; 4+ messages in thread
From: Rich Felker @ 2024-10-23 0:39 UTC (permalink / raw)
To: Xing Li; +Cc: musl, wanghongliang
On Tue, Sep 10, 2024 at 08:09:38AM -0400, Rich Felker wrote:
> On Tue, Sep 10, 2024 at 05:41:12PM +0800, Xing Li wrote:
> > linux kernel add fstat and newfstatat to solve the chromium sandbox, the link as follow:
> > https://lore.kernel.org/loongarch/CAAhV-H7W-Ygn6tXySrip4k3P5xVbVf7GpjOzjXfQvCCbA4r5Wg@mail.gmail.com/T/#t
> >
> > So we add fstat and newfstatat as linux kernel.
> > ---
> > arch/loongarch64/bits/syscall.h.in | 2 ++
> > arch/loongarch64/kstat.h | 21 +++++++++++++++++++++
> > 2 files changed, 23 insertions(+)
> > create mode 100644 arch/loongarch64/kstat.h
> >
> > diff --git a/arch/loongarch64/bits/syscall.h.in b/arch/loongarch64/bits/syscall.h.in
> > index 2afb4ea1..43efb916 100644
> > --- a/arch/loongarch64/bits/syscall.h.in
> > +++ b/arch/loongarch64/bits/syscall.h.in
> > @@ -76,6 +76,8 @@
> > #define __NR_splice 76
> > #define __NR_tee 77
> > #define __NR_readlinkat 78
> > +#define __NR_newfstatat 79
> > +#define __NR_fstat 80
> > #define __NR_sync 81
> > #define __NR_fsync 82
> > #define __NR_fdatasync 83
> > diff --git a/arch/loongarch64/kstat.h b/arch/loongarch64/kstat.h
> > new file mode 100644
> > index 00000000..92625f36
> > --- /dev/null
> > +++ b/arch/loongarch64/kstat.h
> > @@ -0,0 +1,21 @@
> > +struct kstat {
> > + dev_t st_dev;
> > + ino_t st_ino;
> > + mode_t st_mode;
> > + nlink_t st_nlink;
> > + uid_t st_uid;
> > + gid_t st_gid;
> > + dev_t st_rdev;
> > + unsigned long __pad;
> > + off_t st_size;
> > + blksize_t st_blksize;
> > + int __pad2;
> > + blkcnt_t st_blocks;
> > + long st_atime_sec;
> > + long st_atime_nsec;
> > + long st_mtime_sec;
> > + long st_mtime_nsec;
> > + long st_ctime_sec;
> > + long st_ctime_nsec;
> > + unsigned __unused[2];
> > +};
> > --
> > 2.27.0
>
> This can't be accepted as-is because it breaks execution of new
> binaries on old kernels that lack the syscalls. We don't have a
> fallback order that tries statx is legacy stat fails with ENOSYS.
>
> I also don't think this was a good solution to the problem. The same
> problem exists on riscv32 and any future 32-bit archs where legacy
> stat syscalls can't be added (because they're time32-only). statx
> should have just been updated to avoid the need to peek at memory to
> do effective seccomp with it (e.g. by accepting a null pointer for the
> empty path part).
Any thoughts on how this should be fixed? We can add the loongarch
syscall.h entries, but the syscall_arch.h logic would have to disable
them for musl-internal use unless we want to support fallback logic on
archs that might have statx but not fstatat. Since this is not going
to work for most archs, I wonder if we should hold off on a better
solution from kernel side.
Rich
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support
2024-10-23 0:39 ` Rich Felker
@ 2024-10-23 1:42 ` lixing
0 siblings, 0 replies; 4+ messages in thread
From: lixing @ 2024-10-23 1:42 UTC (permalink / raw)
To: Rich Felker; +Cc: musl, wanghongliang
在 2024/10/23 上午8:39, Rich Felker 写道:
> On Tue, Sep 10, 2024 at 08:09:38AM -0400, Rich Felker wrote:
>> On Tue, Sep 10, 2024 at 05:41:12PM +0800, Xing Li wrote:
>>> linux kernel add fstat and newfstatat to solve the chromium sandbox, the link as follow:
>>> https://lore.kernel.org/loongarch/CAAhV-H7W-Ygn6tXySrip4k3P5xVbVf7GpjOzjXfQvCCbA4r5Wg@mail.gmail.com/T/#t
>>>
>>> So we add fstat and newfstatat as linux kernel.
>>> ---
>>> arch/loongarch64/bits/syscall.h.in | 2 ++
>>> arch/loongarch64/kstat.h | 21 +++++++++++++++++++++
>>> 2 files changed, 23 insertions(+)
>>> create mode 100644 arch/loongarch64/kstat.h
>>>
>>> diff --git a/arch/loongarch64/bits/syscall.h.in b/arch/loongarch64/bits/syscall.h.in
>>> index 2afb4ea1..43efb916 100644
>>> --- a/arch/loongarch64/bits/syscall.h.in
>>> +++ b/arch/loongarch64/bits/syscall.h.in
>>> @@ -76,6 +76,8 @@
>>> #define __NR_splice 76
>>> #define __NR_tee 77
>>> #define __NR_readlinkat 78
>>> +#define __NR_newfstatat 79
>>> +#define __NR_fstat 80
>>> #define __NR_sync 81
>>> #define __NR_fsync 82
>>> #define __NR_fdatasync 83
>>> diff --git a/arch/loongarch64/kstat.h b/arch/loongarch64/kstat.h
>>> new file mode 100644
>>> index 00000000..92625f36
>>> --- /dev/null
>>> +++ b/arch/loongarch64/kstat.h
>>> @@ -0,0 +1,21 @@
>>> +struct kstat {
>>> + dev_t st_dev;
>>> + ino_t st_ino;
>>> + mode_t st_mode;
>>> + nlink_t st_nlink;
>>> + uid_t st_uid;
>>> + gid_t st_gid;
>>> + dev_t st_rdev;
>>> + unsigned long __pad;
>>> + off_t st_size;
>>> + blksize_t st_blksize;
>>> + int __pad2;
>>> + blkcnt_t st_blocks;
>>> + long st_atime_sec;
>>> + long st_atime_nsec;
>>> + long st_mtime_sec;
>>> + long st_mtime_nsec;
>>> + long st_ctime_sec;
>>> + long st_ctime_nsec;
>>> + unsigned __unused[2];
>>> +};
>>> --
>>> 2.27.0
>> This can't be accepted as-is because it breaks execution of new
>> binaries on old kernels that lack the syscalls. We don't have a
>> fallback order that tries statx is legacy stat fails with ENOSYS.
>>
>> I also don't think this was a good solution to the problem. The same
>> problem exists on riscv32 and any future 32-bit archs where legacy
>> stat syscalls can't be added (because they're time32-only). statx
>> should have just been updated to avoid the need to peek at memory to
>> do effective seccomp with it (e.g. by accepting a null pointer for the
>> empty path part).
> Any thoughts on how this should be fixed? We can add the loongarch
> syscall.h entries, but the syscall_arch.h logic would have to disable
> them for musl-internal use unless we want to support fallback logic on
> archs that might have statx but not fstatat. Since this is not going
> to work for most archs, I wonder if we should hold off on a better
> solution from kernel side.
>
> Rich
Thank you for reconsidering this patch. Your last reply was blocked by
the mail server, so I didn't
reply immediatily. It's reasonable for not add 79 80 syscalls after the
kernel side add NULL param support for statx.
So not to break the compatiblity is necessary. Sorry for bother you for
this patch and thanks again.
Xing Li.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2024-10-23 1:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-09-10 9:41 [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support Xing Li
2024-09-10 12:09 ` Rich Felker
2024-10-23 0:39 ` Rich Felker
2024-10-23 1:42 ` lixing
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).