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: <ac8c217e-4109-4ca7-a7dd-fc4fc8b0a4de@nvidia.com>
Date: Wed, 8 May 2024 14:23:13 -0700
From: John Hubbard <jhubbard@...dia.com>
To: Edward Liaw <edliaw@...gle.com>, <shuah@...nel.org>, Mark Brown
	<broonie@...nel.org>, Jaroslav Kysela <perex@...ex.cz>, Takashi Iwai
	<tiwai@...e.com>, Catalin Marinas <catalin.marinas@....com>, Will Deacon
	<will@...nel.org>, Nhat Pham <nphamcs@...il.com>, Johannes Weiner
	<hannes@...xchg.org>, Christian Brauner <brauner@...nel.org>, Eric Biederman
	<ebiederm@...ssion.com>, Kees Cook <keescook@...omium.org>, OGAWA Hirofumi
	<hirofumi@...l.parknet.co.jp>, Thomas Gleixner <tglx@...utronix.de>, "Ingo
 Molnar" <mingo@...hat.com>, Peter Zijlstra <peterz@...radead.org>, Darren
 Hart <dvhart@...radead.org>, Davidlohr Bueso <dave@...olabs.net>,
	André Almeida <andrealmeid@...lia.com>, Jiri Kosina
	<jikos@...nel.org>, Benjamin Tissoires <bentiss@...nel.org>, Jason Gunthorpe
	<jgg@...pe.ca>, Kevin Tian <kevin.tian@...el.com>, Andy Lutomirski
	<luto@...capital.net>, Will Drewry <wad@...omium.org>, Marc Zyngier
	<maz@...nel.org>, Oliver Upton <oliver.upton@...ux.dev>, James Morse
	<james.morse@....com>, Suzuki K Poulose <suzuki.poulose@....com>, Zenghui Yu
	<yuzenghui@...wei.com>, Paolo Bonzini <pbonzini@...hat.com>, "Sean
 Christopherson" <seanjc@...gle.com>, Anup Patel <anup@...infault.org>, "Atish
 Patra" <atishp@...shpatra.org>, Paul Walmsley <paul.walmsley@...ive.com>,
	Palmer Dabbelt <palmer@...belt.com>, Albert Ou <aou@...s.berkeley.edu>,
	Christian Borntraeger <borntraeger@...ux.ibm.com>, Janosch Frank
	<frankja@...ux.ibm.com>, Claudio Imbrenda <imbrenda@...ux.ibm.com>, "David
 Hildenbrand" <david@...hat.com>, Mickaël Salaün
	<mic@...ikod.net>, Paul Moore <paul@...l-moore.com>, James Morris
	<jmorris@...ei.org>, "Serge E. Hallyn" <serge@...lyn.com>, Andrew Morton
	<akpm@...ux-foundation.org>, Seth Forshee <sforshee@...nel.org>, Bongsu Jeon
	<bongsu.jeon@...sung.com>, "David S. Miller" <davem@...emloft.net>, "Eric
 Dumazet" <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
	<pabeni@...hat.com>, Steffen Klassert <steffen.klassert@...unet.com>,
	"Herbert Xu" <herbert@...dor.apana.org.au>, Andreas Färber
	<afaerber@...e.de>, Manivannan Sadhasivam <manivannan.sadhasivam@...aro.org>,
	Matthieu Baerts <matttbe@...nel.org>, Mat Martineau <martineau@...nel.org>,
	Geliang Tang <geliang@...nel.org>, Willem de Bruijn
	<willemdebruijn.kernel@...il.com>, Fenghua Yu <fenghua.yu@...el.com>,
	Reinette Chatre <reinette.chatre@...el.com>, Mathieu Desnoyers
	<mathieu.desnoyers@...icios.com>, "Paul E. McKenney" <paulmck@...nel.org>,
	Boqun Feng <boqun.feng@...il.com>, Alexandre Belloni
	<alexandre.belloni@...tlin.com>, Jarkko Sakkinen <jarkko@...nel.org>, "Dave
 Hansen" <dave.hansen@...ux.intel.com>, Muhammad Usama Anjum
	<usama.anjum@...labora.com>
CC: <linux-kernel@...r.kernel.org>, <linux-kselftest@...r.kernel.org>,
	<kernel-team@...roid.com>, <linux-sound@...r.kernel.org>,
	<linux-arm-kernel@...ts.infradead.org>, <linux-mm@...ck.org>,
	<linux-input@...r.kernel.org>, <iommu@...ts.linux.dev>,
	<kvmarm@...ts.linux.dev>, <kvm@...r.kernel.org>,
	<kvm-riscv@...ts.infradead.org>, <linux-riscv@...ts.infradead.org>,
	<linux-security-module@...r.kernel.org>, <linux-fsdevel@...r.kernel.org>,
	<netdev@...r.kernel.org>, <linux-actions@...ts.infradead.org>,
	<mptcp@...ts.linux.dev>, <linux-rtc@...r.kernel.org>,
	<linux-sgx@...r.kernel.org>, <bpf@...r.kernel.org>, kernel test robot
	<oliver.sang@...el.com>
Subject: Re: [PATCH v2 1/5] selftests: Compile kselftest headers with
 -D_GNU_SOURCE

On 5/7/24 2:38 PM, Edward Liaw wrote:
> Add the -D_GNU_SOURCE flag to KHDR_INCLUDES so that it is defined in a
> central location.
> 
> 809216233555 ("selftests/harness: remove use of LINE_MAX") introduced
> asprintf into kselftest_harness.h, which is a GNU extension and needs
> _GNU_SOURCE to either be defined prior to including headers or with the
> -D_GNU_SOURCE flag passed to the compiler.
> 
> Fixes: 809216233555 ("selftests/harness: remove use of LINE_MAX")
> Reported-by: kernel test robot <oliver.sang@...el.com>
> Closes: https://lore.kernel.org/oe-lkp/202404301040.3bea5782-oliver.sang@intel.com
> Signed-off-by: Edward Liaw <edliaw@...gle.com>
> ---
>   tools/testing/selftests/Makefile            | 4 ++--
>   tools/testing/selftests/kselftest_harness.h | 2 +-
>   tools/testing/selftests/lib.mk              | 2 +-
>   3 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
> index e1504833654d..ed012a7f0786 100644
> --- a/tools/testing/selftests/Makefile
> +++ b/tools/testing/selftests/Makefile
> @@ -161,11 +161,11 @@ ifneq ($(KBUILD_OUTPUT),)
>     # $(realpath ...) resolves symlinks
>     abs_objtree := $(realpath $(abs_objtree))
>     BUILD := $(abs_objtree)/kselftest
> -  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
> +  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_objtree}/usr/include
>   else
>     BUILD := $(CURDIR)
>     abs_srctree := $(shell cd $(top_srcdir) && pwd)
> -  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
> +  KHDR_INCLUDES := -D_GNU_SOURCE -isystem ${abs_srctree}/usr/include
>     DEFAULT_INSTALL_HDR_PATH := 1
>   endif

Just a small copy-paste duplication request: can we maybe do it this
way, instead, to remove the duplication? It's small *so far*, but
still. :)

diff --git a/tools/testing/selftests/Makefile b/tools/testing/selftests/Makefile
index e1504833654d..13a5b11db59a 100644
--- a/tools/testing/selftests/Makefile
+++ b/tools/testing/selftests/Makefile
@@ -152,6 +152,8 @@ ifeq ("$(origin O)", "command line")
    KBUILD_OUTPUT := $(O)
  endif
  
+KHDR_INCLUDES := -D_GNU_SOURCE
+
  ifneq ($(KBUILD_OUTPUT),)
    # Make's built-in functions such as $(abspath ...), $(realpath ...) cannot
    # expand a shell special character '~'. We use a somewhat tedious way here.
@@ -161,11 +163,11 @@ ifneq ($(KBUILD_OUTPUT),)
    # $(realpath ...) resolves symlinks
    abs_objtree := $(realpath $(abs_objtree))
    BUILD := $(abs_objtree)/kselftest
-  KHDR_INCLUDES := -isystem ${abs_objtree}/usr/include
+  KHDR_INCLUDES += -isystem ${abs_objtree}/usr/include
  else
    BUILD := $(CURDIR)
    abs_srctree := $(shell cd $(top_srcdir) && pwd)
-  KHDR_INCLUDES := -isystem ${abs_srctree}/usr/include
+  KHDR_INCLUDES += -isystem ${abs_srctree}/usr/include
    DEFAULT_INSTALL_HDR_PATH := 1
  endif


>   
> diff --git a/tools/testing/selftests/kselftest_harness.h b/tools/testing/selftests/kselftest_harness.h
> index d98702b6955d..b2a1b6343896 100644
> --- a/tools/testing/selftests/kselftest_harness.h
> +++ b/tools/testing/selftests/kselftest_harness.h
> @@ -51,7 +51,7 @@
>   #define __KSELFTEST_HARNESS_H
>   
>   #ifndef _GNU_SOURCE
> -#define _GNU_SOURCE
> +static_assert(0, "kselftest harness requires _GNU_SOURCE to be defined");
>   #endif
>   #include <asm/types.h>
>   #include <ctype.h>
> diff --git a/tools/testing/selftests/lib.mk b/tools/testing/selftests/lib.mk
> index da2cade3bab0..2503dc732b4d 100644
> --- a/tools/testing/selftests/lib.mk
> +++ b/tools/testing/selftests/lib.mk
> @@ -45,7 +45,7 @@ selfdir = $(realpath $(dir $(filter %/lib.mk,$(MAKEFILE_LIST))))
>   top_srcdir = $(selfdir)/../../..
>   
>   ifeq ($(KHDR_INCLUDES),)
> -KHDR_INCLUDES := -isystem $(top_srcdir)/usr/include
> +KHDR_INCLUDES := -D_GNU_SOURCE -isystem $(top_srcdir)/usr/include
>   endif
>   
>   # The following are built by lib.mk common compile rules.

The rest looks good. And whether you accept my recommendation above,
or not, either way this patch looks good, so please feel free to add:

Reviewed-by: John Hubbard <jhubbard@...dia.com>


thanks,
-- 
John Hubbard
NVIDIA


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ