From b514416c974d200313014a4068f7cf8844ad38a8 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Tue, 15 Dec 2020 15:49:50 +0900 Subject: [PATCH] Support linux kernel earlier than 4.17 for security_cred_getsecid() Earlier than Linux v4.17, there was no security_cred_getsecid() and it is used to get secid for task. For the earlier kernel, use security_task_getsecid() instead. Change-Id: I7a6284adf4f316efb124a5659a1458adc0b85d1f Ref: v4.17 commit 3ec30113264a ("security: Add a cred_getsecid hook") Signed-off-by: Seung-Woo Kim --- kernel/proc-tsm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/kernel/proc-tsm.c b/kernel/proc-tsm.c index 248aaa1..3f25335 100644 --- a/kernel/proc-tsm.c +++ b/kernel/proc-tsm.c @@ -142,7 +142,11 @@ static int stability_monitor_show(struct seq_file *m, void *v) continue; } +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 17, 0) security_cred_getsecid(((struct cred *)task->real_cred), &secid); +#else + security_task_getsecid(task, &secid); +#endif if (!security_secid_to_secctx(secid, &label, &label_len)) { blacklisted = 0; for (i = 0; i < blacklist_c; i++) { -- 2.34.1