https://github.com/torvalds/linux
Revision 07496eeab577eef1d4912b3e1b502a2b52002ac3 authored by Ross Zwisler on 15 February 2023, 22:33:49 UTC, committed by Michael S. Tsirkin on 09 June 2023, 16:08:08 UTC
The canonical location for the tracefs filesystem is at /sys/kernel/tracing.

But, from Documentation/trace/ftrace.rst:

  Before 4.1, all ftrace tracing control files were within the debugfs
  file system, which is typically located at /sys/kernel/debug/tracing.
  For backward compatibility, when mounting the debugfs file system,
  the tracefs file system will be automatically mounted at:

  /sys/kernel/debug/tracing

A few spots in tools/virtio still refer to this older debugfs
path, so let's update them to avoid confusion.

Signed-off-by: Ross Zwisler <zwisler@google.com>
Message-Id: <20230215223350.2658616-6-zwisler@google.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Mukesh Ojha <quic_mojha@quicinc.com>
1 parent beee7fd
Raw File
Tip revision: 07496eeab577eef1d4912b3e1b502a2b52002ac3 authored by Ross Zwisler on 15 February 2023, 22:33:49 UTC
tools/virtio: use canonical ftrace path
Tip revision: 07496ee
pid_sysctl.h
/* SPDX-License-Identifier: GPL-2.0 */
#ifndef LINUX_PID_SYSCTL_H
#define LINUX_PID_SYSCTL_H

#include <linux/pid_namespace.h>

#if defined(CONFIG_SYSCTL) && defined(CONFIG_MEMFD_CREATE)
static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns)
{
	ns->memfd_noexec_scope =
		task_active_pid_ns(current)->memfd_noexec_scope;
}

static int pid_mfd_noexec_dointvec_minmax(struct ctl_table *table,
	int write, void *buf, size_t *lenp, loff_t *ppos)
{
	struct pid_namespace *ns = task_active_pid_ns(current);
	struct ctl_table table_copy;

	if (write && !ns_capable(ns->user_ns, CAP_SYS_ADMIN))
		return -EPERM;

	table_copy = *table;
	if (ns != &init_pid_ns)
		table_copy.data = &ns->memfd_noexec_scope;

	/*
	 * set minimum to current value, the effect is only bigger
	 * value is accepted.
	 */
	if (*(int *)table_copy.data > *(int *)table_copy.extra1)
		table_copy.extra1 = table_copy.data;

	return proc_dointvec_minmax(&table_copy, write, buf, lenp, ppos);
}

static struct ctl_table pid_ns_ctl_table_vm[] = {
	{
		.procname	= "memfd_noexec",
		.data		= &init_pid_ns.memfd_noexec_scope,
		.maxlen		= sizeof(init_pid_ns.memfd_noexec_scope),
		.mode		= 0644,
		.proc_handler	= pid_mfd_noexec_dointvec_minmax,
		.extra1		= SYSCTL_ZERO,
		.extra2		= SYSCTL_TWO,
	},
	{ }
};
static inline void register_pid_ns_sysctl_table_vm(void)
{
	register_sysctl("vm", pid_ns_ctl_table_vm);
}
#else
static inline void initialize_memfd_noexec_scope(struct pid_namespace *ns) {}
static inline void set_memfd_noexec_scope(struct pid_namespace *ns) {}
static inline void register_pid_ns_sysctl_table_vm(void) {}
#endif

#endif /* LINUX_PID_SYSCTL_H */
back to top