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>] [day] [month] [year] [list]
Date:   Wed, 5 Jun 2019 09:38:48 +0000
From:   David Laight <David.Laight@...LAB.COM>
To:     "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>
Subject: sched_setaffinity() with > 1024 cpus on gcc-9

I suspect that if I compile the following using gcc-9 It'll bleat
about going beyond the end of the array:

#define _GNU_SOURCE
#include <sched.h>

#define MAX_CPU 2048

int fubar(void)
{
        cpu_set_t *set = CPU_ALLOC(MAX_CPU);
        CPU_SET_S(MAX_CPU - 2, CPU_ALLOC_SIZE(MAX_CPU), set);
        return CPU_COUNT_S(CPU_ALLOC_SIZE(MAX_CPU), set);
}

I can't test since I don't have a copy of gcc-9.

The whole interface for > 1024 cpus looks horrid though.
Reading version 5.01 on the man page.
I'd have thought that if the application provided a short mask
to sched_setaffinity() the rest would be deemed to be zeros.
And that if an overlong mask is passed to sched_getaffinity()
the extra bytes/longs would either be zerod or unchanged.

       Be aware that CPU_ALLOC(3) may allocate a slightly larger CPU set
       than requested (because CPU sets are implemented as bit masks
       allocated in units of sizeof(long)).  Consequently,
       sched_getaffinity() can set bits beyond the requested allocation
       size, because the kernel sees a few additional bits.  Therefore, the
       caller should iterate over the bits in the returned set, counting
       those which are set, and stop upon reaching the value returned by
       CPU_COUNT(3) (rather than iterating over the number of bits requested
       to be allocated).

A short mask to sched_getaffinity() should also do something
more sensible than just returning an error.

	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