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]
Date:   Tue, 22 Mar 2022 19:18:31 +0700
From:   Ammar Faizi <ammarfaizi2@...weeb.org>
To:     David Laight <David.Laight@...LAB.COM>, Willy Tarreau <w@....eu>
Cc:     "Paul E. McKenney" <paulmck@...nel.org>,
        Alviro Iskandar Setiawan <alviro.iskandar@...weeb.org>,
        Nugraha <richiisei@...il.com>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>
Subject: Re: [RFC PATCH v2 6/8] tools/nolibc/stdlib: Implement `malloc()`,
 `calloc()`, `realloc()` and `free()`

On 3/22/22 6:52 PM, David Laight wrote:

[...]
>> +struct nolibc_heap {
>> +	size_t	len;
>> +	char	user_p[] __attribute__((__aligned__));
> 
> Doesn't that need (number) in the attribute?

The number is not mandatory.

Specifying no alignment argument implies the maximum alignment for
the target, which is often, but by no means always, 8 or 16 bytes.

This has been discussed in the RFC v1, see the full message here:

   https://lore.kernel.org/lkml/c7129520-5e9a-f9d1-cc12-5af9456c917f@gnuweeb.org/


>> +static __attribute__((unused))
>> +void *malloc(size_t len)
>> +{
>> +	struct nolibc_heap *heap;
> 
> If you do (say):
> 	len = ROUNDUP(len + sizeof *heap, 4096)
> you can optimise a lot of the realloc() calls.
> 
> I actually wonder if compiling a mini-libc.a
> and then linking the programs against it might
> be better than all these static functions?
> -ffunction-sections can help a bit (where supported).

Rounding up is not useful here, because we don't have any free list to keep
track the unused block of memory. I mean, even if it's rounded up, the extra
space after rounded up cannot be utilized with this design. There is no
book-keeping that tracks it.

Though, the kernel still allocates the size in multiple page size.

-- 
Ammar Faizi

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ