Skip to content

Conversation

@rjernst
Copy link
Member

@rjernst rjernst commented May 23, 2024

This commit moves the system call filtering initialization into NativeAccess. The code is essentially unmodified from its existing state, now existing within the *NativeAccess implementations.

relates #104876

This commit moves the system call filtering initialization into
NativeAccess. The code is essentially unmodified from its existing
state, now existing within the *NativeAccess implementations.

relates elastic#104876
@rjernst rjernst added :Core/Infra/Core Core issues without another label >refactoring labels May 23, 2024
@rjernst rjernst marked this pull request as ready for review May 23, 2024 16:11
@rjernst rjernst requested a review from a team as a code owner May 23, 2024 16:11
@elasticsearchmachine elasticsearchmachine added v8.15.0 Team:Core/Infra Meta label for core/infra team labels May 23, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-core-infra (Team:Core/Infra)

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

I see we are dropping support for Solaris, FreeBSD, OpenBSD, but I suppose this is OK, as this is in line with all the rest of native functions

import java.util.Map;

/**
* Installs a system call filter to block process execution.
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: I would split up this comment and put it above the new code in *NativeAccess.java, above each tryInstallExecSandbox implementation. I see there are some, but not all the details (also, it needs some update, e.g. supporting aarch64 on Linux).


// TODO: move this UOE to when binding methods in jna/jdk impls
// we couldn't link methods, could be some really ancient kernel (e.g. < 2.1.57) or some bug
/*if (linux_libc == null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something we can do now, or is it for a follow-up?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'll do it now.

*
* https://msdn.microsoft.com/en-us/library/windows/desktop/ms684147%28v=vs.85%29.aspx
*/
public static class JnaJobObjectBasicLimitInformation extends Structure implements ByReference, JobObjectBasicLimitInformation {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the corresponding classes/functions in org/elasticsearch/bootstrap/JNAKernel32Library.java can be cleaned up too (e.g. class JOBOBJECT_BASIC_LIMIT_INFORMATION)

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh good catch, that entire class can be removed.

public void setUp() throws Exception {
super.setUp();
assumeTrue("requires system call filter installation", Natives.isSystemCallFilterInstalled());
assumeTrue(
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm a bit concerned about testing. At the very least, I would run them locally on a Mac, on CI with test-windows and test-arm, with JDK 17 and 21 (to check both JNA and JDK implementations), and check they are actually run (not skipped by this assumeTrue). It's a lot of work :/

Copy link
Member Author

Choose a reason for hiding this comment

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

I've added several more labels that should trigger complete testing on all platforms.

Copy link
Member Author

Choose a reason for hiding this comment

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

with JDK 17 and 21

Actually, these labels won't trigger either of these versions precisely. I'll double check packaging tests, if we turn on bootstrap checks it should cover all these test scenarios.

@rjernst
Copy link
Member Author

rjernst commented May 24, 2024

I see we are dropping support for Solaris, FreeBSD, OpenBSD

We never officially supported these, so I don't see this as dropping support, just cleaning up unused code. There are numerous other things that will break/fail on those platforms.

@rjernst rjernst added test-arm Pull Requests that should be tested against arm agents :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts test-windows Trigger CI checks on Windows labels May 24, 2024
@elasticsearchmachine elasticsearchmachine added the Team:Delivery Meta label for Delivery team label May 24, 2024
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-delivery (Team:Delivery)

Copy link
Contributor

@ldematte ldematte left a comment

Choose a reason for hiding this comment

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

As long as the additional testing/validation we discussed shows no problems (thanks for the effort!), LGTM

@rjernst rjernst added the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label May 24, 2024
@rjernst rjernst removed the auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) label Jun 8, 2024
@rjernst rjernst requested a review from a team as a code owner June 8, 2024 03:12
@rjernst rjernst added the test-full-bwc Trigger full BWC version matrix tests label Jun 10, 2024
versions = [bwcVersion.toString(), project.version]
setting 'cluster.remote.node.attr', 'gateway'
setting 'xpack.security.enabled', 'false'
setting 'logger.org.elasticsearch.env.NodeEnvironment', 'TRACE'
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we want to keep this in here?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, i've just been adding these for debugging the windows bwc test failure.

@rjernst rjernst merged commit c6f8260 into elastic:main Jul 9, 2024
@rjernst rjernst deleted the native/exec_sandbox branch July 9, 2024 19:25
tvernum pushed a commit that referenced this pull request Feb 25, 2025
This commit moves the system call filtering initialization into
NativeAccess. The code is essentially unmodified from its existing
state, now existing within the *NativeAccess implementations.

relates #104876
tvernum pushed a commit that referenced this pull request Feb 25, 2025
This commit moves the system call filtering initialization into
NativeAccess. The code is essentially unmodified from its existing
state, now existing within the *NativeAccess implementations.

relates #104876
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Core/Infra/Core Core issues without another label :Delivery/Packaging RPM and deb packaging, tar and zip archives, shell and batch scripts >refactoring Team:Core/Infra Meta label for core/infra team Team:Delivery Meta label for Delivery team test-arm Pull Requests that should be tested against arm agents test-full-bwc Trigger full BWC version matrix tests test-windows Trigger CI checks on Windows v8.16.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants