Skip to contentSkip to conversation

Kbuild: Ignore GREP_OPTIONS env variable

PATCH In review Borislav Petkov 3 participants 6 messages Oct 30, 2013 – Nov 11, 2013 Kbuild

lore
Share & tools
lore
#0 lore raw

Hi,

this is just a general poll of what people think about the issue here, just so that at least we've talked about it.

So I had defined GREP_OPTIONS=--color=always on one of my boxes and had forgotten about it and the kernel build started failing because we use grep quite a while in the tree and it started issuing shell color markup which generated garbage files, like the syscall headers on x86, for example.

I have a fix below which seems to take care of it but what is the general opinion: Do we want to be more robust against the environment we find on a machine before building the kernel or let the user figure it out himself that he should be using

GREP_OPTIONS=--color=auto

in the first place and it is his own moronic fault if he does 'always'?

Opinions, comments?

Thanks.

--
From: Borislav Petkov <[email protected]>
Subject: [PATCH] Kbuild: Ignore GREP_OPTIONS env variable
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

When building the kernel in a shell which defines GREP_OPTIONS so that grep behavior is modified, we can break the generation of the syscalls table like so:

__SYSCALL_COMMON(0, sys_read, sys_read) __SYSCALL_COMMON(1, sys_write, sys_write) __SYSCALL_COMMON(10, sys_mprotect, sys_mprotect) ...

This is just the initial breakage, later we barf when generating modules.

In this case, GREP_OPTIONS contains "--color=always" which adds the shell colors markup and completely fudges the headers under ...generated/asm/.

Fix that by ignoring the GREP_OPTIONS variable for the whole kernel build as we tend to use grep at a bunch of places.

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index 868c0eb67b08..7a2acd9a5d1c 100644
@@ -16,6 +16,9 @@ NAME = One Giant Leap for Frogkind
 # o  print "Entering directory ...";
 MAKEFLAGS += -rR --no-print-directory
 
+GREP_OPTIONS=
+export GREP_OPTIONS
+
 # Avoid funny character set dependencies
 unexport LC_ALL
 LC_COLLATE=C
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#1 lore raw

Dne 30.10.2013 17:06, Borislav Petkov napsal(a):

Quoted 6 lines

So I had defined GREP_OPTIONS=--color=always on one of my boxes and had forgotten about it and the kernel build started failing because we use grep quite a while in the tree and it started issuing shell color markup which generated garbage files, like the syscall headers on x86, for example.

Quoted 8 lines

I have a fix below which seems to take care of it but what is the general opinion: Do we want to be more robust against the environment we find on a machine before building the kernel or let the user figure it out himself that he should be using

GREP_OPTIONS=--color=auto

in the first place and it is his own moronic fault if he does 'always'?

I think that on a scale from one to ten, building with GREP_OPTIONS=--color=always and building with LC_COLLATE=<language with non-ASCII sorting rules> score about the same. And are already sanitizing the LC_* variables.

Makefile NAME = One Giant Leap for Frogkind · line 20

Quoted 2 lines
Makefile +2 -0
+GREP_OPTIONS=
+export GREP_OPTIONS

Just remove it from the enviromnet completely, like the next statement does:

Quoted 4 lines

+
# Avoid funny character set dependencies
unexport LC_ALL
LC_COLLATE=C

Michal

#2 lore raw

PATCH 1/1 Kbuild: Ignore GREP_OPTIONS env variable

From: Borislav Petkov <[email protected]>
Subject: [PATCH] Kbuild: Ignore GREP_OPTIONS env variable

When building the kernel in a shell which defines GREP_OPTIONS so that grep behavior is modified, we can break the generation of the syscalls table like so:

__SYSCALL_COMMON(0, sys_read, sys_read) __SYSCALL_COMMON(1, sys_write, sys_write) __SYSCALL_COMMON(10, sys_mprotect, sys_mprotect) ...

This is just the initial breakage, later we barf when generating modules.

In this case, GREP_OPTIONS contains "--color=always" which adds the shell colors markup and completely fudges the headers under ...generated/asm/.

Fix that by unexporting the GREP_OPTIONS variable for the whole kernel build as we tend to use grep at a bunch of places.

---
 Makefile | 3 +++
 1 file changed, 3 insertions(+)
Makefile +3 -0
index 868c0eb67b08..73503a7755fd 100644
@@ -22,6 +22,9 @@ LC_COLLATE=C
 LC_NUMERIC=C
 export LC_COLLATE LC_NUMERIC
 
+# Avoid interference with shell env settings
+unexport GREP_OPTIONS
+
 # We are using a recursive build, so we need to do a little thinking
 # to get the ordering right.
 #
Signature · 8 lines
1.8.4

-- 
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--
#3 lore raw
Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>
Subject: [PATCH] Kbuild: Ignore GREP_OPTIONS env variable

When building the kernel in a shell which defines GREP_OPTIONS so that grep behavior is modified, we can break the generation of the syscalls table like so:

__SYSCALL_COMMON(0, sys_read, sys_read) __SYSCALL_COMMON(1, sys_write, sys_write) __SYSCALL_COMMON(10, sys_mprotect, sys_mprotect) ...

The email had literal escape sequences and git am preserved them, so git show displayed red zeros and onces. That was quite scary, so I replaced the escape character with ^[.

Anyway, applied to kbuild.git#kbuild now.

Michal

#4 lore raw
Quoted 8 lines · Michal Marek
Quoted 7 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>
Subject: [PATCH] Kbuild: Ignore GREP_OPTIONS env variable

When building the kernel in a shell which defines GREP_OPTIONS so that grep behavior is modified, we can break the generation of the syscalls table like so:

Quoted 6 lines
Quoted 3 lines

__SYSCALL_COMMON(0, sys_read, sys_read) __SYSCALL_COMMON(1, sys_write, sys_write) __SYSCALL_COMMON(10, sys_mprotect, sys_mprotect) ...

The email had literal escape sequences and git am preserved them, so git show displayed red zeros and onces. [..]

Neat trick if it was intentionally!

Quoted 1 line

[...] That was quite scary, [...]

Scary if it was unintentional ;-)

Thanks,

Ingo

#5 lore raw
Quoted 13 lines · Ingo Molnar
Quoted 12 lines · Michal Marek
Quoted 10 lines · Borislav Petkov

From: Borislav Petkov <[email protected]>
Subject: [PATCH] Kbuild: Ignore GREP_OPTIONS env variable

When building the kernel in a shell which defines GREP_OPTIONS so that grep behavior is modified, we can break the generation of the syscalls table like so:

__SYSCALL_COMMON(0, sys_read, sys_read) __SYSCALL_COMMON(1, sys_write, sys_write) __SYSCALL_COMMON(10, sys_mprotect, sys_mprotect) ...

Quoted 8 lines
Quoted 2 lines

The email had literal escape sequences and git am preserved them, so git show displayed red zeros and onces. [..]

Neat trick if it was intentionally!

Quoted 1 line

[...] That was quite scary, [...]

Scary if it was unintentional ;-)

Yeah, all our computers are bleeding :-) Well, I sent the first version on the evening before Helloween...

<scary music playing, an old door is creaking...>

Signature · 5 lines
Regards/Gruss,
    Boris.

Sent from a fat crate under my desk. Formatting is fine.
--