diff --git a/Add-loongarch-support-for-audit-userspace.patch b/Add-loongarch-support-for-audit-userspace.patch new file mode 100644 index 0000000000000000000000000000000000000000..4f902f1677eab1c673d8f2210a6f9484af36a648 --- /dev/null +++ b/Add-loongarch-support-for-audit-userspace.patch @@ -0,0 +1,512 @@ +From fdcc1af6486f4462b43dea3728ee08106e7facf1 Mon Sep 17 00:00:00 2001 +From: Wenlong Zhang +Date: Thu, 5 Jun 2025 08:20:15 +0000 +Subject: [PATCH] Add loongarch support for audit-userspace + +--- + lib/Makefile.am | 19 ++- + lib/libaudit.c | 1 + + lib/libaudit.h | 9 ++ + lib/lookup_table.c | 7 + + lib/loongarch64_table.h | 282 ++++++++++++++++++++++++++++++++++++++++ + lib/machinetab.h | 1 + + lib/syscall-update.txt | 1 + + lib/test/lookup_test.c | 18 +++ + src/libev/ev.c | 3 + + 9 files changed, 339 insertions(+), 2 deletions(-) + create mode 100644 lib/loongarch64_table.h + +diff --git a/lib/Makefile.am b/lib/Makefile.am +index b064aa1..df81db1 100644 +--- a/lib/Makefile.am ++++ b/lib/Makefile.am +@@ -47,7 +47,8 @@ nodist_libaudit_la_SOURCES = $(BUILT_SOURCES) + BUILT_SOURCES = actiontabs.h errtabs.h fieldtabs.h flagtabs.h \ + fstypetabs.h ftypetabs.h i386_tables.h machinetabs.h \ + msg_typetabs.h optabs.h ppc_tables.h s390_tables.h \ +- s390x_tables.h x86_64_tables.h uringop_tables.h ++ s390x_tables.h x86_64_tables.h uringop_tables.h \ ++ loongarch64_tables.h + if USE_ARM + BUILT_SOURCES += arm_tables.h + endif +@@ -58,7 +59,8 @@ noinst_PROGRAMS = gen_actiontabs_h gen_errtabs_h gen_fieldtabs_h \ + gen_flagtabs_h gen_fstypetabs_h gen_ftypetabs_h gen_i386_tables_h \ + gen_machinetabs_h gen_msg_typetabs_h \ + gen_optabs_h gen_ppc_tables_h gen_s390_tables_h \ +- gen_s390x_tables_h gen_x86_64_tables_h gen_uringop_tables_h ++ gen_s390x_tables_h gen_x86_64_tables_h gen_uringop_tables_h \ ++ gen_loongarch64_tables_h + if USE_ARM + noinst_PROGRAMS += gen_arm_tables_h + endif +@@ -108,6 +110,19 @@ aarch64_tables.h: gen_aarch64_tables_h Makefile + ./gen_aarch64_tables_h --lowercase --i2s --s2i aarch64_syscall > $@ + endif + ++gen_loongarch64_tables_h_SOURCES = gen_tables.c gen_tables.h loongarch64_table.h ++gen_loongarch64_tables_h_CFLAGS = '-DTABLE_H="loongarch64_table.h"' ++$(gen_loongarch64_tables_h_OBJECTS): CC=$(CC_FOR_BUILD) ++$(gen_loongarch64_tables_h_OBJECTS): CFLAGS=$(CFLAGS_FOR_BUILD) ++$(gen_loongarch64_tables_h_OBJECTS): CPPFLAGS=$(CPPFLAGS_FOR_BUILD) ++$(gen_loongarch64_tables_h_OBJECTS): LDFLAGS=$(LDFLAGS_FOR_BUILD) ++gen_loongarch64_tables_h$(BUILD_EXEEXT): CC=$(CC_FOR_BUILD) ++gen_loongarch64_tables_h$(BUILD_EXEEXT): CFLAGS=$(CFLAGS_FOR_BUILD) ++gen_loongarch64_tables_h$(BUILD_EXEEXT): CPPFLAGS=$(CPPFLAGS_FOR_BUILD) ++gen_loongarch64_tables_h$(BUILD_EXEEXT): LDFLAGS=$(LDFLAGS_FOR_BUILD) ++loongarch64_tables.h: gen_loongarch64_tables_h Makefile ++ ./gen_loongarch64_tables_h --lowercase --i2s --s2i loongarch64_syscall > $@ ++ + gen_errtabs_h_SOURCES = gen_tables.c gen_tables.h errtab.h + gen_errtabs_h_CFLAGS = '-DTABLE_H="errtab.h"' + $(gen_errtabs_h_OBJECTS): CC=$(CC_FOR_BUILD) +diff --git a/lib/libaudit.c b/lib/libaudit.c +index b833acc..fa338b3 100644 +--- a/lib/libaudit.c ++++ b/lib/libaudit.c +@@ -1466,6 +1466,7 @@ int audit_determine_machine(const char *arch) + case MACH_86_64: /* fallthrough */ + case MACH_PPC64: /* fallthrough */ + case MACH_S390X: /* fallthrough */ ++ case MACH_LOONGARCH64: /* fallthrough */ + case MACH_IO_URING: + break; + case MACH_PPC64LE: /* 64 bit only */ +diff --git a/lib/libaudit.h b/lib/libaudit.h +index fd00832..684462d 100644 +--- a/lib/libaudit.h ++++ b/lib/libaudit.h +@@ -497,6 +497,14 @@ extern "C" { + #define EM_AARCH64 183 + #endif + ++#ifndef AUDIT_ARCH_LOONGARCH64 ++#define AUDIT_ARCH_LOONGARCH64 (EM_LOONGARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) ++#endif ++ ++#ifndef EM_LOONGARCH64 ++#define EM_LOONGARCH64 258 ++#endif ++ + #ifndef AUDIT_ARCH_AARCH64 + #define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE) + #endif +@@ -598,6 +606,7 @@ typedef enum { + MACH_ARM, + MACH_AARCH64, + MACH_PPC64LE, ++ MACH_LOONGARCH64, + MACH_IO_URING + } machine_t; + +diff --git a/lib/lookup_table.c b/lib/lookup_table.c +index d839205..16ac421 100644 +--- a/lib/lookup_table.c ++++ b/lib/lookup_table.c +@@ -46,6 +46,7 @@ + #include "s390_tables.h" + #include "s390x_tables.h" + #include "x86_64_tables.h" ++#include "loongarch64_tables.h" + #ifdef WITH_IO_URING + #include "uringop_tables.h" + #endif +@@ -73,6 +74,7 @@ static const struct int_transtab elftab[] = { + { MACH_PPC, AUDIT_ARCH_PPC }, + { MACH_S390X, AUDIT_ARCH_S390X }, + { MACH_S390, AUDIT_ARCH_S390 }, ++ { MACH_LOONGARCH64, AUDIT_ARCH_LOONGARCH64 }, + #ifdef WITH_ARM + { MACH_ARM, AUDIT_ARCH_ARM }, + #endif +@@ -140,6 +142,9 @@ int audit_name_to_syscall(const char *sc, int machine) + case MACH_S390: + found = s390_syscall_s2i(sc, &res); + break; ++ case MACH_LOONGARCH64: ++ found = loongarch64_syscall_s2i(sc, &res); ++ break; + #ifdef WITH_ARM + case MACH_ARM: + found = arm_syscall_s2i(sc, &res); +@@ -189,6 +194,8 @@ const char *audit_syscall_to_name(int sc, int machine) + return s390x_syscall_i2s(sc); + case MACH_S390: + return s390_syscall_i2s(sc); ++ case MACH_LOONGARCH64: ++ return loongarch64_syscall_i2s(sc); + #ifdef WITH_ARM + case MACH_ARM: + return arm_syscall_i2s(sc); +diff --git a/lib/loongarch64_table.h b/lib/loongarch64_table.h +new file mode 100644 +index 0000000..e8b87f8 +--- /dev/null ++++ b/lib/loongarch64_table.h +@@ -0,0 +1,282 @@ ++/* loongarch64_table.h */ ++ ++_S(0, "io_setup") ++_S(1, "io_destroy") ++_S(2, "io_submit") ++_S(3, "io_cancel") ++_S(4, "io_getevents") ++_S(5, "setxattr") ++_S(6, "lsetxattr") ++_S(7, "fsetxattr") ++_S(8, "getxattr") ++_S(9, "lgetxattr") ++_S(10, "fgetxattr") ++_S(11, "listxattr") ++_S(12, "llistxattr") ++_S(13, "flistxattr") ++_S(14, "removexattr") ++_S(15, "lremovexattr") ++_S(16, "fremovexattr") ++_S(17, "getcwd") ++_S(18, "lookup_dcookie") ++_S(19, "eventfd2") ++_S(20, "epoll_create1") ++_S(21, "epoll_ctl") ++_S(22, "epoll_pwait") ++_S(23, "dup") ++_S(24, "dup3") ++_S(25, "fcntl") ++_S(26, "inotify_init1") ++_S(27, "inotify_add_watch") ++_S(28, "inotify_rm_watch") ++_S(29, "ioctl") ++_S(30, "ioprio_set") ++_S(31, "ioprio_get") ++_S(32, "flock") ++_S(33, "mknodat") ++_S(34, "mkdirat") ++_S(35, "unlinkat") ++_S(36, "symlinkat") ++_S(37, "linkat") ++_S(38, "renameat") ++_S(39, "umount2") ++_S(40, "mount") ++_S(41, "pivot_root") ++_S(42, "nfsservctl") ++_S(43, "statfs") ++_S(44, "fstatfs") ++_S(45, "truncate") ++_S(46, "ftruncate") ++_S(47, "fallocate") ++_S(48, "faccessat") ++_S(49, "chdir") ++_S(50, "fchdir") ++_S(51, "chroot") ++_S(52, "fchmod") ++_S(53, "fchmodat") ++_S(54, "fchownat") ++_S(55, "fchown") ++_S(56, "openat") ++_S(57, "close") ++_S(58, "vhangup") ++_S(59, "pipe2") ++_S(60, "quotactl") ++_S(61, "getdents64") ++_S(62, "lseek") ++_S(63, "read") ++_S(64, "write") ++_S(65, "readv") ++_S(66, "writev") ++_S(67, "pread64") ++_S(68, "pwrite64") ++_S(69, "preadv") ++_S(70, "pwritev") ++_S(71, "sendfile") ++_S(72, "pselect6") ++_S(73, "ppoll") ++_S(74, "signalfd4") ++_S(75, "vmsplice") ++_S(76, "splice") ++_S(77, "tee") ++_S(78, "readlinkat") ++_S(79, "newfstatat") ++_S(80, "newfstat") ++_S(81, "sync") ++_S(82, "fsync") ++_S(83, "fdatasync") ++_S(84, "sync_file_range") ++_S(85, "timerfd_create") ++_S(86, "timerfd_settime") ++_S(87, "timerfd_gettime") ++_S(88, "utimensat") ++_S(89, "acct") ++_S(90, "capget") ++_S(91, "capset") ++_S(92, "personality") ++_S(93, "exit") ++_S(94, "exit_group") ++_S(95, "waitid") ++_S(96, "set_tid_address") ++_S(97, "unshare") ++_S(98, "futex") ++_S(99, "set_robust_list") ++_S(100, "get_robust_list") ++_S(101, "nanosleep") ++_S(102, "getitimer") ++_S(103, "setitimer") ++_S(104, "kexec_load") ++_S(105, "init_module") ++_S(106, "delete_module") ++_S(107, "timer_create") ++_S(108, "timer_gettime") ++_S(109, "timer_getoverrun") ++_S(110, "timer_settime") ++_S(111, "timer_delete") ++_S(112, "clock_settime") ++_S(113, "clock_gettime") ++_S(114, "clock_getres") ++_S(115, "clock_nanosleep") ++_S(116, "syslog") ++_S(117, "ptrace") ++_S(118, "sched_setparam") ++_S(119, "sched_setscheduler") ++_S(120, "sched_getscheduler") ++_S(121, "sched_getparam") ++_S(122, "sched_setaffinity") ++_S(123, "sched_getaffinity") ++_S(124, "sched_yield") ++_S(125, "sched_get_priority_max") ++_S(126, "sched_get_priority_min") ++_S(127, "sched_rr_get_interval") ++_S(128, "restart_syscall") ++_S(129, "kill") ++_S(130, "tkill") ++_S(131, "tgkill") ++_S(132, "sigaltstack") ++_S(133, "rt_sigsuspend") ++_S(134, "rt_sigaction") ++_S(135, "rt_sigprocmask") ++_S(136, "rt_sigpending") ++_S(137, "rt_sigtimedwait") ++_S(138, "rt_sigqueueinfo") ++_S(139, "rt_sigreturn") ++_S(140, "setpriority") ++_S(141, "getpriority") ++_S(142, "reboot") ++_S(143, "setregid") ++_S(144, "setgid") ++_S(145, "setreuid") ++_S(146, "setuid") ++_S(147, "setresuid") ++_S(148, "getresuid") ++_S(149, "setresgid") ++_S(150, "getresgid") ++_S(151, "setfsuid") ++_S(152, "setfsgid") ++_S(153, "times") ++_S(154, "setpgid") ++_S(155, "getpgid") ++_S(156, "getsid") ++_S(157, "setsid") ++_S(158, "getgroups") ++_S(159, "setgroups") ++_S(160, "uname") ++_S(161, "sethostname") ++_S(162, "setdomainname") ++_S(163, "getrlimit") ++_S(164, "setrlimit") ++_S(165, "getrusage") ++_S(166, "umask") ++_S(167, "prctl") ++_S(168, "getcpu") ++_S(169, "gettimeofday") ++_S(170, "settimeofday") ++_S(171, "adjtimex") ++_S(172, "getpid") ++_S(173, "getppid") ++_S(174, "getuid") ++_S(175, "geteuid") ++_S(176, "getgid") ++_S(177, "getegid") ++_S(178, "gettid") ++_S(179, "sysinfo") ++_S(180, "mq_open") ++_S(181, "mq_unlink") ++_S(182, "mq_timedsend") ++_S(183, "mq_timedreceive") ++_S(184, "mq_notify") ++_S(185, "mq_getsetattr") ++_S(186, "msgget") ++_S(187, "msgctl") ++_S(188, "msgrcv") ++_S(189, "msgsnd") ++_S(190, "semget") ++_S(191, "semctl") ++_S(192, "semtimedop") ++_S(193, "semop") ++_S(194, "shmget") ++_S(195, "shmctl") ++_S(196, "shmat") ++_S(197, "shmdt") ++_S(198, "socket") ++_S(199, "socketpair") ++_S(200, "bind") ++_S(201, "listen") ++_S(202, "accept") ++_S(203, "connect") ++_S(204, "getsockname") ++_S(205, "getpeername") ++_S(206, "sendto") ++_S(207, "recvfrom") ++_S(208, "setsockopt") ++_S(209, "getsockopt") ++_S(210, "shutdown") ++_S(211, "sendmsg") ++_S(212, "recvmsg") ++_S(213, "readahead") ++_S(214, "brk") ++_S(215, "munmap") ++_S(216, "mremap") ++_S(217, "add_key") ++_S(218, "request_key") ++_S(219, "keyctl") ++_S(220, "clone") ++_S(221, "execve") ++_S(222, "mmap") ++_S(223, "fadvise64") ++_S(224, "swapon") ++_S(225, "swapoff") ++_S(226, "mprotect") ++_S(227, "msync") ++_S(228, "mlock") ++_S(229, "munlock") ++_S(230, "mlockall") ++_S(231, "munlockall") ++_S(232, "mincore") ++_S(233, "madvise") ++_S(234, "remap_file_pages") ++_S(235, "mbind") ++_S(236, "get_mempolicy") ++_S(237, "set_mempolicy") ++_S(238, "migrate_pages") ++_S(239, "move_pages") ++_S(240, "rt_tgsigqueueinfo") ++_S(241, "perf_event_open") ++_S(242, "accept4") ++_S(243, "recvmmsg") ++_S(244, "arch_specific_syscall") ++_S(260, "wait4") ++_S(261, "prlimit64") ++_S(262, "fanotify_init") ++_S(263, "fanotify_mark") ++_S(264, "name_to_handle_at") ++_S(265, "open_by_handle_at") ++_S(266, "clock_adjtime") ++_S(267, "syncfs") ++_S(268, "setns") ++_S(269, "sendmmsg") ++_S(270, "process_vm_readv") ++_S(271, "process_vm_writev") ++_S(272, "kcmp") ++_S(273, "finit_module") ++_S(274, "sched_setattr") ++_S(275, "sched_getattr") ++_S(276, "renameat2") ++_S(277, "seccomp") ++_S(278, "getrandom") ++_S(279, "memfd_create") ++_S(280, "bpf") ++_S(281, "execveat") ++_S(282, "userfaultfd") ++_S(283, "membarrier") ++_S(284, "mlock2") ++_S(285, "copy_file_range") ++_S(286, "preadv2") ++_S(287, "pwritev2") ++_S(288, "pkey_mprotect") ++_S(289, "pkey_alloc") ++_S(290, "pkey_free") ++_S(291, "statx") ++_S(292, "io_pgetevents") ++_S(293, "rseq") ++_S(294, "syscalls") +diff --git a/lib/machinetab.h b/lib/machinetab.h +index 003869e..9213fdf 100644 +--- a/lib/machinetab.h ++++ b/lib/machinetab.h +@@ -43,6 +43,7 @@ _S(MACH_ARM, "armv7b") + _S(MACH_AARCH64, "aarch64" ) + _S(MACH_AARCH64, "armv8l") + #endif ++_S(MACH_LOONGARCH64, "loongarch64" ) + #ifdef WITH_IO_URING + _S(MACH_IO_URING, "uring") + #endif +diff --git a/lib/syscall-update.txt b/lib/syscall-update.txt +index 928df43..601dc10 100644 +--- a/lib/syscall-update.txt ++++ b/lib/syscall-update.txt +@@ -3,6 +3,7 @@ The place where syscall information is gathered is: + arch/arm/tools/syscall.tbl + arch/arm/include/uapi/asm/unistd.h (unused?) + include/uapi/asm-generic/unistd.h (aarch64) ++usr/include/asm-generic/unistd.h (loongarch64) + arch/powerpc/kernel/syscalls/syscall.tbl + arch/s390/kernel/syscalls/syscall.tbl + arch/x86/entry/syscalls/syscall_32.tbl +diff --git a/lib/test/lookup_test.c b/lib/test/lookup_test.c +index 7de7f8a..05612cf 100644 +--- a/lib/test/lookup_test.c ++++ b/lib/test/lookup_test.c +@@ -218,6 +218,23 @@ test_s390x_table(void) + #undef S2I + } + ++static void ++test_loongarch64_table(void) ++{ ++ static const struct entry t[] = { ++#include "../loongarch64_table.h" ++ }; ++ ++ printf("Testing loongarch64_table...\n"); ++#define I2S(I) audit_syscall_to_name((I), MACH_LOONGARCH64) ++#define S2I(S) audit_name_to_syscall((S), MACH_LOONGARCH64) ++ TEST_I2S(0); ++ TEST_S2I(-1); ++#undef I2S ++#undef S2I ++} ++ ++ + static void + test_x86_64_table(void) + { +@@ -409,6 +426,7 @@ main(void) + test_aarch64_table(); + #endif + test_i386_table(); ++ test_loongarch64_table(); + test_ppc_table(); + test_s390_table(); + test_s390x_table(); +diff --git a/src/libev/ev.c b/src/libev/ev.c +index 8f5e037..f188fb3 100644 +--- a/src/libev/ev.c ++++ b/src/libev/ev.c +@@ -826,6 +826,8 @@ struct signalfd_siginfo + /* GNU/Linux emulates sync on mips1 architectures, so we force its use */ + /* anybody else who still uses mips1 is supposed to send in their version, with detection code. */ + #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0" : : : "memory") ++ #elif defined __loongarch__ ++ #define ECB_MEMORY_FENCE __asm__ __volatile__ ("dbar 0" : : : "memory") + #elif defined __alpha__ + #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory") + #elif defined __sw_64__ +@@ -1555,6 +1557,7 @@ ecb_binary32_to_binary16 (uint32_t x) + || defined __sw_64__ \ + || defined __hppa__ \ + || defined __ia64__ \ ++ || defined __loongarch__ \ + || defined __m68k__ \ + || defined __m88k__ \ + || defined __sh__ \ +-- +2.43.0 + diff --git a/audit.spec b/audit.spec index 4571c7c6a27350b1953e59cd168226f964754afb..94763c2c22d3e2822c4949536ef82764af0e3a0f 100644 --- a/audit.spec +++ b/audit.spec @@ -2,7 +2,7 @@ Summary: User space tools for kernel auditing Name: audit Epoch: 1 Version: 3.1.2 -Release: 9 +Release: 10 License: GPLv2+ and LGPLv2+ URL: https://people.redhat.com/sgrubb/audit/ Source0: https://people.redhat.com/sgrubb/audit/%{name}-%{version}.tar.gz @@ -47,6 +47,7 @@ Patch35: backport-Correct-output-when-displaying-rules-with-exe-path-d.patch Patch36: backport-ausearch-format-Fix-display-of-renamed-file-411.patch Patch37: backport-Fix-a-maybe-uninitialized-warning.patch Patch38: backport-ausearch-parse-fix-parsing-for-success-uid-in-parse_.patch +Patch39: Add-loongarch-support-for-audit-userspace.patch BuildRequires: gcc swig libtool systemd kernel-headers >= 2.6.29 BuildRequires: openldap-devel krb5-devel libcap-ng-devel @@ -388,6 +389,9 @@ fi %attr(644,root,root) %{_mandir}/man8/*.8.gz %changelog +* Thu Jun 05 2025 Wenlong Zhang - 1:3.1.2-10 +- Add loongarch64 related code + * Thu May 15 2025 xuraoqing - 1:3.1.2-9 - copy audit.h do not needed, while swig compile error with flex array has been fixed