lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Sun,  3 Jul 2016 21:45:27 +0530
From:	akash.goel@...el.com
To:	linux-kernel@...r.kernel.org, akpm@...ux-foundation.org,
	viro@...iv.linux.org.uk
Cc:	Akash Goel <akash.goel@...el.com>,
	Eduard - Gabriel Munteanu <eduard.munteanu@...ux360.ro>,
	Tom Zanussi <tzanussi@...il.com>,
	Chris Wilson <chris@...is-wilson.co.uk>
Subject: [PATCH] relay: Add global mode support for buffer-only channels

From: Akash Goel <akash.goel@...el.com>

The following patch added support to use channels with no associated files.
	relay: add buffer-only channels; useful for early logging
This is useful when the exact location of relay file is not known or the
the parent directory of relay file is not available, while creating the
channel and the logging has to start right from the boot.

But there was no provision to use global mode with buffer-only channels,
which is added by this patch, without modifying the interface where initially
there will be a dummy invocation of create_buf_file callback through which
kernel client can convey the need of a global buffer.

For the use case where drivers/kernel clients want a simple interface for the
userspace, which enables them to capture data/logs from relay file in order &
without any post processing, support of Global buffer mode is warranted.

Cc: Eduard - Gabriel Munteanu <eduard.munteanu@...ux360.ro>
Cc: Tom Zanussi <tzanussi@...il.com>
Cc: Chris Wilson <chris@...is-wilson.co.uk>
Signed-off-by: Akash Goel <akash.goel@...el.com>
---
 kernel/relay.c | 32 ++++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/kernel/relay.c b/kernel/relay.c
index 04d7cf3..b267384 100644
--- a/kernel/relay.c
+++ b/kernel/relay.c
@@ -451,6 +451,16 @@ static struct rchan_buf *relay_open_buf(struct rchan *chan, unsigned int cpu)
 		if (!dentry)
 			goto free_buf;
 		relay_set_buf_dentry(buf, dentry);
+	} else {
+		dentry = chan->cb->create_buf_file(NULL, NULL,
+					S_IRUSR, buf,
+					&chan->is_global);
+		/* We did not expected the client to return a valid dentry,
+		 * was now just looking for the global info from the client.
+		 * Now onus is on client only to release this dentry pointer.
+		 */
+		if (WARN_ON(dentry))
+			goto free_buf;
 	}
 
  	buf->cpu = cpu;
@@ -666,6 +676,27 @@ int relay_late_setup_files(struct rchan *chan,
 	}
 	chan->has_base_filename = 1;
 	chan->parent = parent;
+
+	if (chan->is_global) {
+		if (unlikely(!chan->buf[0])) {
+			WARN_ONCE(1, KERN_ERR "CPU 0 has no buffer!\n");
+			mutex_unlock(&relay_channels_mutex);
+			return -EINVAL;
+                }
+
+		dentry = relay_create_buf_file(chan, chan->buf[0], 0);
+
+		if (unlikely(!dentry))
+			err = -EINVAL;
+		else if (WARN_ON(!chan->is_global))
+			err = -EINVAL;
+		else
+			relay_set_buf_dentry(chan->buf[0], dentry);
+
+		mutex_unlock(&relay_channels_mutex);
+		return err;
+	}
+
 	curr_cpu = get_cpu();
 	/*
 	 * The CPU hotplug notifier ran before us and created buffers with
@@ -706,6 +737,7 @@ int relay_late_setup_files(struct rchan *chan,
 
 	return err;
 }
+EXPORT_SYMBOL_GPL(relay_late_setup_files);
 
 /**
  *	relay_switch_subbuf - switch to a new sub-buffer
-- 
1.9.2

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ