mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Xing Li <lixing@loongson.cn>
Cc: musl@lists.openwall.com, wanghongliang@loongson.cn
Subject: Re: [musl] [PATCH] loongarch64: add fstat and newfstatat syscall support
Date: Tue, 10 Sep 2024 08:09:38 -0400	[thread overview]
Message-ID: <20240910120937.GW10433@brightrain.aerifal.cx> (raw)
In-Reply-To: <20240910094112.1427937-1-lixing@loongson.cn>

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

  reply	other threads:[~2024-09-10 12:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-10  9:41 Xing Li
2024-09-10 12:09 ` Rich Felker [this message]
2024-10-23  0:39   ` Rich Felker
2024-10-23  1:42     ` lixing

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240910120937.GW10433@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=lixing@loongson.cn \
    --cc=musl@lists.openwall.com \
    --cc=wanghongliang@loongson.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).