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

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