Skip to content

[SMAGENT-1783] Don't check the signal info if it's not valid #1493

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

Merged
merged 3 commits into from
Aug 22, 2019

Conversation

nathan-b
Copy link
Contributor

This is the eBPF half of pull request #1460

@nathan-b nathan-b requested a review from bertocci August 21, 2019 19:42
sig = ctx->sig;
if (sig == SIGKILL) {

if (info == SEND_SIG_NOINFO || info == SEND_SIG_PRIV || info == SEND_SIG_FORCED) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I missed SEND_SIG_FORCED in my change. I think it should be in both the regular+bpf drivers, but both places need to add a version check. It's been removed in later kernel versions according to https://lore.kernel.org/patchwork/patch/981479/.

Have you tried building with a recent kernel? If we have compilation problems and add version checks, let's also update the regular driver code.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ooh, good catch, thanks! Definitely doesn't build on a 5.2 kernel!

It's just a macro, so I think a simple #ifdef might be more straightforward than a version check. I'll update both the kmod and the bpf driver accordingly!

#ifdef SEND_SIG_FORCED
#define SIGINFO_NOT_A_POINTER(_info) ((_info) <= SEND_SIG_FORCED)
#else
#define SIGINFO_NOT_A_POINTER(_info) ((struct kernel_siginfo*)(_info) <= SEND_SIG_PRIV)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why cast for this one and not the other #define? We should use a function and get a little bit of type-checking safety.

@@ -3518,6 +3518,12 @@ FILLER(sys_pagefault_e, false)
return res;
}

#ifdef SEND_SIG_FORCED
#define SIGINFO_NOT_A_POINTER(_info) ((_info) <= SEND_SIG_FORCED)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think <= is defined behavior for pointers, and also we're relying on the implementation of SEND_SIG_*. We should explicitly check for each SEND_SIG_* type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the patch that you helpfully sent me, look at is_sig_special. Looks like that's what the kernel itself uses (would be helpful if they just exported that dang function and saved us some trouble...).

If you'd rather me explicitly check each type though I can do so.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's check explicitly. I would love to use the kernel implementation, and I doubt it will ever change, but there's nothing to guarantee that.

@nathan-b nathan-b merged commit fd30d12 into dev Aug 22, 2019
@nathan-b nathan-b deleted the siginfo_reading branch August 22, 2019 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants