Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFE: export filter in a C header file format #15

Open
pcmoore opened this issue Aug 28, 2015 · 3 comments
Open

RFE: export filter in a C header file format #15

pcmoore opened this issue Aug 28, 2015 · 3 comments

Comments

@pcmoore
Copy link
Member

pcmoore commented Aug 28, 2015

Add functionality to export the seccomp BPF filter in a C header file format suitable for including in a project. Ideally the generated C header would include the filter loading function which would handle the prcrtl()/seccomp() call as well as any NNP settings as defined by the filter.

Proposed new libseccomp API:

API int seccomp_export_chdr(const scmp_filter_ctx ctx, int fd);
@pcmoore pcmoore self-assigned this Aug 28, 2015
@pcmoore pcmoore modified the milestone: v2.4 Feb 15, 2016
@pcmoore pcmoore removed this from the v2.4 milestone Jan 18, 2018
@pcmoore pcmoore added this to the v2.5 milestone Jan 28, 2018
@pcmoore pcmoore modified the milestones: v2.5, v2.6 Aug 26, 2019
pcmoore added a commit to pcmoore/misc-libseccomp that referenced this issue Nov 5, 2019
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test seccomp#15.

Signed-off-by: Paul Moore <[email protected]>
pcmoore added a commit to pcmoore/misc-libseccomp that referenced this issue Nov 6, 2019
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test seccomp#15.

Signed-off-by: Paul Moore <[email protected]>
pcmoore added a commit that referenced this issue Nov 14, 2019
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test #15.

Signed-off-by: Paul Moore <[email protected]>
pcmoore added a commit that referenced this issue Nov 20, 2019
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test #15.

Acked-by: Tom Hromatka <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
drakenclimber pushed a commit to drakenclimber/libseccomp that referenced this issue Jan 27, 2020
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test seccomp#15.

Acked-by: Tom Hromatka <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
(cherry picked from commit 1ecdddb)
Signed-off-by: Tom Hromatka <[email protected]>
drakenclimber pushed a commit to drakenclimber/libseccomp that referenced this issue Feb 3, 2020
We recently changed how libseccomp handles syscall numbers that are
not defined natively, but we missed test seccomp#15.

Acked-by: Tom Hromatka <[email protected]>
Signed-off-by: Paul Moore <[email protected]>
(cherry picked from commit 1ecdddb)
Signed-off-by: Tom Hromatka <[email protected]>
Acked-by: Paul Moore <[email protected]>
@pcmoore
Copy link
Member Author

pcmoore commented Oct 12, 2021

Related: #342

Building upon the strawman API for exporting the filter in original issue description, my thinking is that the generated header file would include a int seccomp_load_chdr(void) function which the application would call to do the necessary settings, e.g. NNP, and load the filter.

@vapier
Copy link
Contributor

vapier commented Oct 13, 2021

how would one handle multiple programs in a single project ? for example, i want to generate two filters and then select between them based on runtime settings -- if i know i need to fork a helper, i'll load one filter, but if i don't need that, i'll load a smaller filter. if we only ever defined seccomp_load_chdr, it wouldn't be easy to utilize. the caller would have to #define seccomp_load_chdr foo, include the 1st header, then #define seccomp_load_chdr bar, and include the 2nd header.

tbh, it's not clear to me how multiple arches should be handled. do we want to generate a single program with all the arches included, or manually separate them out, or some hybrid ? i could see having a single filter for x86/x32/x86_64 making sense, but not also including s390/arm64 in there. maybe i'm not being creative enough. if we separate them out, will we walk all of the architectures added and emit the program for each one with appropriate ifdef protection ? for example, see my mapping of SCMP_ARCH_XXX to ifdefs in pax-utils's seccomp-bpf.c.

are we planning on C being the only target we ever care about ? C++ can ingest these easily enough, but what about Rust or Python or the next hot language ?

i'm starting to wonder if libseccomp (the library) is the right home for this API. who do we see as the target audience of libseccomp (the library, not the project) ? clearly it's meant to be used by production code who want to setup & activate filters. but is it also for development purposes ? should we be throwing all of these more clearly development-oriented APIs into the same library ? or should there be a sep library to hold these, or perhaps a CLI tool ? a sep library would be easy to handle -- have the pkg-config file specify both -lseccomp and -lseccomp-dev, and most linkers will discard the -lseccomp-dev linkage if it's not actually used (or if we wanted, could get into linker scripts to hide the separation pretty easily).

@pcmoore
Copy link
Member Author

pcmoore commented Jan 7, 2024

In an effort to get v2.6.0 out sooner than later, I'm going to suggest we push this out to v2.7.0; if you have any concerns or objections please drop a comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants