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: Resolve SCMP_ARCH_* constants to architecture name #295

Open
r10r opened this issue Oct 13, 2020 · 4 comments
Open

RFE: Resolve SCMP_ARCH_* constants to architecture name #295

r10r opened this issue Oct 13, 2020 · 4 comments

Comments

@r10r
Copy link

r10r commented Oct 13, 2020

What about adding seccomp_arch_name (inverse of seccomp_arch_resolve_name) to the API ?

It would be nice (e.g to debug rule generation) if the SCMP_ARCH_* constants can be resolved to the architecture names.
I noticed that this is already implemented and would require only a small amount of refactoring:

libseccomp/src/gen_pfc.c

Lines 51 to 95 in 3734fdc

static const char *_pfc_arch(const struct arch_def *arch)
{
switch (arch->token) {
case SCMP_ARCH_X86:
return "x86";
case SCMP_ARCH_X86_64:
return "x86_64";
case SCMP_ARCH_X32:
return "x32";
case SCMP_ARCH_ARM:
return "arm";
case SCMP_ARCH_AARCH64:
return "aarch64";
case SCMP_ARCH_MIPS:
return "mips";
case SCMP_ARCH_MIPSEL:
return "mipsel";
case SCMP_ARCH_MIPS64:
return "mips64";
case SCMP_ARCH_MIPSEL64:
return "mipsel64";
case SCMP_ARCH_MIPS64N32:
return "mips64n32";
case SCMP_ARCH_MIPSEL64N32:
return "mipsel64n32";
case SCMP_ARCH_PARISC:
return "parisc";
case SCMP_ARCH_PARISC64:
return "parisc64";
case SCMP_ARCH_PPC64:
return "ppc64";
case SCMP_ARCH_PPC64LE:
return "ppc64le";
case SCMP_ARCH_PPC:
return "ppc";
case SCMP_ARCH_S390X:
return "s390x";
case SCMP_ARCH_S390:
return "s390";
case SCMP_ARCH_RISCV64:
return "riscv64";
default:
return "UNKNOWN";
}
}

So why not expose this in the API ? e.g.

const char * seccomp_arch_name(uint32_t arch);
@pcmoore
Copy link
Member

pcmoore commented Oct 13, 2020

Hi @r10r.

Sure, that sounds reasonable. The right thing to do would probably be to add a const char *name field to struct arch_def and then just leverage the existing arch_def_lookup() to create a new API function seccomp_arch_resolve_token() or similar. Does that sound okay to you?

@drakenclimber any thoughts?

@r10r
Copy link
Author

r10r commented Oct 13, 2020

That sounds good.
Does it help when I make the changes (on top of master) and send you a pull request?

@drakenclimber
Copy link
Member

@drakenclimber any thoughts?

Yes, this sounds like a good API to add, and I think your proposed implementation should work well.

Does it help when I make the changes (on top of master) and send you a pull request?

Yes, that would be awesome! Once it's in master, we can handle getting it into the v2.5 release branch.

Thanks so much for the help :)

@pcmoore
Copy link
Member

pcmoore commented Oct 15, 2020

Once it's in master, we can handle getting it into the v2.5 release branch.

Since this is adding a new function to the API, I would suggest that this should be a candidate for v2.6.0 and not v2.5.x.

@pcmoore pcmoore modified the milestones: v2.6.0, v2.7.0 May 30, 2024
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

3 participants