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

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