Skip to contentSkip to conversation

file: explicitly disable seccomp

PATCH In review Ross Burton 5 participants 13 messages Oct 18, 2019 – Apr 3, 2020

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 file: explicitly disable seccomp

file will automatically enable seccomp if the seccomp headers are available, but the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing build failures), so explicitly and globally disable seccomp.

---
 meta/recipes-devtools/file/file_5.37.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +2 -0
index a840dbc012b..c53a120b840 100644
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
 inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+
 ALTERNATIVE_${PN} = "file"
 ALTERNATIVE_LINK_NAME[file] = "${bindir}/file"
 
Signature · 1 line
2.20.1
#1 lore raw
Quoted 20 lines · Ross Burton

file will automatically enable seccomp if the seccomp headers are available, but
the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing
build failures), so explicitly and globally disable seccomp.

---
 meta/recipes-devtools/file/file_5.37.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +0 -0
index a840dbc012b..c53a120b840 100644

meta/recipes-devtools/file/file_5.37.bb S = "${WORKDIR}/git" · line 25

Quoted 5 lines
meta/recipes-devtools/file/file_5.37.bb +2 -0
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
 inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+

On host it makes sense but how about for target recipe ? We do have libseccomp support
Perhaps it’s best to disable it for native and native sdk alone ?

Quoted 13 lines
meta/recipes-devtools/file/file_5.37.bb +0 -1
 ALTERNATIVE_${PN} = "file"
 ALTERNATIVE_LINK_NAME[file] = "${bindir}/file"
 
--

2.20.1

--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core

#2 lore raw
Quoted 25 lines · Khem Raj
Quoted 21 lines · Ross Burton

file will automatically enable seccomp if the seccomp headers are available, but
the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing
build failures), so explicitly and globally disable seccomp.

---
 meta/recipes-devtools/file/file_5.37.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +0 -0
index a840dbc012b..c53a120b840 100644
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
Quoted 8 lines

meta/recipes-devtools/file/file_5.37.bb S = "${WORKDIR}/git" · line 25

Quoted 4 lines
meta/recipes-devtools/file/file_5.37.bb +2 -0
 inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+

On host it makes sense but how about for target recipe ? We do have libseccomp support
Perhaps it’s best to disable it for native and native sdk alone ?

Given the problem reports in the media and the decisions made by most other distros I think disabling this is probably safest until its been make more usable (no other distro is shipping this enabled now).

Cheers,

Richard

#3 lore raw
Quoted 35 lines · Richard Purdie
Quoted 25 lines · Khem Raj
Quoted 21 lines · Ross Burton

file will automatically enable seccomp if the seccomp headers are available, but
the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing
build failures), so explicitly and globally disable seccomp.

---
 meta/recipes-devtools/file/file_5.37.bb | 2 ++
 1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +0 -0
index a840dbc012b..c53a120b840 100644
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
Quoted 8 lines

meta/recipes-devtools/file/file_5.37.bb S = "${WORKDIR}/git" · line 25

Quoted 4 lines
meta/recipes-devtools/file/file_5.37.bb +2 -0
 inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+

On host it makes sense but how about for target recipe ? We do have libseccomp support
Perhaps it’s best to disable it for native and native sdk alone ?

Quoted 4 lines

Given the problem reports in the media and the decisions made by most other distros I think disabling this is probably safest until its been make more usable (no other distro is shipping this enabled now).

Ok makes sense

Quoted 9 lines

Cheers,

Richard

#4 lore raw
In reply to Richard Purdie
Quoted 35 lines · Richard Purdie
Quoted 25 lines · Khem Raj
Quoted 21 lines · Ross Burton

file will automatically enable seccomp if the seccomp headers are available, but
the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing
build failures), so explicitly and globally disable seccomp.

---
  meta/recipes-devtools/file/file_5.37.bb | 2 ++
  1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +0 -0
index a840dbc012b..c53a120b840 100644
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
Quoted 8 lines

meta/recipes-devtools/file/file_5.37.bb S = "${WORKDIR}/git" · line 25

Quoted 4 lines
meta/recipes-devtools/file/file_5.37.bb +2 -0
  inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+

On host it makes sense but how about for target recipe ? We do have libseccomp support
Perhaps it’s best to disable it for native and native sdk alone ?

Quoted 3 lines

Given the problem reports in the media and the decisions made by most other distros I think disabling this is probably safest until its been make more usable (no other distro is shipping this enabled now).

Arch Linux enabled libseccomp as of today:

https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/file&id=a52fa0a37bad1f4ab67a934a4e0025e70aa1fd0e

This breaks the use of file in do_package():

ERROR: base-files-3.0.14-r89 do_package: Fatal errors occurred in subprocesses:

Command '['file', '-b', '/home/martin/clients/connectedcars/yocto/build/tmp-glibc/work/iwg26-oe-linux-gnueabi/base-files/3.0.14-r89/package/etc/skel/.profile']' died with <Signals.SIGSYS: 31>.: Traceback (most recent call last):

File
"/home/martin/clients/connectedcars/yocto/poky/meta/lib/oe/utils.py", line 272, in run

    ret = self._target(*self._args, **self._kwargs)

File
"/home/martin/clients/connectedcars/yocto/poky/meta/lib/oe/package.py", line 70, in is_elf

    result = subprocess.check_output(["file", "-b", path], 

stderr=subprocess.STDOUT).decode("utf-8")

File "/usr/lib/python3.8/subprocess.py", line 411, in check_output

return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,

File "/usr/lib/python3.8/subprocess.py", line 512, in run

raise CalledProcessError(retcode, process.args,

subprocess.CalledProcessError: Command '['file', '-b', '/home/martin/clients/connectedcars/yocto/build/tmp-glibc/work/iwg26-oe-linux-gnueabi/base-files/3.0.14-r89/package/etc/skel/.profile']' died with <Signals.SIGSYS: 31>.

Disabling libseccomp sandboxing at runtime fixes it for me:

meta/lib/oe/package.py +0 -0

index efd36b3758..bc46d7c27c 100644

--- a/meta/lib/oe/package.py

+++ b/meta/lib/oe/package.py

@@ -67,7 +67,7 @@ def is_kernel_module_signed(path):

# 16 - kernel module

def is_elf(path):

exec_type = 0

- result = subprocess.check_output(["file", "-b", path], stderr=subprocess.STDOUT).decode("utf-8")

+ result = subprocess.check_output(["file", "-S", "-b", path], stderr=subprocess.STDOUT).decode("utf-8")

if "ELF" in result:

exec_type |= 1

#5 lore raw
Quoted 101 lines · Martin Hundebøll
Quoted 35 lines · Richard Purdie
Quoted 25 lines · Khem Raj
Quoted 21 lines · Ross Burton

file will automatically enable seccomp if the seccomp headers are available, but
the build will fail on Opensuse Tumbleweed because the include paths are wrong.

Enabling seccomp is a bad idea because it interacts badly with pseudo (causing
build failures), so explicitly and globally disable seccomp.

---
  meta/recipes-devtools/file/file_5.37.bb | 2 ++
  1 file changed, 2 insertions(+)
meta/recipes-devtools/file/file_5.37.bb +0 -0
index a840dbc012b..c53a120b840 100644
@@ -21,6 +21,8 @@ S = "${WORKDIR}/git"
 
Quoted 8 lines

meta/recipes-devtools/file/file_5.37.bb S = "${WORKDIR}/git" · line 25

Quoted 4 lines
meta/recipes-devtools/file/file_5.37.bb +2 -0
  inherit autotools update-alternatives
 
+EXTRA_OECONF += "--disable-libseccomp"
+

On host it makes sense but how about for target recipe ? We do have libseccomp support
Perhaps it’s best to disable it for native and native sdk alone ?

Quoted 3 lines

Given the problem reports in the media and the decisions made by most other distros I think disabling this is probably safest until its been make more usable (no other distro is shipping this enabled now).

Arch Linux enabled libseccomp as of today:

https://git.archlinux.org/svntogit/packages.git/commit/trunk?h=packages/file&id=a52fa0a37bad1f4ab67a934a4e0025e70aa1fd0e

This breaks the use of file in do_package():

ERROR: base-files-3.0.14-r89 do_package: Fatal errors occurred in subprocesses:

Command '['file', '-b', '/home/martin/clients/connectedcars/yocto/build/tmp-glibc/work/iwg26-oe-linux-gnueabi/base-files/3.0.14-r89/package/etc/skel/.profile']' died with <Signals.SIGSYS: 31>.: Traceback (most recent call last):

File
"/home/martin/clients/connectedcars/yocto/poky/meta/lib/oe/utils.py", line 272, in run

     ret = self._target(*self._args, **self._kwargs)

File
"/home/martin/clients/connectedcars/yocto/poky/meta/lib/oe/package.py", line 70, in is_elf

     result = subprocess.check_output(["file", "-b", path],

stderr=subprocess.STDOUT).decode("utf-8")

File "/usr/lib/python3.8/subprocess.py", line 411, in check_output

return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,

File "/usr/lib/python3.8/subprocess.py", line 512, in run

raise CalledProcessError(retcode, process.args,

subprocess.CalledProcessError: Command '['file', '-b', '/home/martin/clients/connectedcars/yocto/build/tmp-glibc/work/iwg26-oe-linux-gnueabi/base-files/3.0.14-r89/package/etc/skel/.profile']' died with <Signals.SIGSYS: 31>.

Disabling libseccomp sandboxing at runtime fixes it for me:

meta/lib/oe/package.py +0 -0

index efd36b3758..bc46d7c27c 100644

--- a/meta/lib/oe/package.py

+++ b/meta/lib/oe/package.py

meta/lib/oe/package.py +0 -1
@@ -67,7 +67,7 @@ def is_kernel_module_signed(path):
 
  # 16 - kernel module
 
  def is_elf(path):
 
      exec_type = 0
 
-    result = subprocess.check_output(["file", "-b", path],

stderr=subprocess.STDOUT).decode("utf-8")

Quoted 3 lines

+ result = subprocess.check_output(["file", "-S", "-b", path],
stderr=subprocess.STDOUT).decode("utf-8")

pseudo needs some love since it alters syscalls which go out of bounds what is allowed by libseccomp until then pin your file version to 5.37 in arch till a supported distro is affected by same problem. It wont be long better option is to fix pseudo

Quoted 7 lines

if "ELF" in result:

exec_type |= 1

#6 lore raw
Quoted 4 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds what is allowed by libseccomp until then pin your file version to 5.37 in arch till a supported distro is affected by same problem. It wont be long better option is to fix pseudo

That's not quite right. pseudo LD_PRELOADs itself into file, and makes syscalls which are not whitelisted in file's seccomp configuration.

There's nothing pseudo can do to solve this.

Ross

#7 lore raw
Quoted 9 lines · Ross Burton
Quoted 4 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds what is allowed by libseccomp until then pin your file version to 5.37 in arch till a supported distro is affected by same problem. It wont be long better option is to fix pseudo

That's not quite right. pseudo LD_PRELOADs itself into file, and makes syscalls which are not whitelisted in file's seccomp configuration.

It’s is not different than what I was saying how it inserts itself into process is a detail which is hidden from operating system

However I think file is only one case when used along with libseccomp there could be more use cases if other host tools we use start using it

So I wonder If we should start building own native versions of tools or make it part of build tools tarball
Or perhaps just publish a self built container and not worry about what distros are doing underneath

Quoted 5 lines

There's nothing pseudo can do to solve this.

Ross

#8 lore raw
In reply to Ross Burton

Hi,

Quoted 10 lines · Ross Burton
Quoted 4 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds what is allowed by libseccomp until then pin your file version to 5.37 in arch till a supported distro is affected by same problem. It wont be long better option is to fix pseudo

That's not quite right. pseudo LD_PRELOADs itself into file, and makes syscalls which are not whitelisted in file's seccomp configuration.

There's nothing pseudo can do to solve this.

I stumbled across this thread when checking why libseccomp is not in oe-core or meta-oe. It seems to me that pseudo could intercept the seccomp(2) or libseccomps seccomp_* function calls and report them as unsupported to simulate running on a kernel without seccomp support.

What am I missing? :)

Regards,
Jan

#9 lore raw
Quoted 16 lines · Jan Luebbe

Hi,

Quoted 13 lines · Ross Burton
Quoted 7 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds
what is allowed by libseccomp until then pin your file version to 5.37
in arch till a supported distro is affected by same problem. It wont
be long better option is to fix pseudo

That's not quite right. pseudo LD_PRELOADs itself into file, and makes
syscalls which are not whitelisted in file's seccomp configuration.

Quoted 8 lines
Quoted 1 line

There's nothing pseudo can do to solve this.

I stumbled across this thread when checking why libseccomp is not in oe-core or meta-oe. It seems to me that pseudo could intercept the seccomp(2) or libseccomps seccomp_* function calls and report them as unsupported to simulate running on a kernel without seccomp support.

What am I missing? :)

I don't think we'd thought of that, I like the idea in principle...

Cheers,

Richard

#10 lore raw
In reply to Jan Luebbe
Quoted 16 lines · Jan Luebbe

Hi,

Quoted 13 lines · Ross Burton
Quoted 7 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds
what is allowed by libseccomp until then pin your file version to 5.37
in arch till a supported distro is affected by same problem. It wont
be long better option is to fix pseudo

That's not quite right. pseudo LD_PRELOADs itself into file, and makes
syscalls which are not whitelisted in file's seccomp configuration.

Quoted 8 lines
Quoted 1 line

There's nothing pseudo can do to solve this.

I stumbled across this thread when checking why libseccomp is not in oe-core or meta-oe. It seems to me that pseudo could intercept the seccomp(2) or libseccomps seccomp_* function calls and report them as unsupported to simulate running on a kernel without seccomp support.

What am I missing? :)

I made a guess at a patch:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rpurdie/t222&id=d675ff53d3ccbc6bd7db5f067d331bf3f94de5cd

Just need someone with a system that can test it now!

Cheers,

Richard

#11 lore raw
Quoted 25 lines · Richard Purdie
Quoted 23 lines · Jan Luebbe

Hi,

Quoted 9 lines · Ross Burton
Quoted 7 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds
what is allowed by libseccomp until then pin your file version to 5.37
in arch till a supported distro is affected by same problem. It wont
be long better option is to fix pseudo

Quoted 5 lines

That's not quite right. pseudo LD_PRELOADs itself into file, and makes
syscalls which are not whitelisted in file's seccomp configuration.

There's nothing pseudo can do to solve this.

I stumbled across this thread when checking why libseccomp is not in oe-core or meta-oe. It seems to me that pseudo could intercept the seccomp(2) or libseccomps seccomp_* function calls and report them as unsupported to simulate running on a kernel without seccomp support.

Quoted 8 lines
Quoted 1 line

What am I missing? :)

I made a guess at a patch:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rpurdie/t222&id=d675ff53d3ccbc6bd7db5f067d331bf3f94de5cd

Just need someone with a system that can test it now!

seems pseudo still has same issue with archlinux latest file (file-5.38-3) utility

Command '['file', '-b', '/mnt/b/yoe/build/tmp/work/aarch64-yoe-linux/glibc/2.31+gitAUTOINC+71f2b249a2-r0/package/lib/libnss_db-2.31.so']' died with <Signals.SIGSYS: 31>.: Traceback (most recent call last):
File "/mnt/b/yoe/sources/openembedded-core/meta/lib/oe/utils.py",
line 280, in run

    ret = self._target(*self._args, **self._kwargs)
  File "/mnt/b/yoe/sources/openembedded-core/meta/lib/oe/package.py",
line 74, in is_elf
    result = subprocess.check_output(["file", "-b", path],

stderr=subprocess.STDOUT).decode("utf-8")
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,

Quoted 4 lines

Cheers,

Richard

#12 lore raw
Quoted 47 lines · Khem Raj
Quoted 24 lines · Richard Purdie
Quoted 23 lines · Jan Luebbe

Hi,

Quoted 9 lines · Ross Burton
Quoted 7 lines · Khem Raj

pseudo needs some love since it alters syscalls which go out of bounds
what is allowed by libseccomp until then pin your file version to 5.37
in arch till a supported distro is affected by same problem. It wont
be long better option is to fix pseudo

Quoted 5 lines

That's not quite right. pseudo LD_PRELOADs itself into file, and makes
syscalls which are not whitelisted in file's seccomp configuration.

There's nothing pseudo can do to solve this.

I stumbled across this thread when checking why libseccomp is not in oe-core or meta-oe. It seems to me that pseudo could intercept the seccomp(2) or libseccomps seccomp_* function calls and report them as unsupported to simulate running on a kernel without seccomp support.

Quoted 8 lines
Quoted 1 line

What am I missing? :)

I made a guess at a patch:

http://git.yoctoproject.org/cgit.cgi/poky-contrib/commit/?h=rpurdie/t222&id=d675ff53d3ccbc6bd7db5f067d331bf3f94de5cd

Just need someone with a system that can test it now!

seems pseudo still has same issue with archlinux latest file (file-5.38-3) utility

Command '['file', '-b', '/mnt/b/yoe/build/tmp/work/aarch64-yoe-linux/glibc/2.31+gitAUTOINC+71f2b249a2-r0/package/lib/libnss_db-2.31.so']' died with <Signals.SIGSYS: 31>.: Traceback (most recent call last):
File "/mnt/b/yoe/sources/openembedded-core/meta/lib/oe/utils.py",
line 280, in run

    ret = self._target(*self._args, **self._kwargs)
  File "/mnt/b/yoe/sources/openembedded-core/meta/lib/oe/package.py",
line 74, in is_elf
    result = subprocess.check_output(["file", "-b", path],
Quoted 5 lines

stderr=subprocess.STDOUT).decode("utf-8")
File "/usr/lib/python3.8/subprocess.py", line 411, in check_output
return run(*popenargs, stdout=PIPE, timeout=timeout, check=True,
File "/usr/lib/python3.8/subprocess.py", line 512, in run
raise CalledProcessError(retcode, process.args,

There is a pretty horrendous hack in master-next which avoids this (I think). I went through the following:

a) Disabling seccomp syscall. It falls back to prctl().

b) Disabling prctl() (which is variadac) means file exits with an error, seccomp must be enabled.

c) Return success but do nothing (don't load the seccomp program)

It appears that returning success works.

Not convinced we want to do that mind...

Cheers,

Richard