Skip to contentSkip to conversation

scripts: headers_install: Exit with error on config leak

PATCH Superseded Siddharth Gupta 2 participants 3 messages May 3, 2020 – May 6, 2020

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 scripts: headers_install: Exit with error on config leak

Misuse of CONFIG_* in UAPI headers should result in an error as it exposes configuration of different targets to userspace.

---
 scripts/headers_install.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/headers_install.sh +6 -5
index a07668a..94a8335 100755
@@ -64,7 +64,7 @@ configs=$(sed -e '
 	d
 ' $OUTFILE)
 
-# The entries in the following list are not warned.
+# The entries in the following list do not result in an error.
 # Please do not add a new entry. This list is only for existing ones.
 # The list will be reduced gradually, and deleted eventually. (hopefully)
 #
@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
 
 for c in $configs
 do
-	warn=1
+	leak_error=1
 
 	for ignore in $config_leak_ignores
 	do
 		if echo "$INFILE:$c" | grep -q "$ignore$"; then
-			warn=
+			leak_error=
 			break
 		fi
 	done
 
-	if [ "$warn" = 1 ]; then
-		echo "warning: $INFILE: leak $c to user-space" >&2
+	if [ "$leak_error" = 1 ]; then
+		echo "error: $INFILE: leak $c to user-space" >&2
+		exit 1
 	fi
 done
 
Signature · 2 lines
Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw
Quoted 3 lines · Siddharth Gupta

Misuse of CONFIG_* in UAPI headers should result in an error as it exposes configuration of different targets to userspace.

Sorry, I missed to point out this.

This statement is not precious; it does not expose the kernel configuration at all.

include/generated/autoconf.h is not available from userspace. So, all the CONFIG options are undefined.

Could you reword the commit somehow?

Quoted 46 lines
---
 scripts/headers_install.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)
scripts/headers_install.sh +6 -6
index a07668a..94a8335 100755
@@ -64,7 +64,7 @@ configs=$(sed -e '
        d
 ' $OUTFILE)
 
-# The entries in the following list are not warned.
+# The entries in the following list do not result in an error.
 # Please do not add a new entry. This list is only for existing ones.
 # The list will be reduced gradually, and deleted eventually. (hopefully)
 #
@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
 
 for c in $configs
 do
-       warn=1
+       leak_error=1
 
        for ignore in $config_leak_ignores
        do
                if echo "$INFILE:$c" | grep -q "$ignore$"; then
-                       warn=
+                       leak_error=
                        break
                fi
        done
 
-       if [ "$warn" = 1 ]; then
-               echo "warning: $INFILE: leak $c to user-space" >&2
+       if [ "$leak_error" = 1 ]; then
+               echo "error: $INFILE: leak $c to user-space" >&2
+               exit 1
        fi
 done
 
--

Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project

Signature · 2 lines
Best Regards
Masahiro Yamada
#2 lore raw
Quoted 6 lines · Masahiro Yamada
Quoted 2 lines · Siddharth Gupta

Misuse of CONFIG_* in UAPI headers should result in an error as it exposes configuration of different targets to userspace.

Sorry, I missed to point out this.

Quoted 8 lines

This statement is not precious; it does not expose the kernel configuration at all.

include/generated/autoconf.h is not available from userspace. So, all the CONFIG options are undefined.

Could you reword the commit somehow?

Sure. I just meant that if a CONFIG_* is present in the UAPI header it can be set in a userspace application that includes the header to manipulate the control flow in a kernel that might support multiple targets.

I'll update the commit text and send out an updated patch.

Thanks,
Siddharth

Quoted 50 lines
Quoted 48 lines
---
  scripts/headers_install.sh | 11 ++++++-----
  1 file changed, 6 insertions(+), 5 deletions(-)
scripts/headers_install.sh +6 -6
index a07668a..94a8335 100755
@@ -64,7 +64,7 @@ configs=$(sed -e '
         d
  ' $OUTFILE)
 
-# The entries in the following list are not warned.
+# The entries in the following list do not result in an error.
  # Please do not add a new entry. This list is only for existing ones.
  # The list will be reduced gradually, and deleted eventually. (hopefully)
  #
@@ -98,18 +98,19 @@ include/uapi/linux/raw.h:CONFIG_MAX_RAW_DEVS
 
  for c in $configs
  do
-       warn=1
+       leak_error=1
 
         for ignore in $config_leak_ignores
         do
                 if echo "$INFILE:$c" | grep -q "$ignore$"; then
-                       warn=
+                       leak_error=
                         break
                 fi
         done
 
-       if [ "$warn" = 1 ]; then
-               echo "warning: $INFILE: leak $c to user-space" >&2
+       if [ "$leak_error" = 1 ]; then
+               echo "error: $INFILE: leak $c to user-space" >&2
+               exit 1
         fi
  done
 
--

Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project