public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] scripts: headers_install: Exit with error on config leak
@ 2020-05-03  3:29 Siddharth Gupta
  2020-05-04  7:18 ` Masahiro Yamada
  0 siblings, 1 reply; 3+ messages in thread
From: Siddharth Gupta @ 2020-05-03  3:29 UTC (permalink / raw)
  To: Masahiro Yamada, Sam Ravnborg; +Cc: Siddharth Gupta, linux-kernel

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

Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
---
 scripts/headers_install.sh | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
index a07668a..94a8335 100755
--- a/scripts/headers_install.sh
+++ b/scripts/headers_install.sh
@@ -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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scripts: headers_install: Exit with error on config leak
  2020-05-03  3:29 [PATCH v2] scripts: headers_install: Exit with error on config leak Siddharth Gupta
@ 2020-05-04  7:18 ` Masahiro Yamada
  2020-05-06  1:45   ` Siddharth Gupta
  0 siblings, 1 reply; 3+ messages in thread
From: Masahiro Yamada @ 2020-05-04  7:18 UTC (permalink / raw)
  To: Siddharth Gupta; +Cc: Sam Ravnborg, Linux Kernel Mailing List

On Sun, May 3, 2020 at 12:29 PM Siddharth Gupta <sidgup@codeaurora.org> wrote:
>
> 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?





>
> Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
> ---
>  scripts/headers_install.sh | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
> index a07668a..94a8335 100755
> --- a/scripts/headers_install.sh
> +++ b/scripts/headers_install.sh
> @@ -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



-- 
Best Regards
Masahiro Yamada

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] scripts: headers_install: Exit with error on config leak
  2020-05-04  7:18 ` Masahiro Yamada
@ 2020-05-06  1:45   ` Siddharth Gupta
  0 siblings, 0 replies; 3+ messages in thread
From: Siddharth Gupta @ 2020-05-06  1:45 UTC (permalink / raw)
  To: Masahiro Yamada; +Cc: Sam Ravnborg, Linux Kernel Mailing List


On 5/4/2020 12:18 AM, Masahiro Yamada wrote:
> On Sun, May 3, 2020 at 12:29 PM Siddharth Gupta <sidgup@codeaurora.org> wrote:
>> 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?
>
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

>
>
>
>> Signed-off-by: Siddharth Gupta <sidgup@codeaurora.org>
>> ---
>>   scripts/headers_install.sh | 11 ++++++-----
>>   1 file changed, 6 insertions(+), 5 deletions(-)
>>
>> diff --git a/scripts/headers_install.sh b/scripts/headers_install.sh
>> index a07668a..94a8335 100755
>> --- a/scripts/headers_install.sh
>> +++ b/scripts/headers_install.sh
>> @@ -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
>
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-05-06  1:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-03  3:29 [PATCH v2] scripts: headers_install: Exit with error on config leak Siddharth Gupta
2020-05-04  7:18 ` Masahiro Yamada
2020-05-06  1:45   ` Siddharth Gupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox