mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-06 01:03:55 -06:00
seccomp: Get actual errno value from failed seccomp functions
Upon failure, a libseccomp API returns actual errno value very rarely. Fortunately, after its commit 34bf78ab (contained in 2.5.0 release), the SCMP_FLTATR_API_SYSRAWRC attribute can be set which makes subsequent APIs return true errno on failure. This is especially critical when seccomp_load() fails, because generic -ECANCELED says nothing. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
23f77f05f2
commit
73422d9524
2 changed files with 22 additions and 0 deletions
|
@ -312,6 +312,19 @@ static int seccomp_start(uint32_t seccomp_opts, Error **errp)
|
|||
goto seccomp_return;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_SECCOMP_SYSRAWRC)
|
||||
/*
|
||||
* This must be the first seccomp_attr_set() call to have full
|
||||
* error propagation from subsequent seccomp APIs.
|
||||
*/
|
||||
rc = seccomp_attr_set(ctx, SCMP_FLTATR_API_SYSRAWRC, 1);
|
||||
if (rc != 0) {
|
||||
error_setg_errno(errp, -rc,
|
||||
"failed to set seccomp rawrc attribute");
|
||||
goto seccomp_return;
|
||||
}
|
||||
#endif
|
||||
|
||||
rc = seccomp_attr_set(ctx, SCMP_FLTATR_CTL_TSYNC, 1);
|
||||
if (rc != 0) {
|
||||
error_setg_errno(errp, -rc,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue