From 22a78a3e79331f83932372f576eb8338543abb0f Mon Sep 17 00:00:00 2001 From: "Frank Ch. Eigler" Date: Tue, 5 Nov 2013 16:07:54 -0500 Subject: [PATCH] CONFIG_UIDGID_STRICT_TYPE_CHECKS workaround, cont'd The stap runtime doesn't play that well with k[gu]id_t and namespaces. $SUBJECT kconfig option highlights the extent to which we use [ug]id_t. An earlier commit 857163157b8 papered over the problem to some extent; the present commit adds anothet coat of slop to cover the cracks. --- runtime/linux/runtime.h | 4 ++++ runtime/transport/ring_buffer.c | 4 ++-- tapset/linux/context.stp | 20 ++++++++++++++++++-- tapset/linux/task.stp | 2 +- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/runtime/linux/runtime.h b/runtime/linux/runtime.h index 28ede3eac..5e97a83e6 100644 --- a/runtime/linux/runtime.h +++ b/runtime/linux/runtime.h @@ -87,8 +87,12 @@ static void _stp_exit(void); #ifdef STAPCONF_TASK_UID #define STP_CURRENT_EUID (current->euid) #else +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS +#define STP_CURRENT_EUID (from_kuid_munged(current_user_ns(), task_euid(current))) +#else #define STP_CURRENT_EUID (task_euid(current)) #endif +#endif #define is_myproc() (STP_CURRENT_EUID == _stp_uid) diff --git a/runtime/transport/ring_buffer.c b/runtime/transport/ring_buffer.c index 7909263ae..43e014bae 100644 --- a/runtime/transport/ring_buffer.c +++ b/runtime/transport/ring_buffer.c @@ -758,8 +758,8 @@ static int _stp_transport_data_fs_init(void) return rc; } - __stp_entry[cpu]->d_inode->i_uid = _stp_uid; - __stp_entry[cpu]->d_inode->i_gid = _stp_gid; + __stp_entry[cpu]->d_inode->i_uid = KUIDT_INIT(_stp_uid); + __stp_entry[cpu]->d_inode->i_gid = KGIDT_INIT(_stp_gid); __stp_entry[cpu]->d_inode->i_private = &_stp_relay_data.iter[cpu]; #ifndef STP_BULKMODE diff --git a/tapset/linux/context.stp b/tapset/linux/context.stp index 585e1143e..e5b1cb685 100644 --- a/tapset/linux/context.stp +++ b/tapset/linux/context.stp @@ -1,5 +1,5 @@ // context tapset -// Copyright (C) 2005-2011 Red Hat Inc. +// Copyright (C) 2005-2013 Red Hat Inc. // Copyright (C) 2006 Intel Corporation. // // This file is part of systemtap, and is free software. You can @@ -112,9 +112,13 @@ function gid:long () %{ /* pure */ /* unprivileged */ #ifdef STAPCONF_TASK_UID STAP_RETVALUE = current->gid; +#else +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS + STAP_RETVALUE = from_kgid_munged(current_user_ns(), current_gid()); #else STAP_RETVALUE = current_gid(); #endif +#endif %} /** @@ -126,9 +130,13 @@ function egid:long () %{ /* pure */ /* unprivileged */ #ifdef STAPCONF_TASK_UID STAP_RETVALUE = current->egid; +#else +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS + STAP_RETVALUE = from_kgid_munged(current_user_ns(), current_egid()); #else STAP_RETVALUE = current_egid(); #endif +#endif %} /** @@ -141,7 +149,11 @@ function uid:long () #ifdef STAPCONF_TASK_UID STAP_RETVALUE = current->uid; #else - STAP_RETVALUE = current_uid(); +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS + STAP_RETVALUE = from_kuid_munged(current_user_ns(), current_uid()); +#else + STAP_RETVALUE = current_uid(); +#endif #endif %} @@ -154,9 +166,13 @@ function euid:long () %{ /* pure */ /* unprivileged */ #ifdef STAPCONF_TASK_UID STAP_RETVALUE = current->euid; +#else +#ifdef CONFIG_UIDGID_STRICT_TYPE_CHECKS + STAP_RETVALUE = from_kuid_munged(current_user_ns(), current_euid()); #else STAP_RETVALUE = current_euid(); #endif +#endif %} diff --git a/tapset/linux/task.stp b/tapset/linux/task.stp index e43e77f6b..1450d1f06 100644 --- a/tapset/linux/task.stp +++ b/tapset/linux/task.stp @@ -1,6 +1,6 @@ // task information tapset // Copyright (C) 2006 Intel Corporation. -// Copyright (C) 2010 Red Hat Inc. +// Copyright (C) 2010-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 -- 2.43.5