* runtime/linux/task_finder.c: Add CONFIG_UIDGID_STRICT_TYPE_CHECKS code.
* runtime/linux/task_finder2.c: Ditto.
* runtime/transport/control.c: Ditto.
* runtime/transport/transport.c: Ditto.
* runtime/linux/autoconf-uidgid.c: New autoconf test.
* buildrun.cxx (compile_pass): Add STAPCONF_LINUX_UIDGID_H autoconf test.
* runtime/procfs.c: Include uidgid_compatibility.h.
* runtime/proc_fs_compatibility.h: Move KUIDT_INIT()/KGIDT_INIT() macros
to uidgid_compatibility.h.
* runtime/transport/debugfs.c: Use KUIDT_INIT/KGIDT_INIT macros.
* runtime/transport/relay_v2.c: Ditto
* runtime/uidgid_compatibility.h: New file.
output_autoconf(s, o, "autoconf-pagefault_disable.c", "STAPCONF_PAGEFAULT_DISABLE", NULL);
output_exportconf(s, o, "kallsyms_lookup_name", "STAPCONF_KALLSYMS");
+ output_autoconf(s, o, "autoconf-uidgid.c", "STAPCONF_LINUX_UIDGID_H", NULL);
o << module_cflags << " += -include $(STAPCONF_HEADER)" << endl;
--- /dev/null
+#include <linux/cred.h>
+#include <linux/uidgid.h>
#ifndef STAPCONF_TASK_UID
#include <linux/cred.h>
#endif
+#include "../uidgid_compatibility.h"
#include "syscall.h"
#include "utrace_compatibility.h"
#include "task_finder_map.c"
#ifdef STAPCONF_TASK_UID
tsk_euid = tsk->euid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ tsk_euid = from_kuid_munged(current_user_ns(), task_euid(tsk));
#else
tsk_euid = task_euid(tsk);
+#endif
#endif
filelen = strlen(filename);
list_for_each(tgt_node, &__stp_task_finder_list) {
/* Check the thread's exe's path/pid against our list. */
#ifdef STAPCONF_TASK_UID
tsk_euid = tsk->euid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ tsk_euid = from_kuid_munged(current_user_ns(), task_euid(tsk));
#else
tsk_euid = task_euid(tsk);
+#endif
#endif
mmpathlen = strlen(mmpath);
list_for_each(tgt_node, &__stp_task_finder_list) {
#ifndef STAPCONF_TASK_UID
#include <linux/cred.h>
#endif
+#include "../uidgid_compatibility.h"
#include "syscall.h"
#include "task_finder_map.c"
#include "task_finder_vma.c"
#ifdef STAPCONF_TASK_UID
tsk_euid = tsk->euid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ tsk_euid = from_kuid_munged(current_user_ns(), task_euid(tsk));
#else
tsk_euid = task_euid(tsk);
+#endif
#endif
filelen = strlen(filename);
list_for_each(tgt_node, &__stp_task_finder_list) {
/* Check the thread's exe's path/pid against our list. */
#ifdef STAPCONF_TASK_UID
tsk_euid = tsk->euid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ tsk_euid = from_kuid_munged(current_user_ns(), task_euid(tsk));
#else
tsk_euid = task_euid(tsk);
+#endif
#endif
mmpathlen = strlen(mmpath);
list_for_each(tgt_node, &__stp_task_finder_list) {
* some of the new interface's functions. */
#ifndef STAPCONF_PDE_DATA
-#ifndef KUIDT_INIT
-#define KUIDT_INIT(value) ((uid_t) value)
-#define KGIDT_INIT(value) ((gid_t) value)
-
+#ifndef STAPCONF_LINUX_UIDGID_H
static void proc_set_user(struct proc_dir_entry *de, uid_t uid, gid_t gid)
{
de->uid = uid;
#include <linux/pid_namespace.h>
#endif
#include "proc_fs_compatibility.h"
+#include "uidgid_compatibility.h"
#if defined(STAPCONF_PATH_LOOKUP) && !defined(STAPCONF_KERN_PATH_PARENT)
#define kern_path_parent(name, nameidata) \
#include "symbols.c"
#include <linux/delay.h>
#include <linux/poll.h>
+#include "../uidgid_compatibility.h"
static _stp_mempool_t *_stp_pool_q;
static struct list_head _stp_ctl_ready_q;
#ifdef STAPCONF_TASK_UID
uid_t euid = current->euid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ uid_t euid = from_kuid_munged(current_user_ns(), current_euid());
#else
uid_t euid = current_euid();
+#endif
#endif
if (count < sizeof(u32))
#include <linux/debugfs.h>
#include "transport.h"
+#include "../uidgid_compatibility.h"
/* Defines the number of buffers allocated in control.c (which #includes
this file) for the _stp_pool_q. This is the number of .cmd messages
return -1;
}
- _stp_cmd_file->d_inode->i_uid = _stp_uid;
- _stp_cmd_file->d_inode->i_gid = _stp_gid;
+ _stp_cmd_file->d_inode->i_uid = KUIDT_INIT(_stp_uid);
+ _stp_cmd_file->d_inode->i_gid = KGIDT_INIT(_stp_gid);
return 0;
}
#include <linux/mm.h>
#include <linux/relay.h>
#include <linux/timer.h>
+#include "../uidgid_compatibility.h"
#ifndef STP_RELAY_TIMER_INTERVAL
/* Wakeup timer interval in jiffies (default 10 ms) */
file = NULL;
}
else if (file) {
- file->d_inode->i_uid = _stp_uid;
- file->d_inode->i_gid = _stp_gid;
+ file->d_inode->i_uid = KUIDT_INIT(_stp_uid);
+ file->d_inode->i_gid = KGIDT_INIT(_stp_gid);
}
return file;
}
goto err;
}
- _stp_relay_data.dropped_file->d_inode->i_uid = _stp_uid;
- _stp_relay_data.dropped_file->d_inode->i_gid = _stp_gid;
+ _stp_relay_data.dropped_file->d_inode->i_uid = KUIDT_INIT(_stp_uid);
+ _stp_relay_data.dropped_file->d_inode->i_gid = KGIDT_INIT(_stp_gid);
/* Create "trace" file. */
npages = _stp_subbuf_size * _stp_nsubbufs;
#include <linux/namei.h>
#include <linux/delay.h>
#include <linux/mutex.h>
+#include "../uidgid_compatibility.h"
static int _stp_exit_flag = 0;
#ifdef STAPCONF_TASK_UID
_stp_uid = current->uid;
_stp_gid = current->gid;
+#else
+#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS
+ _stp_uid = from_kuid_munged(current_user_ns(), current_uid());
+ _stp_gid = from_kgid_munged(current_user_ns(), current_gid());
#else
_stp_uid = current_uid();
_stp_gid = current_gid();
#endif
+#endif
/* PR13489, missing inode-uprobes symbol-export workaround */
#if !defined(STAPCONF_TASK_USER_REGSET_VIEW_EXPORTED) && !defined(STAPCONF_UTRACE_REGSET) /* RHEL5 era utrace */
--- /dev/null
+/*
+ * uidgid.h compatibility defines and inlines
+ * Copyright (C) 2013 Red Hat Inc.
+ *
+ * This file is part of systemtap, and is free software. You can
+ * redistribute it and/or modify it under the terms of the GNU General
+ * Public License (GPL); either version 2, or (at your option) any
+ * later version.
+ */
+
+#ifndef _UIDGID_COMPATIBILITY_H_
+#define _UIDGID_COMPATIBILITY_H_
+
+#ifndef STAPCONF_LINUX_UIDGID_H
+
+#define KUIDT_INIT(value) ((uid_t) value)
+#define KGIDT_INIT(value) ((gid_t) value)
+
+#else
+
+#include <linux/cred.h>
+#include <linux/uidgid.h>
+
+#endif
+
+#endif /* _UIDGID_COMPATIBILITY_H_ */