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-next>] [day] [month] [year] [list]
Date: Mon, 3 Jun 2024 18:27:23 +0000
From: Carlos Llamas <cmllamas@...gle.com>
To: linux-mm@...ck.org
Cc: Mike Kravetz <mike.kravetz@...cle.com>, Andi Kleen <ak@...ux.intel.com>,
	Hugh Dickins <hughd@...gle.com>, Edward Liaw <edliaw@...gle.com>,
	kernel-team@...roid.com, linux-kernel@...r.kernel.org,
	linux-api@...r.kernel.org
Subject: Header conflicts with shmget() and SHM_HUGE_2MB

Hi, I'm trying to figure out how one would use SHM_HUGE_{2MB/1GB}
defines through shmget() from userspace. After having a look at the
man-pages I thought the #include pattern would be similar to that of
mmap(), e.g.:

  #include <sys/mman.h>
  #include <linux/mman.h>
  [...]
  	mmap(NULL, size, prot, flags | MAP_HUGETLB | MAP_HUGE_2MB,
	     fd, 0);

However, when doing the shmem equivalent with the headers I get several
redefinition conflicts. When attempting to compile something like this:

  #include <sys/shm.h>
  #include <linux/shm.h>
  [...]
  	shmid = shmget(key, size, flags | SHM_HUGETLB | SHM_HUGE_2MB);

I run into the following type of issues:

  /usr/include/linux/shm.h:26:8: error: redefinition of ‘struct shmid_ds’
     26 | struct shmid_ds {
        |        ^~~~~~~~
  In file included from /usr/include/x86_64-linux-gnu/bits/shm.h:45,
                   from /usr/include/x86_64-linux-gnu/sys/shm.h:30:
  /usr/include/x86_64-linux-gnu/bits/types/struct_shmid_ds.h:24:8: note: originally defined here
     24 | struct shmid_ds
        |        ^~~~~~~~

I can see such definitions are tagged as "obsolete" in the uapi headers.
Do we need some ifndef protection with the glibc headers?

What is the advice to follow for userspace? Skip <linux/shm.h> and
openly redefine the SHM_HUGE_* wherever needed?

Thanks,
--
Carlos Llamas

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ