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: <13d8756927914b578b076babc8b7f7fb@AcuMS.aculab.com>
Date:   Fri, 9 Jun 2023 09:15:05 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     'Zhangjin Wu' <falcon@...ylab.org>,
        "thomas@...ch.de" <thomas@...ch.de>
CC:     "arnd@...db.de" <arnd@...db.de>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "linux-kselftest@...r.kernel.org" <linux-kselftest@...r.kernel.org>,
        "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>,
        "w@....eu" <w@....eu>
Subject: RE: [PATCH v2 1/4] tools/nolibc: sys.h: add __syscall() and
 __sysret() helpers

From: Zhangjin Wu
> Sent: 09 June 2023 05:43
> 
> Hi, Thomas, David, Willy
> 
> > Hi David,
> >
> > On 2023-06-08 14:35:49+0000, David Laight wrote:
> > > From: Zhangjin Wu
> > > > Sent: 06 June 2023 09:10
> > > >
> > > > most of the library routines share the same code model, let's add two
> > > > helpers to simplify the coding and shrink the code lines too.
> > > >
> > > ...
> > > > +/* Syscall return helper, set errno as -ret when ret < 0 */
> > > > +static inline __attribute__((always_inline)) long __sysret(long ret)
> > > > +{
> > > > +	if (ret < 0) {
> > > > +		SET_ERRNO(-ret);
> > > > +		ret = -1;
> > > > +	}
> > > > +	return ret;
> > > > +}
> > >
> > > If that right?
> > > I thought that that only the first few (1024?) negative values
> > > got used as errno values.
> > >
> 
> Thanks David, this question did inspire me to think about the syscalls
> who returns pointers, we didn't touch them yet:

I'm also not sure whether lseek() is expected to return values
that would be negative.

(I do remember having to patch out some checks (not Linux) in order to use:
    echo -n xxxx | dd of=/dev/kmem oseek=nnn
in order to patch a live kernel!)

Technically read() and write() can do longer transfers, but
Linux limits them to MAXINT.
IIRC both BSD and SYSV allow drivers return all values (except -1)
form ioctl().

The check for -4095UL is probably reasonable.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ