lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACWXhK==yVZGZbY+3DUAuxL34=gKwQv20Cw3y1+QKir0D2F3EQ@mail.gmail.com>
Date:   Wed, 8 Feb 2023 10:09:48 +0800
From:   Feiyang Chen <chris.chenfeiyang@...il.com>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     w@....eu, "Paul E. McKenney" <paulmck@...nel.org>,
        Feiyang Chen <chenfeiyang@...ngson.cn>,
        Huacai Chen <chenhuacai@...nel.org>,
        Jiaxun Yang <jiaxun.yang@...goat.com>,
        loongarch@...ts.linux.dev, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] nolibc: Add statx() support to implement sys_stat()

On Tue, 7 Feb 2023 at 22:31, Arnd Bergmann <arnd@...db.de> wrote:
>
> On Tue, Feb 7, 2023, at 03:09, chris.chenfeiyang@...il.com wrote:
> > From: Feiyang Chen <chenfeiyang@...ngson.cn>
> >
> > Neither __NR_newfstatat nor __NR_stat is defined on new architecture
> > like LoongArch, but we can use statx() to implement sys_stat().
> >
> > Signed-off-by: Feiyang Chen <chenfeiyang@...ngson.cn>
>
> This looks nice, it should also help on 32-bit architectures that
> only have stat64 but not newfstatat or stat.
>
> > +#if defined(__NR_newfstatat) || defined(__NR_stat)
> >  static __attribute__((unused))
> >  int sys_stat(const char *path, struct stat *buf)
> ...
> > +#else
> > +#error None of __NR_newfstatat, __NR_stat, nor __NR_statx defined,
> > cannot implement sys_stat()
> > +#endif
>
> Given that all architectures implement statx the same way, I wonder
> if we can't just kill off the old function here and always use statx.
>
> That would also allow removing the architecture specific
> sys_stat_struct definitions in all arch-*.h files.
>

Hi, Arnd,

I'd really like to make all architectures use sys_statx() instead
of sys_stat(). I just fear we might get dragged into a long discussion.
Can I send a patch series to do this later?

> > +struct statx_timestamp {
> > +     __s64   tv_sec;
> > +     __u32   tv_nsec;
> > +     __s32   __reserved;
> > +};
> > +
> > +struct statx {
> > +     /* 0x00 */
> > +     __u32   stx_mask;       /* What results were written [uncond] */
> > +     __u32   stx_blksize;    /* Preferred general I/O size [uncond] */
> > +     __u64   stx_attributes; /* Flags conveying information about the file
> > [uncond] */
> > +     /* 0x10 */
> > +     __u32   stx_nlink;      /* Number of hard links */
> > +     __u32   stx_uid;        /* User ID of owner */
> > +     __u32   stx_gid;        /* Group ID of owner */
> > +     __u16   stx_mode;       /* File mode */
> > +     __u16   __spare0[1];
> > +     /* 0x20 */
> > +     __u64   stx_ino;        /* Inode number */
> > +     __u64   stx_size;       /* File size */
> > +     __u64   stx_blocks;     /* Number of 512-byte blocks allocated */
> > +     __u64   stx_attributes_mask; /* Mask to show what's supported in
> > stx_attributes */
> > +     /* 0x40 */
> > +     struct statx_timestamp  stx_atime;      /* Last access time */
> > +     struct statx_timestamp  stx_btime;      /* File creation time */
> > +     struct statx_timestamp  stx_ctime;      /* Last attribute change time */
> > +     struct statx_timestamp  stx_mtime;      /* Last data modification time */
> > +     /* 0x80 */
> > +     __u32   stx_rdev_major; /* Device ID of special file [if bdev/cdev] */
> > +     __u32   stx_rdev_minor;
> > +     __u32   stx_dev_major;  /* ID of device containing file [uncond] */
> > +     __u32   stx_dev_minor;
> > +     /* 0x90 */
> > +     __u64   stx_mnt_id;
> > +     __u32   stx_dio_mem_align;      /* Memory buffer alignment for direct I/O */
> > +     __u32   stx_dio_offset_align;   /* File offset alignment for direct I/O */
> > +     /* 0xa0 */
> > +     __u64   __spare3[12];   /* Spare space for future expansion */
> > +     /* 0x100 */
> > +};
>
> Can't we just #include <linux/stat.h> here to avoid having to maintain
> a duplicate copy?
>

Yes, I will #include <linux/stat.h> here.

Thanks,
Feiyang

>     Arnd

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ