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: <Zifhr1sX5soHlXSG@1wt.eu>
Date: Tue, 23 Apr 2024 18:28:31 +0200
From: Willy Tarreau <w@....eu>
To: Thomas Weißschuh <linux@...ssschuh.net>
Cc: Shuah Khan <skhan@...uxfoundation.org>,
        "Paul E. McKenney" <paulmck@...nel.org>, linux-kernel@...r.kernel.org,
        Rodrigo Campos <rodrigo@...g.com.ar>
Subject: Re: [PATCH v3 4/4] selftests/nolibc: Add tests for strlcat() and
 strlcpy()

Hi Thomas,

On Tue, Apr 23, 2024 at 11:18:06AM +0200, Thomas Weißschuh wrote:
> + Shuah and Paul, please see below.
> 
> So I picked this up and it got picked up by Shuah, but...
> 
> On 2024-02-18 16:51:06+0000, Rodrigo Campos wrote:
> > I've verified that the tests matches libbsd's strlcat()/strlcpy()
> > implementation.
> > 
> > Please note that as strlcat()/strlcpy() are not part of the libc, the
> > tests are only compiled when using nolibc.
> > 
> > Signed-off-by: Rodrigo Campos <rodrigo@...g.com.ar>
> > ---
> >  tools/testing/selftests/nolibc/nolibc-test.c | 40 ++++++++++++++++++++
> >  1 file changed, 40 insertions(+)
> > 
> > diff --git a/tools/testing/selftests/nolibc/nolibc-test.c b/tools/testing/selftests/nolibc/nolibc-test.c
> > index 6ba4f8275ac4..d373fc14706c 100644
> > --- a/tools/testing/selftests/nolibc/nolibc-test.c
> > +++ b/tools/testing/selftests/nolibc/nolibc-test.c
> > @@ -600,6 +600,25 @@ int expect_strne(const char *expr, int llen, const char *cmp)
> >  	return ret;
> >  }
> >  
> > +#define EXPECT_STRBUFEQ(cond, expr, buf, val, cmp)				\
> > +	do { if (!(cond)) result(llen, SKIPPED); else ret += expect_str_buf_eq(expr, buf, val, llen, cmp); } while (0)
> > +
> > +static __attribute__((unused))
> > +int expect_str_buf_eq(size_t expr, const char *buf, size_t val, int llen, const char *cmp)
> > +{
> > +	llen += printf(" = %lu <%s> ", expr, buf);
> 
> This introduces a compiler warning on 32bit:
> 
>     i386-linux-gcc -Os -fno-ident -fno-asynchronous-unwind-tables -std=c89 -W -Wall -Wextra -fno-stack-protector -m32 -mstack-protector-guard=global -fstack-protector-all  -o nolibc-test \
>       -nostdlib -nostdinc -static -Isysroot/i386/include nolibc-test.c nolibc-test-linkage.c -lgcc
>     nolibc-test.c: In function 'expect_str_buf_eq':
>     nolibc-test.c:610:30: error: format '%lu' expects argument of type 'long unsigned int', but argument 2 has type 'size_t' {aka 'unsigned int'} [-Werror=format=]
>       610 |         llen += printf(" = %lu <%s> ", expr, buf);
>           |                            ~~^         ~~~~
>           |                              |         |
>           |                              |         size_t {aka unsigned int}
>           |                              long unsigned int
>           |                            %u
> 
> 
> It is easy enough to fix through a cast to "unsigned long".

Yes, that's usually what I do as well with size_t everywhere as well.

> The original patch was already sent to Shuah and included in -next.
> 
> Shuah, Paul:
> 
> I'd like to rewrite the offending commit instead of having a fixup commit.
> As it seems to me the original patch would only go into 6.10 anyways.
> 
> Any objections?

I, too, think it would be the cleanest history-wise, I just don't know
if that's the easiest for Shuah if it requires to change already published
commit IDs.

> Notes to self:
> 
> * Add flag to run-tests.sh to use -Werror
> * Implement "%zu" in nolibc printf()

Could be nice indeed!

Thanks Thomas for taking care of this!
Willy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ