私のアプリケーションをベンチマークしたいです。これまではgnu timeを使用していますが、perfはより良い統計を生成します。
原則として、私は特定のリスクを認識するのではなく、セキュリティへの影響を理解していないので、すべてのユーザーがいくつかのセキュリティ関連タスクを実行できるようにするのではなく、専用のパフォーマンスユーザーパスに行きたいと思います。したがって、問題のパフォーマンスを低下させる編集的設定は避けたいと思います。この質問には。
読むkernel.orgのパフォーマンスセキュリティ(ドキュメントにはこれがLinux 5.9以降で動作する必要があることを示唆しているようです。)私は次のようにしました。
# addgroup perf_users
# adduser perfer
# addgroup perfer perf_users
# cd /usr/bin
# chgrp perf_users perf
# chmod o-rwx perf
# setcap "cap_perfmon,cap_sys_ptrace,cap_syslog=ep" perf
# setcap -v "cap_perfmon,cap_sys_ptrace,cap_syslog=ep" perf
返品perf: ok
。
# getcap perf
返品
perf cap_sys_ptrace,cap_syslog,cap_perfmon=ep
。
受信したリンクとは異なります。
perf = cap_sys_ptrace,cap_syslog,cap_perfmon+ep
私のLinuxは5.10.0-5-amd64 #1 SMP Debian 5.10.24-1
perf
今すぐユーザーと一緒に実行すると、perfer
エラーメッセージが表示されます。
Error:
Access to performance monitoring and observability operations is limited.
Consider adjusting /proc/sys/kernel/perf_event_paranoid setting to open
access to performance monitoring and observability operations for processes
without CAP_PERFMON, CAP_SYS_PTRACE or CAP_SYS_ADMIN Linux capability.
More information can be found at 'Perf events and tool security' document:
https://www.kernel.org/doc/html/latest/admin-guide/perf-security.html
perf_event_paranoid setting is 3:
-1: Allow use of (almost) all events by all users
Ignore mlock limit after perf_event_mlock_kb without CAP_IPC_LOCK
>= 0: Disallow raw and ftrace function tracepoint access
>= 1: Disallow CPU event access
>= 2: Disallow kernel profiling
To make the adjusted perf_event_paranoid setting permanent preserve it
in /etc/sysctl.conf (e.g. kernel.perf_event_paranoid = <setting>)
上記のすべての方法を使用してこれをバイパスしようとしました。
妄想設定を下げずにパフォーマンスを実行する方法を知っている人はいますか?
ベストアンサー1
これを行う標準的な方法には以下が含まれるが、これらに限定されない。
visudoを使用して特定のコマンドを実行するためにユーザーまたはグループを追加します。 https://www.digitalocean.com/community/tutorials/how-to-edit-the-sudoers-file
chmodを使用したSUIDまたはGUID固定ビットの設定 https://www.redhat.com/sysadmin/suid-sgid-sticky-bit