这几天遇到基于海光服务器的银河麒麟V10 SP2版本操作系统出现内存无故增长问题。
排查发现auditd服务,占用了大量内存。
我的环境是银河麒麟V10 SP2 524,audit版本audit-3.0-5.se.06
==5037== HEAP SUMMARY: ==5037== in use at exit: 3,022 bytes in 210 blocks ==5037== total heap usage: 415 allocs, 205 frees, 159,455 bytes allocated ==5037== ==5037== 122 bytes in 35 blocks are definitely lost in loss record 1 of 6 ==5037== at 0x483479B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==5037== by 0x488435C: xmalloc (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x4884393: xmemdup (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x48848FF: ??? (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x4884B4C: get_file_sys_info (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x11217B: ??? (in /usr/sbin/auditd) ==5037== by 0x112D83: ??? (in /usr/sbin/auditd) ==5037== by 0x10ECA7: ??? (in /usr/sbin/auditd) ==5037== by 0x4BD0B26: (below main) (libc-start.c:308) ==5037== ==5037== 122 bytes in 35 blocks are definitely lost in loss record 2 of 6 ==5037== at 0x483479B: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so) ==5037== by 0x488435C: xmalloc (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x4884393: xmemdup (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x488494E: ??? (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x4884B4C: get_file_sys_info (in /usr/lib64/libaudit.so.1.0.0) ==5037== by 0x11217B: ??? (in /usr/sbin/auditd) ==5037== by 0x112D83: ??? (in /usr/sbin/auditd) ==5037== by 0x10ECA7: ??? (in /usr/sbin/auditd) ==5037== by 0x4BD0B26: (below main) (libc-start.c:308)
分析auditd服务存在内存泄露问题,位置在/usr/lib64/libaudit.so.1.0.0的get_file_sys_info处,malloc以后未释放。
auditd是审计服务,会对ssh的会话做日志记录,该问题出现在写日志前判断分区时的一部分代码。
经过循环ssh登录退出,也复现了这个现象。
yum update audit
升级到audit-3.0-5.se.07.ky10及以后版本即可解决
我也找到了官方发布的补丁:https://www.kylinos.cn/index.php/support/update/6.html