Skip to content

Commit 8b4b2f9

Browse files
authored
Remove bootstrap.system_call_filter setting (#72848)
This commit removes the bootstrap.system_call_filter setting, as starting in Elasticsearch 8.0.0 we are going to require that system call filters be installed and that this is not user configurable. Note that while we force bootstrap to attempt to install system call filters, we only enforce that they are installed via a bootstrap check in production environments. We can consider changing this behavior, but leave that for future consideration and thus a potential follow-up change.
1 parent 694229f commit 8b4b2f9

File tree

10 files changed

+47
-70
lines changed

10 files changed

+47
-70
lines changed

docs/reference/migration/migrate_8_0/settings.asciidoc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,16 +226,17 @@ Discontinue use of the removed settings. Specifying these settings in
226226
====
227227

228228
[[system-call-filter-setting]]
229-
.System call filter setting deprecated
229+
.System call filter setting removed
230230
[%collapsible]
231231
====
232232
*Details* +
233233
Elasticsearch uses system call filters to remove its ability to fork another
234234
process. This is useful to mitigate remote code exploits. These system call
235-
filters are enabled by default, and controlled via the setting
235+
filters are enabled by default, and were previously controlled via the setting
236236
`bootstrap.system_call_filter`. Starting in Elasticsearch 8.0, system call
237-
filters will be required. As such, the setting `bootstrap.system_call_filter` is
238-
deprecated and will be removed in Elasticsearch 8.0.
237+
filters will be required. As such, the setting `bootstrap.system_call_filter`
238+
was deprecated in Elasticsearch 7.13.0, and is removed as of Elasticsearch
239+
8.0.0.
239240
240241
*Impact* +
241242
Discontinue use of the removed setting. Specifying this setting in Elasticsearch

server/src/main/java/org/elasticsearch/bootstrap/Bootstrap.java

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,17 +89,28 @@ public void run() {
8989
});
9090
}
9191

92-
/** initialize native resources */
93-
public static void initializeNatives(Path tmpFile, boolean mlockAll, boolean systemCallFilter, boolean ctrlHandler) {
92+
/**
93+
* Initialize native resources.
94+
*
95+
* @param tmpFile the temp directory
96+
* @param mlockAll whether or not to lock memory
97+
* @param systemCallFilter whether or not to install system call filters
98+
* @param ctrlHandler whether or not to install the ctrl-c handler (applies to Windows only)
99+
*/
100+
static void initializeNatives(final Path tmpFile, final boolean mlockAll, final boolean systemCallFilter, final boolean ctrlHandler) {
94101
final Logger logger = LogManager.getLogger(Bootstrap.class);
95102

96103
// check if the user is running as root, and bail
97104
if (Natives.definitelyRunningAsRoot()) {
98105
throw new RuntimeException("can not run elasticsearch as root");
99106
}
100107

101-
// enable system call filter
102108
if (systemCallFilter) {
109+
/*
110+
* Try to install system call filters; if they fail to install; a bootstrap check will fail startup in production mode.
111+
*
112+
* TODO: should we fail hard here if system call filters fail to install, or remain lenient in non-production environments?
113+
*/
103114
Natives.tryInstallSystemCallFilter(tmpFile);
104115
}
105116

@@ -165,7 +176,7 @@ private void setup(boolean addShutdownHook, Environment environment) throws Boot
165176
initializeNatives(
166177
environment.tmpFile(),
167178
BootstrapSettings.MEMORY_LOCK_SETTING.get(settings),
168-
BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.get(settings),
179+
true, // always install system call filters, not user-configurable since 8.0.0
169180
BootstrapSettings.CTRLHANDLER_SETTING.get(settings));
170181

171182
// initialize probes before the security manager is installed

server/src/main/java/org/elasticsearch/bootstrap/BootstrapChecks.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,14 @@ String getUseSerialGC() {
523523
}
524524

525525
/**
526-
* Bootstrap check that if system call filters are enabled, then system call filters must have installed successfully.
526+
* Bootstrap check that system call filters must have installed successfully.
527527
*/
528528
static class SystemCallFilterCheck implements BootstrapCheck {
529529

530530
@Override
531531
public BootstrapCheckResult check(BootstrapContext context) {
532-
if (BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.get(context.settings()) && isSystemCallFilterInstalled() == false) {
533-
final String message = "system call filters failed to install; " +
534-
"check the logs and fix your configuration or disable system call filters at your own risk";
532+
if (isSystemCallFilterInstalled() == false) {
533+
final String message = "system call filters failed to install; check the logs and fix your configuration";
535534
return BootstrapCheckResult.failure(message);
536535
} else {
537536
return BootstrapCheckResult.success();
@@ -590,10 +589,10 @@ String onError() {
590589
String message(BootstrapContext context) {
591590
return String.format(
592591
Locale.ROOT,
593-
"OnError [%s] requires forking but is prevented by system call filters ([%s=true]);" +
592+
"OnError [%s] requires forking but is prevented by system call filters;" +
594593
" upgrade to at least Java 8u92 and use ExitOnOutOfMemoryError",
595-
onError(),
596-
BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.getKey());
594+
onError()
595+
);
597596
}
598597

599598
}
@@ -614,10 +613,10 @@ String onOutOfMemoryError() {
614613
String message(BootstrapContext context) {
615614
return String.format(
616615
Locale.ROOT,
617-
"OnOutOfMemoryError [%s] requires forking but is prevented by system call filters ([%s=true]);" +
616+
"OnOutOfMemoryError [%s] requires forking but is prevented by system call filters;" +
618617
" upgrade to at least Java 8u92 and use ExitOnOutOfMemoryError",
619-
onOutOfMemoryError(),
620-
BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.getKey());
618+
onOutOfMemoryError()
619+
);
621620
}
622621

623622
}

server/src/main/java/org/elasticsearch/common/settings/ClusterSettings.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,6 @@ public void apply(Settings value, Settings current, Settings previous) {
430430
PluginsService.MANDATORY_SETTING,
431431
BootstrapSettings.SECURITY_FILTER_BAD_DEFAULTS_SETTING,
432432
BootstrapSettings.MEMORY_LOCK_SETTING,
433-
BootstrapSettings.SYSTEM_CALL_FILTER_SETTING,
434433
BootstrapSettings.CTRLHANDLER_SETTING,
435434
KeyStoreWrapper.SEED_SETTING,
436435
IndexingMemoryController.INDEX_BUFFER_SIZE_SETTING,

server/src/test/java/org/elasticsearch/bootstrap/BootstrapChecksTests.java

Lines changed: 16 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -417,37 +417,31 @@ String getUseSerialGC() {
417417

418418
public void testSystemCallFilterCheck() throws NodeValidationException {
419419
final AtomicBoolean isSystemCallFilterInstalled = new AtomicBoolean();
420-
BootstrapContext context = randomBoolean() ? createTestContext(Settings.builder().put("bootstrap.system_call_filter", true)
421-
.build(), null) : emptyContext;
420+
final BootstrapContext context;
421+
if (randomBoolean()) {
422+
context = createTestContext(Settings.builder().put("bootstrap.system_call_filter", true).build(), null);
423+
} else {
424+
context = emptyContext;
425+
}
422426

423427
final BootstrapChecks.SystemCallFilterCheck systemCallFilterEnabledCheck = new BootstrapChecks.SystemCallFilterCheck() {
428+
424429
@Override
425430
boolean isSystemCallFilterInstalled() {
426431
return isSystemCallFilterInstalled.get();
427432
}
433+
428434
};
429435

430436
final NodeValidationException e = expectThrows(
431437
NodeValidationException.class,
432438
() -> BootstrapChecks.check(context, true, Collections.singletonList(systemCallFilterEnabledCheck)));
433439
assertThat(
434440
e.getMessage(),
435-
containsString("system call filters failed to install; " +
436-
"check the logs and fix your configuration or disable system call filters at your own risk"));
441+
containsString("system call filters failed to install; check the logs and fix your configuration"));
437442

438443
isSystemCallFilterInstalled.set(true);
439444
BootstrapChecks.check(context, true, Collections.singletonList(systemCallFilterEnabledCheck));
440-
BootstrapContext context_1 = createTestContext(Settings.builder().put("bootstrap.system_call_filter", false).build(), null);
441-
final BootstrapChecks.SystemCallFilterCheck systemCallFilterNotEnabledCheck = new BootstrapChecks.SystemCallFilterCheck() {
442-
@Override
443-
boolean isSystemCallFilterInstalled() {
444-
return isSystemCallFilterInstalled.get();
445-
}
446-
};
447-
isSystemCallFilterInstalled.set(false);
448-
BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck));
449-
isSystemCallFilterInstalled.set(true);
450-
BootstrapChecks.check(context_1, true, Collections.singletonList(systemCallFilterNotEnabledCheck));
451445
}
452446

453447
public void testMightForkCheck() throws NodeValidationException {
@@ -482,6 +476,7 @@ public void testOnErrorCheck() throws NodeValidationException {
482476
final AtomicBoolean isSystemCallFilterInstalled = new AtomicBoolean();
483477
final AtomicReference<String> onError = new AtomicReference<>();
484478
final BootstrapChecks.MightForkCheck check = new BootstrapChecks.OnErrorCheck() {
479+
485480
@Override
486481
boolean isSystemCallFilterInstalled() {
487482
return isSystemCallFilterInstalled.get();
@@ -491,6 +486,7 @@ boolean isSystemCallFilterInstalled() {
491486
String onError() {
492487
return onError.get();
493488
}
489+
494490
};
495491

496492
final String command = randomAlphaOfLength(16);
@@ -502,14 +498,15 @@ String onError() {
502498
e -> assertThat(
503499
e.getMessage(),
504500
containsString(
505-
"OnError [" + command + "] requires forking but is prevented by system call filters " +
506-
"([bootstrap.system_call_filter=true]); upgrade to at least Java 8u92 and use ExitOnOutOfMemoryError")));
501+
"OnError [" + command + "] requires forking but is prevented by system call filters;" +
502+
" upgrade to at least Java 8u92 and use ExitOnOutOfMemoryError")));
507503
}
508504

509505
public void testOnOutOfMemoryErrorCheck() throws NodeValidationException {
510506
final AtomicBoolean isSystemCallFilterInstalled = new AtomicBoolean();
511507
final AtomicReference<String> onOutOfMemoryError = new AtomicReference<>();
512508
final BootstrapChecks.MightForkCheck check = new BootstrapChecks.OnOutOfMemoryErrorCheck() {
509+
513510
@Override
514511
boolean isSystemCallFilterInstalled() {
515512
return isSystemCallFilterInstalled.get();
@@ -519,6 +516,7 @@ boolean isSystemCallFilterInstalled() {
519516
String onOutOfMemoryError() {
520517
return onOutOfMemoryError.get();
521518
}
519+
522520
};
523521

524522
final String command = randomAlphaOfLength(16);
@@ -531,7 +529,7 @@ String onOutOfMemoryError() {
531529
e.getMessage(),
532530
containsString(
533531
"OnOutOfMemoryError [" + command + "]"
534-
+ " requires forking but is prevented by system call filters ([bootstrap.system_call_filter=true]);"
532+
+ " requires forking but is prevented by system call filters;"
535533
+ " upgrade to at least Java 8u92 and use ExitOnOutOfMemoryError")));
536534
}
537535

server/src/test/java/org/elasticsearch/bootstrap/BootstrapSettingsTests.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ public class BootstrapSettingsTests extends ESTestCase {
1616
public void testDefaultSettings() {
1717
assertTrue(BootstrapSettings.SECURITY_FILTER_BAD_DEFAULTS_SETTING.get(Settings.EMPTY));
1818
assertFalse(BootstrapSettings.MEMORY_LOCK_SETTING.get(Settings.EMPTY));
19-
assertTrue(BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.get(Settings.EMPTY));
2019
assertTrue(BootstrapSettings.CTRLHANDLER_SETTING.get(Settings.EMPTY));
2120
}
2221

test/framework/src/main/java/org/elasticsearch/bootstrap/BootstrapForTesting.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class BootstrapForTesting {
7373
// just like bootstrap, initialize natives, then SM
7474
final boolean memoryLock =
7575
BootstrapSettings.MEMORY_LOCK_SETTING.get(Settings.EMPTY); // use the default bootstrap.memory_lock setting
76+
// some tests need the ability to disable system call filters (so they can fork other processes as part of test execution)
7677
final boolean systemCallFilter = Booleans.parseBoolean(System.getProperty("tests.system_call_filter", "true"));
7778
Bootstrap.initializeNatives(javaTmpDir, memoryLock, systemCallFilter, true);
7879

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/DeprecationChecks.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ private DeprecationChecks() {
3232
static List<Function<ClusterState, DeprecationIssue>> CLUSTER_SETTINGS_CHECKS =
3333
Collections.emptyList();
3434

35-
static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS =
36-
List.of(NodeDeprecationChecks::checkBootstrapSystemCallFilterSetting);
35+
static List<BiFunction<Settings, PluginsAndModules, DeprecationIssue>> NODE_SETTINGS_CHECKS = List.of();
3736

3837
static List<Function<IndexMetadata, DeprecationIssue>> INDEX_SETTINGS_CHECKS =
3938
List.of(IndexDeprecationChecks::oldIndicesCheck, IndexDeprecationChecks::translogRetentionSettingCheck);

x-pack/plugin/deprecation/src/main/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecks.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.elasticsearch.xpack.deprecation;
99

1010
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
11-
import org.elasticsearch.bootstrap.BootstrapSettings;
1211
import org.elasticsearch.common.settings.Setting;
1312
import org.elasticsearch.common.settings.Settings;
1413
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
@@ -18,14 +17,6 @@
1817

1918
public class NodeDeprecationChecks {
2019

21-
static DeprecationIssue checkBootstrapSystemCallFilterSetting(final Settings settings, final PluginsAndModules pluginsAndModules) {
22-
return checkRemovedSetting(
23-
settings,
24-
BootstrapSettings.SYSTEM_CALL_FILTER_SETTING,
25-
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-system-call-filter-setting"
26-
);
27-
}
28-
2920
private static DeprecationIssue checkDeprecatedSetting(
3021
final Settings settings,
3122
final PluginsAndModules pluginsAndModules,

x-pack/plugin/deprecation/src/test/java/org/elasticsearch/xpack/deprecation/NodeDeprecationChecksTests.java

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,38 +7,17 @@
77

88
package org.elasticsearch.xpack.deprecation;
99

10-
import org.elasticsearch.action.admin.cluster.node.info.PluginsAndModules;
11-
import org.elasticsearch.bootstrap.BootstrapSettings;
1210
import org.elasticsearch.common.settings.Setting;
1311
import org.elasticsearch.common.settings.Settings;
1412
import org.elasticsearch.test.ESTestCase;
1513
import org.elasticsearch.xpack.core.deprecation.DeprecationIssue;
1614

17-
import java.util.List;
18-
1915
import static org.hamcrest.Matchers.equalTo;
20-
import static org.hamcrest.Matchers.hasItem;
2116
import static org.hamcrest.Matchers.not;
2217
import static org.hamcrest.Matchers.nullValue;
2318

2419
public class NodeDeprecationChecksTests extends ESTestCase {
2520

26-
public void testCheckBootstrapSystemCallFilterSetting() {
27-
final boolean boostrapSystemCallFilter = randomBoolean();
28-
final Settings settings =
29-
Settings.builder().put(BootstrapSettings.SYSTEM_CALL_FILTER_SETTING.getKey(), boostrapSystemCallFilter).build();
30-
final PluginsAndModules pluginsAndModules = new PluginsAndModules(List.of(), List.of());
31-
final List<DeprecationIssue> issues =
32-
DeprecationChecks.filterChecks(DeprecationChecks.NODE_SETTINGS_CHECKS, c -> c.apply(settings, pluginsAndModules));
33-
final DeprecationIssue expected = new DeprecationIssue(
34-
DeprecationIssue.Level.CRITICAL,
35-
"setting [bootstrap.system_call_filter] is deprecated and will be removed in the next major version",
36-
"https://www.elastic.co/guide/en/elasticsearch/reference/7.13/breaking-changes-7.13.html#deprecate-system-call-filter-setting",
37-
"the setting [bootstrap.system_call_filter] is currently set to [" + boostrapSystemCallFilter + "], remove this setting");
38-
assertThat(issues, hasItem(expected));
39-
assertSettingDeprecationsAndWarnings(new Setting<?>[]{BootstrapSettings.SYSTEM_CALL_FILTER_SETTING});
40-
}
41-
4221
public void testRemovedSettingNotSet() {
4322
final Settings settings = Settings.EMPTY;
4423
final Setting<?> removedSetting = Setting.simpleString("node.removed_setting");

0 commit comments

Comments
 (0)