From d1290ff8054920162185fc0856180cce4ab2bce4 Mon Sep 17 00:00:00 2001
From: Marshall Greenblatt <marshall@chromium.org>
Date: Thu, 31 Mar 2022 20:28:22 +0000
Subject: [PATCH] Linux: Fix build error with use_sysroot=false on Ubuntu 18.04

Fixes the following build error:

../../sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc:265:51: error: use of undeclared identifier 'F_SEAL_FUTURE_WRITE'
      F_SEAL_SEAL | F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_FUTURE_WRITE;

The F_SEAL_FUTURE_WRITE flag was added for Android so it makes sense to move
the usage behind a platform check.

BUG=1299437

Change-Id: I18312d01115282b36fbf8ee7a5e088084171bafe
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3553575
Reviewed-by: Egor Pasko <pasko@chromium.org>
Reviewed-by: Robert Sesek <rsesek@chromium.org>
Commit-Queue: Marshall Greenblatt <marshall@chromium.org>
Cr-Commit-Position: refs/heads/main@{#987613}
---
 .../syscall_parameters_restrictions.cc                   | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
index 9728d0b52e68c..7feff3f49323a 100644
--- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
+++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
@@ -261,8 +261,13 @@ ResultExpr RestrictFcntlCommands() {
 
   const uint64_t kAllowedMask = O_ACCMODE | O_APPEND | O_NONBLOCK | O_SYNC |
                                 kOLargeFileFlag | O_CLOEXEC | O_NOATIME;
-  const uint64_t kAllowedSeals =
-      F_SEAL_SEAL | F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_FUTURE_WRITE;
+#if BUILDFLAG(IS_ANDROID)
+  const uint64_t kOsSpecificSeals = F_SEAL_FUTURE_WRITE;
+#else
+  const uint64_t kOsSpecificSeals = 0;
+#endif
+  const uint64_t kAllowedSeals = F_SEAL_SEAL | F_SEAL_GROW | F_SEAL_SHRINK |
+                                 kOsSpecificSeals;
   // clang-format off
   return Switch(cmd)
       .CASES((F_GETFL,
