Support linux kernel earlier than 4.17 for security_cred_getsecid() 04/249604/1
authorSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 15 Dec 2020 06:49:50 +0000 (15:49 +0900)
committerSeung-Woo Kim <sw0312.kim@samsung.com>
Tue, 15 Dec 2020 08:04:53 +0000 (17:04 +0900)
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 <sw0312.kim@samsung.com>
kernel/proc-tsm.c

index 248aaa1..3f25335 100644 (file)
@@ -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++) {