0002-sandbox-add-riscv-arch-definition-and-define-syscall.patch 47 KB

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