0010-sandbox-add-riscv-arch-definition-and-define-syscall.patch 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864
  1. From 46182d25278d74ee7e13eb46df41d31eb95d9ec5 Mon Sep 17 00:00:00 2001
  2. From: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  3. Date: Wed, 15 Jun 2022 08:27:45 +0000
  4. Subject: [PATCH 10/68] sandbox: add riscv arch definition and define syscall
  5. Credit to work contributed in Github.
  6. https://github.com/felixonmars/archriscv-packages/tree/master/chromium
  7. Signed-off-by: Rebecca Chang Swee Fun <rebecca.chang@starfivetech.com>
  8. ---
  9. sandbox/features.gni | 3 +-
  10. sandbox/linux/BUILD.gn | 5 +
  11. sandbox/linux/bpf_dsl/linux_syscall_ranges.h | 6 +
  12. sandbox/linux/bpf_dsl/seccomp_macros.h | 41 +
  13. .../seccomp-bpf-helpers/baseline_policy.cc | 9 +-
  14. .../syscall_parameters_restrictions.cc | 3 +-
  15. .../linux/seccomp-bpf-helpers/syscall_sets.cc | 71 +-
  16. .../linux/seccomp-bpf-helpers/syscall_sets.h | 14 +-
  17. sandbox/linux/seccomp-bpf/syscall.cc | 35 +-
  18. sandbox/linux/services/credentials.cc | 2 +-
  19. sandbox/linux/services/syscall_wrappers.cc | 2 +-
  20. .../linux/syscall_broker/broker_process.cc | 20 +-
  21. sandbox/linux/system_headers/linux_seccomp.h | 8 +
  22. sandbox/linux/system_headers/linux_signal.h | 2 +-
  23. sandbox/linux/system_headers/linux_stat.h | 2 +-
  24. sandbox/linux/system_headers/linux_syscalls.h | 4 +
  25. .../system_headers/riscv64_linux_syscalls.h | 1074 +++++++++++++++++
  26. .../linux/bpf_cros_amd_gpu_policy_linux.cc | 2 +-
  27. sandbox/policy/linux/bpf_gpu_policy_linux.cc | 2 +-
  28. 19 files changed, 1251 insertions(+), 54 deletions(-)
  29. create mode 100644 sandbox/linux/system_headers/riscv64_linux_syscalls.h
  30. diff --git a/sandbox/features.gni b/sandbox/features.gni
  31. index ad067ada520b..c9f67f81618f 100644
  32. --- a/sandbox/features.gni
  33. +++ b/sandbox/features.gni
  34. @@ -9,7 +9,8 @@
  35. use_seccomp_bpf = (is_linux || is_chromeos || is_android) &&
  36. (current_cpu == "x86" || current_cpu == "x64" ||
  37. current_cpu == "arm" || current_cpu == "arm64" ||
  38. - current_cpu == "mipsel" || current_cpu == "mips64el")
  39. + current_cpu == "mipsel" || current_cpu == "mips64el" ||
  40. + current_cpu == "riscv64")
  41. # SSBD (Speculative Store Bypass Disable) is a mitigation of Spectre Variant 4.
  42. # As Spectre Variant 4 can be mitigated by site isolation, opt-out SSBD on site
  43. diff --git a/sandbox/linux/BUILD.gn b/sandbox/linux/BUILD.gn
  44. index ec24cd81e274..60c60d741bf6 100644
  45. --- a/sandbox/linux/BUILD.gn
  46. +++ b/sandbox/linux/BUILD.gn
  47. @@ -292,11 +292,16 @@ if (is_linux || is_chromeos) {
  48. cflags = [
  49. # For ULLONG_MAX
  50. "-std=gnu99",
  51. + "-fPIE",
  52. # These files have a suspicious comparison.
  53. # TODO fix this and re-enable this warning.
  54. "-Wno-sign-compare",
  55. ]
  56. +
  57. + ldflags = [
  58. + "-pie",
  59. + ]
  60. }
  61. }
  62. diff --git a/sandbox/linux/bpf_dsl/linux_syscall_ranges.h b/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
  63. index 313511f22e95..104dabde1cc0 100644
  64. --- a/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
  65. +++ b/sandbox/linux/bpf_dsl/linux_syscall_ranges.h
  66. @@ -56,6 +56,12 @@
  67. #define MAX_PUBLIC_SYSCALL __NR_syscalls
  68. #define MAX_SYSCALL MAX_PUBLIC_SYSCALL
  69. +#elif defined(__riscv) && (__riscv_xlen == 64)
  70. +
  71. +#define MIN_SYSCALL 0u
  72. +#define MAX_PUBLIC_SYSCALL 1024u
  73. +#define MAX_SYSCALL MAX_PUBLIC_SYSCALL
  74. +
  75. #else
  76. #error "Unsupported architecture"
  77. #endif
  78. diff --git a/sandbox/linux/bpf_dsl/seccomp_macros.h b/sandbox/linux/bpf_dsl/seccomp_macros.h
  79. index 961a8cf7521e..7c9a0c99e8fb 100644
  80. --- a/sandbox/linux/bpf_dsl/seccomp_macros.h
  81. +++ b/sandbox/linux/bpf_dsl/seccomp_macros.h
  82. @@ -343,6 +343,47 @@ struct regs_struct {
  83. #define SECCOMP_PT_PARM4(_regs) (_regs).regs[3]
  84. #define SECCOMP_PT_PARM5(_regs) (_regs).regs[4]
  85. #define SECCOMP_PT_PARM6(_regs) (_regs).regs[5]
  86. +
  87. +#elif defined(__riscv) && (__riscv_xlen == 64)
  88. +struct regs_struct {
  89. + unsigned long regs[32];
  90. +};
  91. +
  92. +#define SECCOMP_ARCH AUDIT_ARCH_RISCV64
  93. +
  94. +#define SECCOMP_REG(_ctx, _reg) ((_ctx)->uc_mcontext.__gregs[_reg])
  95. +
  96. +#define SECCOMP_RESULT(_ctx) SECCOMP_REG(_ctx, REG_A0)
  97. +#define SECCOMP_SYSCALL(_ctx) SECCOMP_REG(_ctx, REG_A0+7)
  98. +#define SECCOMP_IP(_ctx) (_ctx)->uc_mcontext.__gregs[REG_PC]
  99. +#define SECCOMP_PARM1(_ctx) SECCOMP_REG(_ctx, REG_A0)
  100. +#define SECCOMP_PARM2(_ctx) SECCOMP_REG(_ctx, REG_A0+1)
  101. +#define SECCOMP_PARM3(_ctx) SECCOMP_REG(_ctx, REG_A0+2)
  102. +#define SECCOMP_PARM4(_ctx) SECCOMP_REG(_ctx, REG_A0+3)
  103. +#define SECCOMP_PARM5(_ctx) SECCOMP_REG(_ctx, REG_A0+4)
  104. +#define SECCOMP_PARM6(_ctx) SECCOMP_REG(_ctx, REG_A0+5)
  105. +
  106. +#define SECCOMP_NR_IDX (offsetof(struct arch_seccomp_data, nr))
  107. +#define SECCOMP_ARCH_IDX (offsetof(struct arch_seccomp_data, arch))
  108. +#define SECCOMP_IP_MSB_IDX \
  109. + (offsetof(struct arch_seccomp_data, instruction_pointer) + 4)
  110. +#define SECCOMP_IP_LSB_IDX \
  111. + (offsetof(struct arch_seccomp_data, instruction_pointer) + 0)
  112. +#define SECCOMP_ARG_MSB_IDX(nr) \
  113. + (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 4)
  114. +#define SECCOMP_ARG_LSB_IDX(nr) \
  115. + (offsetof(struct arch_seccomp_data, args) + 8 * (nr) + 0)
  116. +
  117. +#define SECCOMP_PT_RESULT(_regs) (_regs).regs[REG_A0]
  118. +#define SECCOMP_PT_SYSCALL(_regs) (_regs).regs[REG_A0+7]
  119. +#define SECCOMP_PT_IP(_regs) (_regs).regs[REG_PC]
  120. +#define SECCOMP_PT_PARM1(_regs) (_regs).regs[REG_A0]
  121. +#define SECCOMP_PT_PARM2(_regs) (_regs).regs[REG_A0+1]
  122. +#define SECCOMP_PT_PARM3(_regs) (_regs).regs[REG_A0+2]
  123. +#define SECCOMP_PT_PARM4(_regs) (_regs).regs[REG_A0+3]
  124. +#define SECCOMP_PT_PARM5(_regs) (_regs).regs[REG_A0+4]
  125. +#define SECCOMP_PT_PARM6(_regs) (_regs).regs[REG_A0+5]
  126. +
  127. #else
  128. #error Unsupported target platform
  129. diff --git a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
  130. index 30c15cccb5c1..06c6026a26fa 100644
  131. --- a/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
  132. +++ b/sandbox/linux/seccomp-bpf-helpers/baseline_policy.cc
  133. @@ -60,6 +60,9 @@ bool IsBaselinePolicyAllowed(int sysno) {
  134. #endif
  135. #if defined(__mips__)
  136. SyscallSets::IsMipsPrivate(sysno) ||
  137. +#endif
  138. +#if defined(__riscv)
  139. + SyscallSets::IsRiscvPrivate(sysno) ||
  140. #endif
  141. SyscallSets::IsAllowedOperationOnFd(sysno);
  142. // clang-format on
  143. @@ -198,7 +201,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
  144. return RestrictFcntlCommands();
  145. #endif
  146. -#if !defined(__aarch64__)
  147. +#if !defined(__aarch64__) && !defined(__riscv)
  148. // fork() is never used as a system call (clone() is used instead), but we
  149. // have seen it in fallback code on Android.
  150. if (sysno == __NR_fork) {
  151. @@ -253,7 +256,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
  152. }
  153. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
  154. - defined(__aarch64__)
  155. + defined(__aarch64__) || defined(__riscv)
  156. if (sysno == __NR_mmap)
  157. return RestrictMmapFlags();
  158. #endif
  159. @@ -274,7 +277,7 @@ ResultExpr EvaluateSyscallImpl(int fs_denied_errno,
  160. return RestrictPrctl();
  161. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  162. - defined(__aarch64__)
  163. + defined(__aarch64__) || defined(__riscv)
  164. if (sysno == __NR_socketpair) {
  165. // Only allow AF_UNIX, PF_UNIX. Crash if anything else is seen.
  166. static_assert(AF_UNIX == PF_UNIX,
  167. diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
  168. index 7feff3f49323..80205c10dd0b 100644
  169. --- a/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
  170. +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_parameters_restrictions.cc
  171. @@ -37,6 +37,7 @@
  172. #if (BUILDFLAG(IS_LINUX) || BUILDFLAG(IS_CHROMEOS_LACROS)) && \
  173. !defined(__arm__) && !defined(__aarch64__) && \
  174. + !defined(__riscv) && \
  175. !defined(PTRACE_GET_THREAD_AREA)
  176. // Also include asm/ptrace-abi.h since ptrace.h in older libc (for instance
  177. // the one in Ubuntu 16.04 LTS) is missing PTRACE_GET_THREAD_AREA.
  178. @@ -443,7 +444,7 @@ ResultExpr RestrictPtrace() {
  179. #endif
  180. return Switch(request)
  181. .CASES((
  182. -#if !defined(__aarch64__)
  183. +#if !defined(__aarch64__) && !defined(__riscv)
  184. PTRACE_GETREGS, PTRACE_GETFPREGS, PTRACE_GET_THREAD_AREA,
  185. PTRACE_GETREGSET,
  186. #endif
  187. diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
  188. index b3cf6fc7e86f..39dceabf07c3 100644
  189. --- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
  190. +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.cc
  191. @@ -103,7 +103,7 @@ bool SyscallSets::IsUmask(int sysno) {
  192. // Both EPERM and ENOENT are valid errno unless otherwise noted in comment.
  193. bool SyscallSets::IsFileSystem(int sysno) {
  194. switch (sysno) {
  195. -#if !defined(__aarch64__)
  196. +#if !defined(__aarch64__) && !defined(__riscv)
  197. case __NR_access: // EPERM not a valid errno.
  198. case __NR_chmod:
  199. case __NR_chown:
  200. @@ -136,7 +136,7 @@ bool SyscallSets::IsFileSystem(int sysno) {
  201. case __NR_faccessat2:
  202. case __NR_fchmodat:
  203. case __NR_fchownat: // Should be called chownat ?
  204. -#if defined(__x86_64__) || defined(__aarch64__)
  205. +#if defined(__x86_64__) || defined(__aarch64__) && defined(__riscv)
  206. case __NR_newfstatat: // fstatat(). EPERM not a valid errno.
  207. #elif defined(__i386__) || defined(__arm__) || \
  208. (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
  209. @@ -226,7 +226,7 @@ bool SyscallSets::IsAllowedFileSystemAccessViaFd(int sysno) {
  210. case __NR_oldfstat:
  211. #endif
  212. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
  213. - defined(__aarch64__)
  214. + defined(__aarch64__) || defined(__riscv)
  215. case __NR_sync_file_range: // EPERM not a valid errno.
  216. #elif defined(__arm__)
  217. case __NR_arm_sync_file_range: // EPERM not a valid errno.
  218. @@ -245,7 +245,7 @@ bool SyscallSets::IsDeniedFileSystemAccessViaFd(int sysno) {
  219. #if defined(__i386__) || defined(__arm__)
  220. case __NR_fchown32:
  221. #endif
  222. -#if !defined(__aarch64__)
  223. +#if !defined(__aarch64__) && !defined(__riscv)
  224. case __NR_getdents: // EPERM not a valid errno.
  225. #endif
  226. case __NR_getdents64: // EPERM not a valid errno.
  227. @@ -324,7 +324,7 @@ bool SyscallSets::IsProcessPrivilegeChange(int sysno) {
  228. bool SyscallSets::IsProcessGroupOrSession(int sysno) {
  229. switch (sysno) {
  230. case __NR_setpgid:
  231. -#if !defined(__aarch64__)
  232. +#if !defined(__aarch64__) && !defined(__riscv)
  233. case __NR_getpgrp:
  234. #endif
  235. case __NR_setsid:
  236. @@ -358,7 +358,7 @@ bool SyscallSets::IsAllowedSignalHandling(int sysno) {
  237. case __NR_rt_sigqueueinfo:
  238. case __NR_rt_sigsuspend:
  239. case __NR_rt_tgsigqueueinfo:
  240. -#if !defined(__aarch64__)
  241. +#if !defined(__aarch64__) && !defined(__riscv)
  242. case __NR_signalfd:
  243. #endif
  244. case __NR_signalfd4:
  245. @@ -382,12 +382,12 @@ bool SyscallSets::IsAllowedOperationOnFd(int sysno) {
  246. switch (sysno) {
  247. case __NR_close:
  248. case __NR_dup:
  249. -#if !defined(__aarch64__)
  250. +#if !defined(__aarch64__) && !defined(__riscv)
  251. case __NR_dup2:
  252. #endif
  253. case __NR_dup3:
  254. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  255. - defined(__aarch64__)
  256. + defined(__aarch64__) || defined(__riscv)
  257. case __NR_shutdown:
  258. #endif
  259. return true;
  260. @@ -426,7 +426,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
  261. return true;
  262. case __NR_clone: // Should be parameter-restricted.
  263. case __NR_setns: // Privileged.
  264. -#if !defined(__aarch64__)
  265. +#if !defined(__aarch64__) && !defined(__riscv)
  266. case __NR_fork:
  267. #endif
  268. #if defined(__i386__) || defined(__x86_64__)
  269. @@ -437,7 +437,7 @@ bool SyscallSets::IsAllowedProcessStartOrDeath(int sysno) {
  270. #endif
  271. case __NR_set_tid_address:
  272. case __NR_unshare:
  273. -#if !defined(__mips__) && !defined(__aarch64__)
  274. +#if !defined(__mips__) && !defined(__aarch64__) && !defined(__riscv)
  275. case __NR_vfork:
  276. #endif
  277. default:
  278. @@ -462,7 +462,7 @@ bool SyscallSets::IsAllowedFutex(int sysno) {
  279. bool SyscallSets::IsAllowedEpoll(int sysno) {
  280. switch (sysno) {
  281. -#if !defined(__aarch64__)
  282. +#if !defined(__aarch64__) && !defined(__riscv)
  283. case __NR_epoll_create:
  284. case __NR_epoll_wait:
  285. #endif
  286. @@ -483,14 +483,14 @@ bool SyscallSets::IsAllowedEpoll(int sysno) {
  287. bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
  288. switch (sysno) {
  289. -#if !defined(__aarch64__)
  290. +#if !defined(__aarch64__) && !defined(__riscv)
  291. case __NR_pipe:
  292. #endif
  293. case __NR_pipe2:
  294. return true;
  295. default:
  296. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  297. - defined(__aarch64__)
  298. + defined(__aarch64__) || defined(__riscv)
  299. case __NR_socketpair: // We will want to inspect its argument.
  300. #endif
  301. return false;
  302. @@ -500,7 +500,7 @@ bool SyscallSets::IsAllowedGetOrModifySocket(int sysno) {
  303. bool SyscallSets::IsDeniedGetOrModifySocket(int sysno) {
  304. switch (sysno) {
  305. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  306. - defined(__aarch64__)
  307. + defined(__aarch64__) || defined(__riscv)
  308. case __NR_accept:
  309. case __NR_accept4:
  310. case __NR_bind:
  311. @@ -554,7 +554,7 @@ bool SyscallSets::IsAllowedAddressSpaceAccess(int sysno) {
  312. case __NR_mincore:
  313. case __NR_mlockall:
  314. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
  315. - defined(__aarch64__)
  316. + defined(__aarch64__) || defined(__riscv)
  317. case __NR_mmap:
  318. #endif
  319. #if defined(__i386__) || defined(__arm__) || \
  320. @@ -587,7 +587,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
  321. (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
  322. case __NR__llseek:
  323. #endif
  324. -#if !defined(__aarch64__)
  325. +#if !defined(__aarch64__) && !defined(__riscv)
  326. case __NR_poll:
  327. #endif
  328. case __NR_ppoll:
  329. @@ -608,7 +608,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
  330. case __NR_recv:
  331. #endif
  332. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  333. - defined(__aarch64__)
  334. + defined(__aarch64__) || defined(__riscv)
  335. case __NR_recvfrom: // Could specify source.
  336. case __NR_recvmsg: // Could specify source.
  337. #endif
  338. @@ -623,7 +623,7 @@ bool SyscallSets::IsAllowedGeneralIo(int sysno) {
  339. case __NR_send:
  340. #endif
  341. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  342. - defined(__aarch64__)
  343. + defined(__aarch64__) || defined(__riscv)
  344. case __NR_sendmsg: // Could specify destination.
  345. case __NR_sendto: // Could specify destination.
  346. #endif
  347. @@ -672,7 +672,7 @@ bool SyscallSets::IsSeccomp(int sysno) {
  348. bool SyscallSets::IsAllowedBasicScheduler(int sysno) {
  349. switch (sysno) {
  350. case __NR_sched_yield:
  351. -#if !defined(__aarch64__)
  352. +#if !defined(__aarch64__) && !defined(__riscv)
  353. case __NR_pause:
  354. #endif
  355. case __NR_nanosleep:
  356. @@ -756,7 +756,7 @@ bool SyscallSets::IsNuma(int sysno) {
  357. case __NR_getcpu:
  358. case __NR_mbind:
  359. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
  360. - defined(__aarch64__)
  361. + defined(__aarch64__) || defined(__riscv)
  362. case __NR_migrate_pages:
  363. #endif
  364. case __NR_move_pages:
  365. @@ -791,7 +791,7 @@ bool SyscallSets::IsGlobalProcessEnvironment(int sysno) {
  366. switch (sysno) {
  367. case __NR_acct: // Privileged.
  368. #if defined(__i386__) || defined(__x86_64__) || defined(__mips__) || \
  369. - defined(__aarch64__)
  370. + defined(__aarch64__) || defined(__riscv)
  371. case __NR_getrlimit:
  372. #endif
  373. #if defined(__i386__) || defined(__arm__)
  374. @@ -826,7 +826,7 @@ bool SyscallSets::IsDebug(int sysno) {
  375. bool SyscallSets::IsGlobalSystemStatus(int sysno) {
  376. switch (sysno) {
  377. -#if !defined(__aarch64__)
  378. +#if !defined(__aarch64__) && !defined(__riscv)
  379. case __NR__sysctl:
  380. case __NR_sysfs:
  381. #endif
  382. @@ -844,7 +844,7 @@ bool SyscallSets::IsGlobalSystemStatus(int sysno) {
  383. bool SyscallSets::IsEventFd(int sysno) {
  384. switch (sysno) {
  385. -#if !defined(__aarch64__)
  386. +#if !defined(__aarch64__) && !defined(__riscv)
  387. case __NR_eventfd:
  388. #endif
  389. case __NR_eventfd2:
  390. @@ -896,7 +896,7 @@ bool SyscallSets::IsKeyManagement(int sysno) {
  391. }
  392. #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
  393. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  394. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || defined(__riscv)
  395. bool SyscallSets::IsSystemVSemaphores(int sysno) {
  396. switch (sysno) {
  397. case __NR_semctl:
  398. @@ -915,7 +915,7 @@ bool SyscallSets::IsSystemVSemaphores(int sysno) {
  399. #endif
  400. #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
  401. - defined(__aarch64__) || \
  402. + defined(__aarch64__) || defined(__riscv) || \
  403. (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  404. // These give a lot of ambient authority and bypass the setuid sandbox.
  405. bool SyscallSets::IsSystemVSharedMemory(int sysno) {
  406. @@ -932,7 +932,8 @@ bool SyscallSets::IsSystemVSharedMemory(int sysno) {
  407. #endif
  408. #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
  409. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  410. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
  411. + defined(__riscv)
  412. bool SyscallSets::IsSystemVMessageQueue(int sysno) {
  413. switch (sysno) {
  414. case __NR_msgctl:
  415. @@ -963,7 +964,8 @@ bool SyscallSets::IsSystemVIpc(int sysno) {
  416. bool SyscallSets::IsAnySystemV(int sysno) {
  417. #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
  418. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  419. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
  420. + defined(__riscv)
  421. return IsSystemVMessageQueue(sysno) || IsSystemVSemaphores(sysno) ||
  422. IsSystemVSharedMemory(sysno);
  423. #elif defined(__i386__) || \
  424. @@ -1000,7 +1002,7 @@ bool SyscallSets::IsAdvancedScheduler(int sysno) {
  425. bool SyscallSets::IsInotify(int sysno) {
  426. switch (sysno) {
  427. case __NR_inotify_add_watch:
  428. -#if !defined(__aarch64__)
  429. +#if !defined(__aarch64__) && !defined(__riscv)
  430. case __NR_inotify_init:
  431. #endif
  432. case __NR_inotify_init1:
  433. @@ -1138,7 +1140,7 @@ bool SyscallSets::IsMisc(int sysno) {
  434. #if defined(__x86_64__)
  435. case __NR_tuxcall:
  436. #endif
  437. -#if !defined(__aarch64__)
  438. +#if !defined(__aarch64__) && !defined(__riscv)
  439. case __NR_vserver:
  440. #endif
  441. return true;
  442. @@ -1173,6 +1175,17 @@ bool SyscallSets::IsArmPrivate(int sysno) {
  443. }
  444. #endif // defined(__arm__)
  445. +#if defined(__riscv)
  446. +bool SyscallSets::IsRiscvPrivate(int sysno) {
  447. + switch (sysno) {
  448. + case __NR_riscv_flush_icache:
  449. + return true;
  450. + default:
  451. + return false;
  452. + }
  453. +}
  454. +#endif // defined(__riscv)
  455. +
  456. #if defined(__mips__)
  457. bool SyscallSets::IsMipsPrivate(int sysno) {
  458. switch (sysno) {
  459. diff --git a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
  460. index 6403f45dc2f7..7110d3f6999c 100644
  461. --- a/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
  462. +++ b/sandbox/linux/seccomp-bpf-helpers/syscall_sets.h
  463. @@ -52,7 +52,7 @@ class SANDBOX_EXPORT SyscallSets {
  464. #endif
  465. #if defined(__x86_64__) || defined(__arm__) || defined(__mips__) || \
  466. - defined(__aarch64__)
  467. + defined(__aarch64__) || defined(__riscv)
  468. static bool IsNetworkSocketInformation(int sysno);
  469. #endif
  470. @@ -79,18 +79,21 @@ class SANDBOX_EXPORT SyscallSets {
  471. static bool IsAsyncIo(int sysno);
  472. static bool IsKeyManagement(int sysno);
  473. #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
  474. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  475. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
  476. + defined(__riscv)
  477. static bool IsSystemVSemaphores(int sysno);
  478. #endif
  479. #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
  480. defined(__aarch64__) || \
  481. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  482. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
  483. + defined(__riscv)
  484. // These give a lot of ambient authority and bypass the setuid sandbox.
  485. static bool IsSystemVSharedMemory(int sysno);
  486. #endif
  487. #if defined(__x86_64__) || defined(__arm__) || defined(__aarch64__) || \
  488. - (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS))
  489. + (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_64_BITS)) || \
  490. + defined(__riscv)
  491. static bool IsSystemVMessageQueue(int sysno);
  492. #endif
  493. @@ -117,6 +120,9 @@ class SANDBOX_EXPORT SyscallSets {
  494. static bool IsMipsPrivate(int sysno);
  495. static bool IsMipsMisc(int sysno);
  496. #endif // defined(__mips__)
  497. +#if defined(__riscv)
  498. + static bool IsRiscvPrivate(int sysno);
  499. +#endif
  500. };
  501. } // namespace sandbox.
  502. diff --git a/sandbox/linux/seccomp-bpf/syscall.cc b/sandbox/linux/seccomp-bpf/syscall.cc
  503. index 2e0e810383b5..37f60d3333e0 100644
  504. --- a/sandbox/linux/seccomp-bpf/syscall.cc
  505. +++ b/sandbox/linux/seccomp-bpf/syscall.cc
  506. @@ -18,7 +18,7 @@ namespace sandbox {
  507. namespace {
  508. #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
  509. - defined(ARCH_CPU_MIPS_FAMILY)
  510. + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
  511. // Number that's not currently used by any Linux kernel ABIs.
  512. const int kInvalidSyscallNumber = 0x351d3;
  513. #else
  514. @@ -308,6 +308,28 @@ asm(// We need to be able to tell the kernel exactly where we made a
  515. "2:ret\n"
  516. ".cfi_endproc\n"
  517. ".size SyscallAsm, .-SyscallAsm\n"
  518. +#elif defined(__riscv)
  519. + ".text\n"
  520. + ".align 2\n"
  521. + ".type SyscallAsm, %function\n"
  522. + "SyscallAsm:\n"
  523. + ".cfi_startproc\n"
  524. + "bgez a0,1f\n"
  525. + "la a0,2f\n"
  526. + "j 2f\n"
  527. + "1:mv a7, a0\n"
  528. + "ld a0, (t0)\n"
  529. + "ld a1, 8(t0)\n"
  530. + "ld a2, 16(t0)\n"
  531. + "ld a3, 24(t0)\n"
  532. + "ld a4, 32(t0)\n"
  533. + "ld a5, 40(t0)\n"
  534. + "ld a6, 48(t0)\n"
  535. + // Enter the kernel
  536. + "scall\n"
  537. + "2:ret\n"
  538. + ".cfi_endproc\n"
  539. + ".size SyscallAsm, .-SyscallAsm\n"
  540. #endif
  541. ); // asm
  542. @@ -424,6 +446,17 @@ intptr_t Syscall::Call(int nr,
  543. : "memory", "x1", "x2", "x3", "x4", "x5", "x8", "x30");
  544. ret = inout;
  545. }
  546. +#elif defined(__riscv)
  547. + intptr_t ret;
  548. + {
  549. + register intptr_t inout __asm__("a0") = nr;
  550. + register const intptr_t* data __asm__("t0") = args;
  551. + asm volatile("jal SyscallAsm\n"
  552. + : "+r"(inout)
  553. + : "r"(data)
  554. + : "memory", "a1", "a2", "a3", "a4", "a5", "a6");
  555. + ret = inout;
  556. + }
  557. #else
  558. #error "Unimplemented architecture"
  559. diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
  560. index 00b969ee02a7..7fa1a42ca41c 100644
  561. --- a/sandbox/linux/services/credentials.cc
  562. +++ b/sandbox/linux/services/credentials.cc
  563. @@ -80,7 +80,7 @@ bool ChrootToSafeEmptyDir() {
  564. pid_t pid = -1;
  565. alignas(16) char stack_buf[PTHREAD_STACK_MIN];
  566. #if defined(ARCH_CPU_X86_FAMILY) || defined(ARCH_CPU_ARM_FAMILY) || \
  567. - defined(ARCH_CPU_MIPS_FAMILY)
  568. + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
  569. // The stack grows downward.
  570. void* stack = stack_buf + sizeof(stack_buf);
  571. #else
  572. diff --git a/sandbox/linux/services/syscall_wrappers.cc b/sandbox/linux/services/syscall_wrappers.cc
  573. index f863cd005141..b6d7dac2cab4 100644
  574. --- a/sandbox/linux/services/syscall_wrappers.cc
  575. +++ b/sandbox/linux/services/syscall_wrappers.cc
  576. @@ -61,7 +61,7 @@ long sys_clone(unsigned long flags,
  577. #if defined(ARCH_CPU_X86_64)
  578. return syscall(__NR_clone, flags, child_stack, ptid, ctid, tls);
  579. #elif defined(ARCH_CPU_X86) || defined(ARCH_CPU_ARM_FAMILY) || \
  580. - defined(ARCH_CPU_MIPS_FAMILY)
  581. + defined(ARCH_CPU_MIPS_FAMILY) || defined(ARCH_CPU_RISCV_FAMILY)
  582. // CONFIG_CLONE_BACKWARDS defined.
  583. return syscall(__NR_clone, flags, child_stack, ptid, tls, ctid);
  584. #endif
  585. diff --git a/sandbox/linux/syscall_broker/broker_process.cc b/sandbox/linux/syscall_broker/broker_process.cc
  586. index 7dd4688011f9..11422693463d 100644
  587. --- a/sandbox/linux/syscall_broker/broker_process.cc
  588. +++ b/sandbox/linux/syscall_broker/broker_process.cc
  589. @@ -117,44 +117,46 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
  590. // and are default disabled in Android. So, we should refuse to broker them
  591. // to be consistent with the platform's restrictions.
  592. switch (sysno) {
  593. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  594. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  595. case __NR_access:
  596. #endif
  597. case __NR_faccessat:
  598. case __NR_faccessat2:
  599. return !fast_check || policy_->allowed_command_set.test(COMMAND_ACCESS);
  600. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  601. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  602. case __NR_mkdir:
  603. #endif
  604. case __NR_mkdirat:
  605. return !fast_check || policy_->allowed_command_set.test(COMMAND_MKDIR);
  606. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  607. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  608. case __NR_open:
  609. #endif
  610. case __NR_openat:
  611. return !fast_check || policy_->allowed_command_set.test(COMMAND_OPEN);
  612. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  613. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  614. case __NR_readlink:
  615. #endif
  616. case __NR_readlinkat:
  617. return !fast_check || policy_->allowed_command_set.test(COMMAND_READLINK);
  618. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  619. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  620. case __NR_rename:
  621. #endif
  622. +#ifdef __NR_renameat
  623. case __NR_renameat:
  624. +#endif
  625. case __NR_renameat2:
  626. return !fast_check || policy_->allowed_command_set.test(COMMAND_RENAME);
  627. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  628. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  629. case __NR_rmdir:
  630. return !fast_check || policy_->allowed_command_set.test(COMMAND_RMDIR);
  631. #endif
  632. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  633. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  634. case __NR_stat:
  635. case __NR_lstat:
  636. #endif
  637. @@ -164,7 +166,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
  638. #if defined(__NR_fstatat64)
  639. case __NR_fstatat64:
  640. #endif
  641. -#if defined(__x86_64__) || defined(__aarch64__)
  642. +#if defined(__x86_64__) || defined(__aarch64__) || defined(__riscv)
  643. case __NR_newfstatat:
  644. #endif
  645. return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);
  646. @@ -179,7 +181,7 @@ bool BrokerProcess::IsSyscallBrokerable(int sysno, bool fast_check) const {
  647. return !fast_check || policy_->allowed_command_set.test(COMMAND_STAT);
  648. #endif
  649. -#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID)
  650. +#if !defined(__aarch64__) && !BUILDFLAG(IS_ANDROID) && !defined(__riscv)
  651. case __NR_unlink:
  652. return !fast_check || policy_->allowed_command_set.test(COMMAND_UNLINK);
  653. #endif
  654. diff --git a/sandbox/linux/system_headers/linux_seccomp.h b/sandbox/linux/system_headers/linux_seccomp.h
  655. index 7d898d84631a..0b144fe30c32 100644
  656. --- a/sandbox/linux/system_headers/linux_seccomp.h
  657. +++ b/sandbox/linux/system_headers/linux_seccomp.h
  658. @@ -39,6 +39,10 @@
  659. #define EM_AARCH64 183
  660. #endif
  661. +#ifndef EM_RISCV
  662. +#define EM_RISCV 243
  663. +#endif
  664. +
  665. #ifndef __AUDIT_ARCH_64BIT
  666. #define __AUDIT_ARCH_64BIT 0x80000000
  667. #endif
  668. @@ -71,6 +75,10 @@
  669. #define AUDIT_ARCH_AARCH64 (EM_AARCH64 | __AUDIT_ARCH_64BIT | __AUDIT_ARCH_LE)
  670. #endif
  671. +#ifndef AUDIT_ARCH_RISCV64
  672. +#define AUDIT_ARCH_RISCV64 (EM_RISCV|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
  673. +#endif
  674. +
  675. // For prctl.h
  676. #ifndef PR_SET_SECCOMP
  677. #define PR_SET_SECCOMP 22
  678. diff --git a/sandbox/linux/system_headers/linux_signal.h b/sandbox/linux/system_headers/linux_signal.h
  679. index 74bbb8ef8c74..db6159f754ce 100644
  680. --- a/sandbox/linux/system_headers/linux_signal.h
  681. +++ b/sandbox/linux/system_headers/linux_signal.h
  682. @@ -13,7 +13,7 @@
  683. // (not undefined, but defined different values and in different memory
  684. // layouts). So, fill the gap here.
  685. #if defined(__i386__) || defined(__x86_64__) || defined(__arm__) || \
  686. - defined(__aarch64__)
  687. + defined(__aarch64__) || defined(__riscv)
  688. #define LINUX_SIGHUP 1
  689. #define LINUX_SIGINT 2
  690. diff --git a/sandbox/linux/system_headers/linux_stat.h b/sandbox/linux/system_headers/linux_stat.h
  691. index 5f49a958499e..32ab256cfca4 100644
  692. --- a/sandbox/linux/system_headers/linux_stat.h
  693. +++ b/sandbox/linux/system_headers/linux_stat.h
  694. @@ -150,7 +150,7 @@ struct kernel_stat {
  695. int st_blocks;
  696. int st_pad4[14];
  697. };
  698. -#elif defined(__aarch64__)
  699. +#elif defined(__aarch64__) || defined(__riscv)
  700. struct kernel_stat {
  701. unsigned long st_dev;
  702. unsigned long st_ino;
  703. diff --git a/sandbox/linux/system_headers/linux_syscalls.h b/sandbox/linux/system_headers/linux_syscalls.h
  704. index 2b78a0cc3b97..968d6f71b586 100644
  705. --- a/sandbox/linux/system_headers/linux_syscalls.h
  706. +++ b/sandbox/linux/system_headers/linux_syscalls.h
  707. @@ -35,5 +35,9 @@
  708. #include "sandbox/linux/system_headers/arm64_linux_syscalls.h"
  709. #endif
  710. +#if defined(__riscv) && __riscv_xlen == 64
  711. +#include "sandbox/linux/system_headers/riscv64_linux_syscalls.h"
  712. +#endif
  713. +
  714. #endif // SANDBOX_LINUX_SYSTEM_HEADERS_LINUX_SYSCALLS_H_
  715. diff --git a/sandbox/linux/system_headers/riscv64_linux_syscalls.h b/sandbox/linux/system_headers/riscv64_linux_syscalls.h
  716. new file mode 100644
  717. index 000000000000..f8fcd06bc2f2
  718. --- /dev/null
  719. +++ b/sandbox/linux/system_headers/riscv64_linux_syscalls.h
  720. @@ -0,0 +1,1074 @@
  721. +// Copyright 2014 The Chromium Authors. All rights reserved.
  722. +// Use of this source code is governed by a BSD-style license that can be
  723. +// found in the LICENSE file.
  724. +
  725. +#ifndef SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
  726. +#define SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
  727. +
  728. +#include <asm-generic/unistd.h>
  729. +
  730. +#if !defined(__NR_io_setup)
  731. +#define __NR_io_setup 0
  732. +#endif
  733. +
  734. +#if !defined(__NR_io_destroy)
  735. +#define __NR_io_destroy 1
  736. +#endif
  737. +
  738. +#if !defined(__NR_io_submit)
  739. +#define __NR_io_submit 2
  740. +#endif
  741. +
  742. +#if !defined(__NR_io_cancel)
  743. +#define __NR_io_cancel 3
  744. +#endif
  745. +
  746. +#if !defined(__NR_io_getevents)
  747. +#define __NR_io_getevents 4
  748. +#endif
  749. +
  750. +#if !defined(__NR_setxattr)
  751. +#define __NR_setxattr 5
  752. +#endif
  753. +
  754. +#if !defined(__NR_lsetxattr)
  755. +#define __NR_lsetxattr 6
  756. +#endif
  757. +
  758. +#if !defined(__NR_fsetxattr)
  759. +#define __NR_fsetxattr 7
  760. +#endif
  761. +
  762. +#if !defined(__NR_getxattr)
  763. +#define __NR_getxattr 8
  764. +#endif
  765. +
  766. +#if !defined(__NR_lgetxattr)
  767. +#define __NR_lgetxattr 9
  768. +#endif
  769. +
  770. +#if !defined(__NR_fgetxattr)
  771. +#define __NR_fgetxattr 10
  772. +#endif
  773. +
  774. +#if !defined(__NR_listxattr)
  775. +#define __NR_listxattr 11
  776. +#endif
  777. +
  778. +#if !defined(__NR_llistxattr)
  779. +#define __NR_llistxattr 12
  780. +#endif
  781. +
  782. +#if !defined(__NR_flistxattr)
  783. +#define __NR_flistxattr 13
  784. +#endif
  785. +
  786. +#if !defined(__NR_removexattr)
  787. +#define __NR_removexattr 14
  788. +#endif
  789. +
  790. +#if !defined(__NR_lremovexattr)
  791. +#define __NR_lremovexattr 15
  792. +#endif
  793. +
  794. +#if !defined(__NR_fremovexattr)
  795. +#define __NR_fremovexattr 16
  796. +#endif
  797. +
  798. +#if !defined(__NR_getcwd)
  799. +#define __NR_getcwd 17
  800. +#endif
  801. +
  802. +#if !defined(__NR_lookup_dcookie)
  803. +#define __NR_lookup_dcookie 18
  804. +#endif
  805. +
  806. +#if !defined(__NR_eventfd2)
  807. +#define __NR_eventfd2 19
  808. +#endif
  809. +
  810. +#if !defined(__NR_epoll_create1)
  811. +#define __NR_epoll_create1 20
  812. +#endif
  813. +
  814. +#if !defined(__NR_epoll_ctl)
  815. +#define __NR_epoll_ctl 21
  816. +#endif
  817. +
  818. +#if !defined(__NR_epoll_pwait)
  819. +#define __NR_epoll_pwait 22
  820. +#endif
  821. +
  822. +#if !defined(__NR_dup)
  823. +#define __NR_dup 23
  824. +#endif
  825. +
  826. +#if !defined(__NR_dup3)
  827. +#define __NR_dup3 24
  828. +#endif
  829. +
  830. +#if !defined(__NR_fcntl)
  831. +#define __NR_fcntl 25
  832. +#endif
  833. +
  834. +#if !defined(__NR_inotify_init1)
  835. +#define __NR_inotify_init1 26
  836. +#endif
  837. +
  838. +#if !defined(__NR_inotify_add_watch)
  839. +#define __NR_inotify_add_watch 27
  840. +#endif
  841. +
  842. +#if !defined(__NR_inotify_rm_watch)
  843. +#define __NR_inotify_rm_watch 28
  844. +#endif
  845. +
  846. +#if !defined(__NR_ioctl)
  847. +#define __NR_ioctl 29
  848. +#endif
  849. +
  850. +#if !defined(__NR_ioprio_set)
  851. +#define __NR_ioprio_set 30
  852. +#endif
  853. +
  854. +#if !defined(__NR_ioprio_get)
  855. +#define __NR_ioprio_get 31
  856. +#endif
  857. +
  858. +#if !defined(__NR_flock)
  859. +#define __NR_flock 32
  860. +#endif
  861. +
  862. +#if !defined(__NR_mknodat)
  863. +#define __NR_mknodat 33
  864. +#endif
  865. +
  866. +#if !defined(__NR_mkdirat)
  867. +#define __NR_mkdirat 34
  868. +#endif
  869. +
  870. +#if !defined(__NR_unlinkat)
  871. +#define __NR_unlinkat 35
  872. +#endif
  873. +
  874. +#if !defined(__NR_symlinkat)
  875. +#define __NR_symlinkat 36
  876. +#endif
  877. +
  878. +#if !defined(__NR_linkat)
  879. +#define __NR_linkat 37
  880. +#endif
  881. +
  882. +#if !defined(__NR_renameat)
  883. +#define __NR_renameat 38
  884. +#endif
  885. +
  886. +#if !defined(__NR_umount2)
  887. +#define __NR_umount2 39
  888. +#endif
  889. +
  890. +#if !defined(__NR_mount)
  891. +#define __NR_mount 40
  892. +#endif
  893. +
  894. +#if !defined(__NR_pivot_root)
  895. +#define __NR_pivot_root 41
  896. +#endif
  897. +
  898. +#if !defined(__NR_nfsservctl)
  899. +#define __NR_nfsservctl 42
  900. +#endif
  901. +
  902. +#if !defined(__NR_statfs)
  903. +#define __NR_statfs 43
  904. +#endif
  905. +
  906. +#if !defined(__NR_fstatfs)
  907. +#define __NR_fstatfs 44
  908. +#endif
  909. +
  910. +#if !defined(__NR_truncate)
  911. +#define __NR_truncate 45
  912. +#endif
  913. +
  914. +#if !defined(__NR_ftruncate)
  915. +#define __NR_ftruncate 46
  916. +#endif
  917. +
  918. +#if !defined(__NR_fallocate)
  919. +#define __NR_fallocate 47
  920. +#endif
  921. +
  922. +#if !defined(__NR_faccessat)
  923. +#define __NR_faccessat 48
  924. +#endif
  925. +
  926. +#if !defined(__NR_chdir)
  927. +#define __NR_chdir 49
  928. +#endif
  929. +
  930. +#if !defined(__NR_fchdir)
  931. +#define __NR_fchdir 50
  932. +#endif
  933. +
  934. +#if !defined(__NR_chroot)
  935. +#define __NR_chroot 51
  936. +#endif
  937. +
  938. +#if !defined(__NR_fchmod)
  939. +#define __NR_fchmod 52
  940. +#endif
  941. +
  942. +#if !defined(__NR_fchmodat)
  943. +#define __NR_fchmodat 53
  944. +#endif
  945. +
  946. +#if !defined(__NR_fchownat)
  947. +#define __NR_fchownat 54
  948. +#endif
  949. +
  950. +#if !defined(__NR_fchown)
  951. +#define __NR_fchown 55
  952. +#endif
  953. +
  954. +#if !defined(__NR_openat)
  955. +#define __NR_openat 56
  956. +#endif
  957. +
  958. +#if !defined(__NR_close)
  959. +#define __NR_close 57
  960. +#endif
  961. +
  962. +#if !defined(__NR_vhangup)
  963. +#define __NR_vhangup 58
  964. +#endif
  965. +
  966. +#if !defined(__NR_pipe2)
  967. +#define __NR_pipe2 59
  968. +#endif
  969. +
  970. +#if !defined(__NR_quotactl)
  971. +#define __NR_quotactl 60
  972. +#endif
  973. +
  974. +#if !defined(__NR_getdents64)
  975. +#define __NR_getdents64 61
  976. +#endif
  977. +
  978. +#if !defined(__NR_lseek)
  979. +#define __NR_lseek 62
  980. +#endif
  981. +
  982. +#if !defined(__NR_read)
  983. +#define __NR_read 63
  984. +#endif
  985. +
  986. +#if !defined(__NR_write)
  987. +#define __NR_write 64
  988. +#endif
  989. +
  990. +#if !defined(__NR_readv)
  991. +#define __NR_readv 65
  992. +#endif
  993. +
  994. +#if !defined(__NR_writev)
  995. +#define __NR_writev 66
  996. +#endif
  997. +
  998. +#if !defined(__NR_pread64)
  999. +#define __NR_pread64 67
  1000. +#endif
  1001. +
  1002. +#if !defined(__NR_pwrite64)
  1003. +#define __NR_pwrite64 68
  1004. +#endif
  1005. +
  1006. +#if !defined(__NR_preadv)
  1007. +#define __NR_preadv 69
  1008. +#endif
  1009. +
  1010. +#if !defined(__NR_pwritev)
  1011. +#define __NR_pwritev 70
  1012. +#endif
  1013. +
  1014. +#if !defined(__NR_sendfile)
  1015. +#define __NR_sendfile 71
  1016. +#endif
  1017. +
  1018. +#if !defined(__NR_pselect6)
  1019. +#define __NR_pselect6 72
  1020. +#endif
  1021. +
  1022. +#if !defined(__NR_ppoll)
  1023. +#define __NR_ppoll 73
  1024. +#endif
  1025. +
  1026. +#if !defined(__NR_signalfd4)
  1027. +#define __NR_signalfd4 74
  1028. +#endif
  1029. +
  1030. +#if !defined(__NR_vmsplice)
  1031. +#define __NR_vmsplice 75
  1032. +#endif
  1033. +
  1034. +#if !defined(__NR_splice)
  1035. +#define __NR_splice 76
  1036. +#endif
  1037. +
  1038. +#if !defined(__NR_tee)
  1039. +#define __NR_tee 77
  1040. +#endif
  1041. +
  1042. +#if !defined(__NR_readlinkat)
  1043. +#define __NR_readlinkat 78
  1044. +#endif
  1045. +
  1046. +#if !defined(__NR_newfstatat)
  1047. +#define __NR_newfstatat 79
  1048. +#endif
  1049. +
  1050. +#if !defined(__NR_fstat)
  1051. +#define __NR_fstat 80
  1052. +#endif
  1053. +
  1054. +#if !defined(__NR_sync)
  1055. +#define __NR_sync 81
  1056. +#endif
  1057. +
  1058. +#if !defined(__NR_fsync)
  1059. +#define __NR_fsync 82
  1060. +#endif
  1061. +
  1062. +#if !defined(__NR_fdatasync)
  1063. +#define __NR_fdatasync 83
  1064. +#endif
  1065. +
  1066. +#if !defined(__NR_sync_file_range)
  1067. +#define __NR_sync_file_range 84
  1068. +#endif
  1069. +
  1070. +#if !defined(__NR_timerfd_create)
  1071. +#define __NR_timerfd_create 85
  1072. +#endif
  1073. +
  1074. +#if !defined(__NR_timerfd_settime)
  1075. +#define __NR_timerfd_settime 86
  1076. +#endif
  1077. +
  1078. +#if !defined(__NR_timerfd_gettime)
  1079. +#define __NR_timerfd_gettime 87
  1080. +#endif
  1081. +
  1082. +#if !defined(__NR_utimensat)
  1083. +#define __NR_utimensat 88
  1084. +#endif
  1085. +
  1086. +#if !defined(__NR_acct)
  1087. +#define __NR_acct 89
  1088. +#endif
  1089. +
  1090. +#if !defined(__NR_capget)
  1091. +#define __NR_capget 90
  1092. +#endif
  1093. +
  1094. +#if !defined(__NR_capset)
  1095. +#define __NR_capset 91
  1096. +#endif
  1097. +
  1098. +#if !defined(__NR_personality)
  1099. +#define __NR_personality 92
  1100. +#endif
  1101. +
  1102. +#if !defined(__NR_exit)
  1103. +#define __NR_exit 93
  1104. +#endif
  1105. +
  1106. +#if !defined(__NR_exit_group)
  1107. +#define __NR_exit_group 94
  1108. +#endif
  1109. +
  1110. +#if !defined(__NR_waitid)
  1111. +#define __NR_waitid 95
  1112. +#endif
  1113. +
  1114. +#if !defined(__NR_set_tid_address)
  1115. +#define __NR_set_tid_address 96
  1116. +#endif
  1117. +
  1118. +#if !defined(__NR_unshare)
  1119. +#define __NR_unshare 97
  1120. +#endif
  1121. +
  1122. +#if !defined(__NR_futex)
  1123. +#define __NR_futex 98
  1124. +#endif
  1125. +
  1126. +#if !defined(__NR_set_robust_list)
  1127. +#define __NR_set_robust_list 99
  1128. +#endif
  1129. +
  1130. +#if !defined(__NR_get_robust_list)
  1131. +#define __NR_get_robust_list 100
  1132. +#endif
  1133. +
  1134. +#if !defined(__NR_nanosleep)
  1135. +#define __NR_nanosleep 101
  1136. +#endif
  1137. +
  1138. +#if !defined(__NR_getitimer)
  1139. +#define __NR_getitimer 102
  1140. +#endif
  1141. +
  1142. +#if !defined(__NR_setitimer)
  1143. +#define __NR_setitimer 103
  1144. +#endif
  1145. +
  1146. +#if !defined(__NR_kexec_load)
  1147. +#define __NR_kexec_load 104
  1148. +#endif
  1149. +
  1150. +#if !defined(__NR_init_module)
  1151. +#define __NR_init_module 105
  1152. +#endif
  1153. +
  1154. +#if !defined(__NR_delete_module)
  1155. +#define __NR_delete_module 106
  1156. +#endif
  1157. +
  1158. +#if !defined(__NR_timer_create)
  1159. +#define __NR_timer_create 107
  1160. +#endif
  1161. +
  1162. +#if !defined(__NR_timer_gettime)
  1163. +#define __NR_timer_gettime 108
  1164. +#endif
  1165. +
  1166. +#if !defined(__NR_timer_getoverrun)
  1167. +#define __NR_timer_getoverrun 109
  1168. +#endif
  1169. +
  1170. +#if !defined(__NR_timer_settime)
  1171. +#define __NR_timer_settime 110
  1172. +#endif
  1173. +
  1174. +#if !defined(__NR_timer_delete)
  1175. +#define __NR_timer_delete 111
  1176. +#endif
  1177. +
  1178. +#if !defined(__NR_clock_settime)
  1179. +#define __NR_clock_settime 112
  1180. +#endif
  1181. +
  1182. +#if !defined(__NR_clock_gettime)
  1183. +#define __NR_clock_gettime 113
  1184. +#endif
  1185. +
  1186. +#if !defined(__NR_clock_getres)
  1187. +#define __NR_clock_getres 114
  1188. +#endif
  1189. +
  1190. +#if !defined(__NR_clock_nanosleep)
  1191. +#define __NR_clock_nanosleep 115
  1192. +#endif
  1193. +
  1194. +#if !defined(__NR_syslog)
  1195. +#define __NR_syslog 116
  1196. +#endif
  1197. +
  1198. +#if !defined(__NR_ptrace)
  1199. +#define __NR_ptrace 117
  1200. +#endif
  1201. +
  1202. +#if !defined(__NR_sched_setparam)
  1203. +#define __NR_sched_setparam 118
  1204. +#endif
  1205. +
  1206. +#if !defined(__NR_sched_setscheduler)
  1207. +#define __NR_sched_setscheduler 119
  1208. +#endif
  1209. +
  1210. +#if !defined(__NR_sched_getscheduler)
  1211. +#define __NR_sched_getscheduler 120
  1212. +#endif
  1213. +
  1214. +#if !defined(__NR_sched_getparam)
  1215. +#define __NR_sched_getparam 121
  1216. +#endif
  1217. +
  1218. +#if !defined(__NR_sched_setaffinity)
  1219. +#define __NR_sched_setaffinity 122
  1220. +#endif
  1221. +
  1222. +#if !defined(__NR_sched_getaffinity)
  1223. +#define __NR_sched_getaffinity 123
  1224. +#endif
  1225. +
  1226. +#if !defined(__NR_sched_yield)
  1227. +#define __NR_sched_yield 124
  1228. +#endif
  1229. +
  1230. +#if !defined(__NR_sched_get_priority_max)
  1231. +#define __NR_sched_get_priority_max 125
  1232. +#endif
  1233. +
  1234. +#if !defined(__NR_sched_get_priority_min)
  1235. +#define __NR_sched_get_priority_min 126
  1236. +#endif
  1237. +
  1238. +#if !defined(__NR_sched_rr_get_interval)
  1239. +#define __NR_sched_rr_get_interval 127
  1240. +#endif
  1241. +
  1242. +#if !defined(__NR_restart_syscall)
  1243. +#define __NR_restart_syscall 128
  1244. +#endif
  1245. +
  1246. +#if !defined(__NR_kill)
  1247. +#define __NR_kill 129
  1248. +#endif
  1249. +
  1250. +#if !defined(__NR_tkill)
  1251. +#define __NR_tkill 130
  1252. +#endif
  1253. +
  1254. +#if !defined(__NR_tgkill)
  1255. +#define __NR_tgkill 131
  1256. +#endif
  1257. +
  1258. +#if !defined(__NR_sigaltstack)
  1259. +#define __NR_sigaltstack 132
  1260. +#endif
  1261. +
  1262. +#if !defined(__NR_rt_sigsuspend)
  1263. +#define __NR_rt_sigsuspend 133
  1264. +#endif
  1265. +
  1266. +#if !defined(__NR_rt_sigaction)
  1267. +#define __NR_rt_sigaction 134
  1268. +#endif
  1269. +
  1270. +#if !defined(__NR_rt_sigprocmask)
  1271. +#define __NR_rt_sigprocmask 135
  1272. +#endif
  1273. +
  1274. +#if !defined(__NR_rt_sigpending)
  1275. +#define __NR_rt_sigpending 136
  1276. +#endif
  1277. +
  1278. +#if !defined(__NR_rt_sigtimedwait)
  1279. +#define __NR_rt_sigtimedwait 137
  1280. +#endif
  1281. +
  1282. +#if !defined(__NR_rt_sigqueueinfo)
  1283. +#define __NR_rt_sigqueueinfo 138
  1284. +#endif
  1285. +
  1286. +#if !defined(__NR_rt_sigreturn)
  1287. +#define __NR_rt_sigreturn 139
  1288. +#endif
  1289. +
  1290. +#if !defined(__NR_setpriority)
  1291. +#define __NR_setpriority 140
  1292. +#endif
  1293. +
  1294. +#if !defined(__NR_getpriority)
  1295. +#define __NR_getpriority 141
  1296. +#endif
  1297. +
  1298. +#if !defined(__NR_reboot)
  1299. +#define __NR_reboot 142
  1300. +#endif
  1301. +
  1302. +#if !defined(__NR_setregid)
  1303. +#define __NR_setregid 143
  1304. +#endif
  1305. +
  1306. +#if !defined(__NR_setgid)
  1307. +#define __NR_setgid 144
  1308. +#endif
  1309. +
  1310. +#if !defined(__NR_setreuid)
  1311. +#define __NR_setreuid 145
  1312. +#endif
  1313. +
  1314. +#if !defined(__NR_setuid)
  1315. +#define __NR_setuid 146
  1316. +#endif
  1317. +
  1318. +#if !defined(__NR_setresuid)
  1319. +#define __NR_setresuid 147
  1320. +#endif
  1321. +
  1322. +#if !defined(__NR_getresuid)
  1323. +#define __NR_getresuid 148
  1324. +#endif
  1325. +
  1326. +#if !defined(__NR_setresgid)
  1327. +#define __NR_setresgid 149
  1328. +#endif
  1329. +
  1330. +#if !defined(__NR_getresgid)
  1331. +#define __NR_getresgid 150
  1332. +#endif
  1333. +
  1334. +#if !defined(__NR_setfsuid)
  1335. +#define __NR_setfsuid 151
  1336. +#endif
  1337. +
  1338. +#if !defined(__NR_setfsgid)
  1339. +#define __NR_setfsgid 152
  1340. +#endif
  1341. +
  1342. +#if !defined(__NR_times)
  1343. +#define __NR_times 153
  1344. +#endif
  1345. +
  1346. +#if !defined(__NR_setpgid)
  1347. +#define __NR_setpgid 154
  1348. +#endif
  1349. +
  1350. +#if !defined(__NR_getpgid)
  1351. +#define __NR_getpgid 155
  1352. +#endif
  1353. +
  1354. +#if !defined(__NR_getsid)
  1355. +#define __NR_getsid 156
  1356. +#endif
  1357. +
  1358. +#if !defined(__NR_setsid)
  1359. +#define __NR_setsid 157
  1360. +#endif
  1361. +
  1362. +#if !defined(__NR_getgroups)
  1363. +#define __NR_getgroups 158
  1364. +#endif
  1365. +
  1366. +#if !defined(__NR_setgroups)
  1367. +#define __NR_setgroups 159
  1368. +#endif
  1369. +
  1370. +#if !defined(__NR_uname)
  1371. +#define __NR_uname 160
  1372. +#endif
  1373. +
  1374. +#if !defined(__NR_sethostname)
  1375. +#define __NR_sethostname 161
  1376. +#endif
  1377. +
  1378. +#if !defined(__NR_setdomainname)
  1379. +#define __NR_setdomainname 162
  1380. +#endif
  1381. +
  1382. +#if !defined(__NR_getrlimit)
  1383. +#define __NR_getrlimit 163
  1384. +#endif
  1385. +
  1386. +#if !defined(__NR_setrlimit)
  1387. +#define __NR_setrlimit 164
  1388. +#endif
  1389. +
  1390. +#if !defined(__NR_getrusage)
  1391. +#define __NR_getrusage 165
  1392. +#endif
  1393. +
  1394. +#if !defined(__NR_umask)
  1395. +#define __NR_umask 166
  1396. +#endif
  1397. +
  1398. +#if !defined(__NR_prctl)
  1399. +#define __NR_prctl 167
  1400. +#endif
  1401. +
  1402. +#if !defined(__NR_getcpu)
  1403. +#define __NR_getcpu 168
  1404. +#endif
  1405. +
  1406. +#if !defined(__NR_gettimeofday)
  1407. +#define __NR_gettimeofday 169
  1408. +#endif
  1409. +
  1410. +#if !defined(__NR_settimeofday)
  1411. +#define __NR_settimeofday 170
  1412. +#endif
  1413. +
  1414. +#if !defined(__NR_adjtimex)
  1415. +#define __NR_adjtimex 171
  1416. +#endif
  1417. +
  1418. +#if !defined(__NR_getpid)
  1419. +#define __NR_getpid 172
  1420. +#endif
  1421. +
  1422. +#if !defined(__NR_getppid)
  1423. +#define __NR_getppid 173
  1424. +#endif
  1425. +
  1426. +#if !defined(__NR_getuid)
  1427. +#define __NR_getuid 174
  1428. +#endif
  1429. +
  1430. +#if !defined(__NR_geteuid)
  1431. +#define __NR_geteuid 175
  1432. +#endif
  1433. +
  1434. +#if !defined(__NR_getgid)
  1435. +#define __NR_getgid 176
  1436. +#endif
  1437. +
  1438. +#if !defined(__NR_getegid)
  1439. +#define __NR_getegid 177
  1440. +#endif
  1441. +
  1442. +#if !defined(__NR_gettid)
  1443. +#define __NR_gettid 178
  1444. +#endif
  1445. +
  1446. +#if !defined(__NR_sysinfo)
  1447. +#define __NR_sysinfo 179
  1448. +#endif
  1449. +
  1450. +#if !defined(__NR_mq_open)
  1451. +#define __NR_mq_open 180
  1452. +#endif
  1453. +
  1454. +#if !defined(__NR_mq_unlink)
  1455. +#define __NR_mq_unlink 181
  1456. +#endif
  1457. +
  1458. +#if !defined(__NR_mq_timedsend)
  1459. +#define __NR_mq_timedsend 182
  1460. +#endif
  1461. +
  1462. +#if !defined(__NR_mq_timedreceive)
  1463. +#define __NR_mq_timedreceive 183
  1464. +#endif
  1465. +
  1466. +#if !defined(__NR_mq_notify)
  1467. +#define __NR_mq_notify 184
  1468. +#endif
  1469. +
  1470. +#if !defined(__NR_mq_getsetattr)
  1471. +#define __NR_mq_getsetattr 185
  1472. +#endif
  1473. +
  1474. +#if !defined(__NR_msgget)
  1475. +#define __NR_msgget 186
  1476. +#endif
  1477. +
  1478. +#if !defined(__NR_msgctl)
  1479. +#define __NR_msgctl 187
  1480. +#endif
  1481. +
  1482. +#if !defined(__NR_msgrcv)
  1483. +#define __NR_msgrcv 188
  1484. +#endif
  1485. +
  1486. +#if !defined(__NR_msgsnd)
  1487. +#define __NR_msgsnd 189
  1488. +#endif
  1489. +
  1490. +#if !defined(__NR_semget)
  1491. +#define __NR_semget 190
  1492. +#endif
  1493. +
  1494. +#if !defined(__NR_semctl)
  1495. +#define __NR_semctl 191
  1496. +#endif
  1497. +
  1498. +#if !defined(__NR_semtimedop)
  1499. +#define __NR_semtimedop 192
  1500. +#endif
  1501. +
  1502. +#if !defined(__NR_semop)
  1503. +#define __NR_semop 193
  1504. +#endif
  1505. +
  1506. +#if !defined(__NR_shmget)
  1507. +#define __NR_shmget 194
  1508. +#endif
  1509. +
  1510. +#if !defined(__NR_shmctl)
  1511. +#define __NR_shmctl 195
  1512. +#endif
  1513. +
  1514. +#if !defined(__NR_shmat)
  1515. +#define __NR_shmat 196
  1516. +#endif
  1517. +
  1518. +#if !defined(__NR_shmdt)
  1519. +#define __NR_shmdt 197
  1520. +#endif
  1521. +
  1522. +#if !defined(__NR_socket)
  1523. +#define __NR_socket 198
  1524. +#endif
  1525. +
  1526. +#if !defined(__NR_socketpair)
  1527. +#define __NR_socketpair 199
  1528. +#endif
  1529. +
  1530. +#if !defined(__NR_bind)
  1531. +#define __NR_bind 200
  1532. +#endif
  1533. +
  1534. +#if !defined(__NR_listen)
  1535. +#define __NR_listen 201
  1536. +#endif
  1537. +
  1538. +#if !defined(__NR_accept)
  1539. +#define __NR_accept 202
  1540. +#endif
  1541. +
  1542. +#if !defined(__NR_connect)
  1543. +#define __NR_connect 203
  1544. +#endif
  1545. +
  1546. +#if !defined(__NR_getsockname)
  1547. +#define __NR_getsockname 204
  1548. +#endif
  1549. +
  1550. +#if !defined(__NR_getpeername)
  1551. +#define __NR_getpeername 205
  1552. +#endif
  1553. +
  1554. +#if !defined(__NR_sendto)
  1555. +#define __NR_sendto 206
  1556. +#endif
  1557. +
  1558. +#if !defined(__NR_recvfrom)
  1559. +#define __NR_recvfrom 207
  1560. +#endif
  1561. +
  1562. +#if !defined(__NR_setsockopt)
  1563. +#define __NR_setsockopt 208
  1564. +#endif
  1565. +
  1566. +#if !defined(__NR_getsockopt)
  1567. +#define __NR_getsockopt 209
  1568. +#endif
  1569. +
  1570. +#if !defined(__NR_shutdown)
  1571. +#define __NR_shutdown 210
  1572. +#endif
  1573. +
  1574. +#if !defined(__NR_sendmsg)
  1575. +#define __NR_sendmsg 211
  1576. +#endif
  1577. +
  1578. +#if !defined(__NR_recvmsg)
  1579. +#define __NR_recvmsg 212
  1580. +#endif
  1581. +
  1582. +#if !defined(__NR_readahead)
  1583. +#define __NR_readahead 213
  1584. +#endif
  1585. +
  1586. +#if !defined(__NR_brk)
  1587. +#define __NR_brk 214
  1588. +#endif
  1589. +
  1590. +#if !defined(__NR_munmap)
  1591. +#define __NR_munmap 215
  1592. +#endif
  1593. +
  1594. +#if !defined(__NR_mremap)
  1595. +#define __NR_mremap 216
  1596. +#endif
  1597. +
  1598. +#if !defined(__NR_add_key)
  1599. +#define __NR_add_key 217
  1600. +#endif
  1601. +
  1602. +#if !defined(__NR_request_key)
  1603. +#define __NR_request_key 218
  1604. +#endif
  1605. +
  1606. +#if !defined(__NR_keyctl)
  1607. +#define __NR_keyctl 219
  1608. +#endif
  1609. +
  1610. +#if !defined(__NR_clone)
  1611. +#define __NR_clone 220
  1612. +#endif
  1613. +
  1614. +#if !defined(__NR_execve)
  1615. +#define __NR_execve 221
  1616. +#endif
  1617. +
  1618. +#if !defined(__NR_mmap)
  1619. +#define __NR_mmap 222
  1620. +#endif
  1621. +
  1622. +#if !defined(__NR_fadvise64)
  1623. +#define __NR_fadvise64 223
  1624. +#endif
  1625. +
  1626. +#if !defined(__NR_swapon)
  1627. +#define __NR_swapon 224
  1628. +#endif
  1629. +
  1630. +#if !defined(__NR_swapoff)
  1631. +#define __NR_swapoff 225
  1632. +#endif
  1633. +
  1634. +#if !defined(__NR_mprotect)
  1635. +#define __NR_mprotect 226
  1636. +#endif
  1637. +
  1638. +#if !defined(__NR_msync)
  1639. +#define __NR_msync 227
  1640. +#endif
  1641. +
  1642. +#if !defined(__NR_mlock)
  1643. +#define __NR_mlock 228
  1644. +#endif
  1645. +
  1646. +#if !defined(__NR_munlock)
  1647. +#define __NR_munlock 229
  1648. +#endif
  1649. +
  1650. +#if !defined(__NR_mlockall)
  1651. +#define __NR_mlockall 230
  1652. +#endif
  1653. +
  1654. +#if !defined(__NR_munlockall)
  1655. +#define __NR_munlockall 231
  1656. +#endif
  1657. +
  1658. +#if !defined(__NR_mincore)
  1659. +#define __NR_mincore 232
  1660. +#endif
  1661. +
  1662. +#if !defined(__NR_madvise)
  1663. +#define __NR_madvise 233
  1664. +#endif
  1665. +
  1666. +#if !defined(__NR_remap_file_pages)
  1667. +#define __NR_remap_file_pages 234
  1668. +#endif
  1669. +
  1670. +#if !defined(__NR_mbind)
  1671. +#define __NR_mbind 235
  1672. +#endif
  1673. +
  1674. +#if !defined(__NR_get_mempolicy)
  1675. +#define __NR_get_mempolicy 236
  1676. +#endif
  1677. +
  1678. +#if !defined(__NR_set_mempolicy)
  1679. +#define __NR_set_mempolicy 237
  1680. +#endif
  1681. +
  1682. +#if !defined(__NR_migrate_pages)
  1683. +#define __NR_migrate_pages 238
  1684. +#endif
  1685. +
  1686. +#if !defined(__NR_move_pages)
  1687. +#define __NR_move_pages 239
  1688. +#endif
  1689. +
  1690. +#if !defined(__NR_rt_tgsigqueueinfo)
  1691. +#define __NR_rt_tgsigqueueinfo 240
  1692. +#endif
  1693. +
  1694. +#if !defined(__NR_perf_event_open)
  1695. +#define __NR_perf_event_open 241
  1696. +#endif
  1697. +
  1698. +#if !defined(__NR_accept4)
  1699. +#define __NR_accept4 242
  1700. +#endif
  1701. +
  1702. +#if !defined(__NR_recvmmsg)
  1703. +#define __NR_recvmmsg 243
  1704. +#endif
  1705. +
  1706. +#if !defined(__NR_riscv_flush_icache)
  1707. +#define __NR_riscv_flush_icache 259
  1708. +#endif
  1709. +
  1710. +#if !defined(__NR_wait4)
  1711. +#define __NR_wait4 260
  1712. +#endif
  1713. +
  1714. +#if !defined(__NR_prlimit64)
  1715. +#define __NR_prlimit64 261
  1716. +#endif
  1717. +
  1718. +#if !defined(__NR_fanotify_init)
  1719. +#define __NR_fanotify_init 262
  1720. +#endif
  1721. +
  1722. +#if !defined(__NR_fanotify_mark)
  1723. +#define __NR_fanotify_mark 263
  1724. +#endif
  1725. +
  1726. +#if !defined(__NR_name_to_handle_at)
  1727. +#define __NR_name_to_handle_at 264
  1728. +#endif
  1729. +
  1730. +#if !defined(__NR_open_by_handle_at)
  1731. +#define __NR_open_by_handle_at 265
  1732. +#endif
  1733. +
  1734. +#if !defined(__NR_clock_adjtime)
  1735. +#define __NR_clock_adjtime 266
  1736. +#endif
  1737. +
  1738. +#if !defined(__NR_syncfs)
  1739. +#define __NR_syncfs 267
  1740. +#endif
  1741. +
  1742. +#if !defined(__NR_setns)
  1743. +#define __NR_setns 268
  1744. +#endif
  1745. +
  1746. +#if !defined(__NR_sendmmsg)
  1747. +#define __NR_sendmmsg 269
  1748. +#endif
  1749. +
  1750. +#if !defined(__NR_process_vm_readv)
  1751. +#define __NR_process_vm_readv 270
  1752. +#endif
  1753. +
  1754. +#if !defined(__NR_process_vm_writev)
  1755. +#define __NR_process_vm_writev 271
  1756. +#endif
  1757. +
  1758. +#if !defined(__NR_kcmp)
  1759. +#define __NR_kcmp 272
  1760. +#endif
  1761. +
  1762. +#if !defined(__NR_finit_module)
  1763. +#define __NR_finit_module 273
  1764. +#endif
  1765. +
  1766. +#if !defined(__NR_sched_setattr)
  1767. +#define __NR_sched_setattr 274
  1768. +#endif
  1769. +
  1770. +#if !defined(__NR_sched_getattr)
  1771. +#define __NR_sched_getattr 275
  1772. +#endif
  1773. +
  1774. +#if !defined(__NR_renameat2)
  1775. +#define __NR_renameat2 276
  1776. +#endif
  1777. +
  1778. +#if !defined(__NR_seccomp)
  1779. +#define __NR_seccomp 277
  1780. +#endif
  1781. +
  1782. +#if !defined(__NR_getrandom)
  1783. +#define __NR_getrandom 278
  1784. +#endif
  1785. +
  1786. +#if !defined(__NR_memfd_create)
  1787. +#define __NR_memfd_create 279
  1788. +#endif
  1789. +
  1790. +#if !defined(__NR_faccessat2)
  1791. +#define __NR_faccessat2 439
  1792. +#endif
  1793. +
  1794. +#endif // SANDBOX_LINUX_SYSTEM_HEADERS_RISCV64_LINUX_SYSCALLS_H_
  1795. diff --git a/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc b/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
  1796. index cd64d06ae39d..1dad48a7caae 100644
  1797. --- a/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
  1798. +++ b/sandbox/policy/linux/bpf_cros_amd_gpu_policy_linux.cc
  1799. @@ -38,7 +38,7 @@ ResultExpr CrosAmdGpuProcessPolicy::EvaluateSyscall(int sysno) const {
  1800. case __NR_sched_setscheduler:
  1801. case __NR_sysinfo:
  1802. case __NR_uname:
  1803. -#if !defined(__aarch64__)
  1804. +#if !defined(__aarch64__) && !defined(__riscv)
  1805. case __NR_readlink:
  1806. case __NR_stat:
  1807. #endif
  1808. diff --git a/sandbox/policy/linux/bpf_gpu_policy_linux.cc b/sandbox/policy/linux/bpf_gpu_policy_linux.cc
  1809. index f8df9dcbd931..4a6287aba2ef 100644
  1810. --- a/sandbox/policy/linux/bpf_gpu_policy_linux.cc
  1811. +++ b/sandbox/policy/linux/bpf_gpu_policy_linux.cc
  1812. @@ -73,7 +73,7 @@ ResultExpr GpuProcessPolicy::EvaluateSyscall(int sysno) const {
  1813. (defined(ARCH_CPU_MIPS_FAMILY) && defined(ARCH_CPU_32_BITS))
  1814. case __NR_ftruncate64:
  1815. #endif
  1816. -#if !defined(__aarch64__)
  1817. +#if !defined(__aarch64__) && !defined(__riscv)
  1818. case __NR_getdents:
  1819. #endif
  1820. case __NR_getdents64:
  1821. --
  1822. 2.30.2