Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 21 Mar 2018 17:31:29 +0000
From:      Xin LI <delphij@gmail.com>
To:        Conrad Meyer <cem@freebsd.org>
Cc:        Konstantin Belousov <kostikbel@gmail.com>,  "src-committers@freebsd.org" <src-committers@freebsd.org>,  "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>,  "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, Xin Li <delphij@freebsd.org>
Subject:   Re: svn commit: r331279 - in head: include lib/libc/gen lib/libc/sys lib/libc/tests/gen sys/compat/freebsd32 sys/conf sys/kern sys/sys tests/sys/kern usr.bin/truss
Message-ID:  <CAGMYy3vKe6mbsadsyvUR=03JKWuTG%2BtR8pmtW7HzPkDQRV6f5g@mail.gmail.com>
In-Reply-To: <CAG6CVpVq4e9p7tWRhzD1YmK0Zoxg3M31bMsHMkUbqCFwBHe%2BDQ@mail.gmail.com>
References:  <201803210115.w2L1Fjt9084698@repo.freebsd.org> <20180321103325.GJ76926@kib.kiev.ua> <CAG6CVpW3tPVyh6D3FXpAc9DPqG9u_KnHBiZOFmg1zZsHmDb8jA@mail.gmail.com> <20180321152335.GL76926@kib.kiev.ua> <CAG6CVpVq4e9p7tWRhzD1YmK0Zoxg3M31bMsHMkUbqCFwBHe%2BDQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Mar 21, 2018 at 8:37 AM Conrad Meyer <cem@freebsd.org> wrote:

> On Wed, Mar 21, 2018 at 8:23 AM, Konstantin Belousov
> <kostikbel@gmail.com> wrote:
> > On Wed, Mar 21, 2018 at 08:03:16AM -0700, Conrad Meyer wrote:
> >> On Wed, Mar 21, 2018 at 3:33 AM, Konstantin Belousov
> >> > Libraries must not abort the application.
> >> > Esp. libc.
> >>
> >> What do you propose instead?  while (1); ?  I don't see that as
> >> obviously better.
> >
> > Return the error to caller, as all, well most, correct library function=
s
> > do.
>
> The abort() in case of ENOSYS was proposed by delphij@.  It is
> intended for users that getentropy() not fail.  Another possible
> fallback is to use the kern.arandom sysctl.  Would this be amenable to
> you?
>

=E2=80=8BMy proposal was: "Note that ENOSYS should be handled by fallback w=
ith
kern.arandom or an explicit abort() should be done.=E2=80=8B".

It seems that a more graceful way of doing this should be something like:

if (sysctl({MIB: KERN, ARND}, 2, buf, &buflen_copy, NULL, 0) =3D=3D -1 ||
buflen_copy !=3D buflen) {
    /*
     * The sysctl cannot fail. If it does fail on some FreeBSD
     * derivative or after some future change, just abort so that
     * the problem will be found and fixed. abort is not normally
     * suitable for a library but makes sense here.
     */
    abort();
}

Like it was done in srandomdev().



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGMYy3vKe6mbsadsyvUR=03JKWuTG%2BtR8pmtW7HzPkDQRV6f5g>