public inbox for linux-audit@redhat.com
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Tracy Reed <treed@ultraviolet.org>
Cc: linux-audit@redhat.com, Miloslav Trmac <mitr@redhat.com>
Subject: Re: PCI-DSS: Log every root actions/keystrokes but avoid passwords
Date: Wed, 13 Mar 2013 12:26:56 -0400	[thread overview]
Message-ID: <20130313154358.GF23106@madcap2.tricolour.ca> (raw)
In-Reply-To: <20130312210936.GT4555@tracyreed.org>

[-- Attachment #1: Type: text/plain, Size: 1348 bytes --]

On Tue, Mar 12, 2013 at 02:09:37PM -0700, Tracy Reed wrote:
> On Tue, Mar 12, 2013 at 01:47:42PM PDT, Richard Guy Briggs spake thusly:
> > I'm actually working on that right now.  I have a patch I am in the
> > process of testing.  It implements a new sysctl.  I'm working in
> > the upstream kernel, so it will likely be available in Linus' git tree
> > before anywhere else.  After that, likely fedora, then RHEL, but I'm a
> > bit new to that process.
> 
> Wow, thanks! Always glad to see good security features/auditing being added to
> the kernel. Although I'm surprised a new sysctl was necessary and it couldn't
> all be done in auditd in userspace. I look forward to reading over the code to
> learn what into this.

The necessary hooks are in the tty driver in the kernel.  Control bits
could be managed by audit in userspace, but would still need kernel
intervention.

> Please do post the patch here when you have it worked out as I am very likely
> to miss it in the flood of kernel patches when it goes to/from Linus.

Here you go.  Given Steve's good question, this control method may
change.

> Thanks again!

No worries, glad to be of service.

> Tracy Reed

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer
AMER ENG Base Operating Systems
Remote, Canada, Ottawa
Voice: 1.647.777.2635
Internal: (81) 32635

[-- Attachment #2: 0001-tty-add-a-sysctl-switch-to-avoid-logging-passwords-w.patch --]
[-- Type: text/plain, Size: 3542 bytes --]

>From 1c67c13117d3e44036a890664f7aec413a392545 Mon Sep 17 00:00:00 2001
From: Richard Guy Briggs <rgb@redhat.com>
Date: Wed, 13 Mar 2013 11:31:59 -0400
Subject: [PATCH] tty: add a sysctl switch to avoid logging passwords with audit
To: linux-audit@redhat.com

Most commands are entered one line at a time and processed as complete lines
in non-canonical mode.  Commands that interactively require a password, enter
canonical mode to do this.  This feature (icanon) can be used to avoid logging
passwords by audit while still logging the rest of the command.

The sysctl is /proc/sys/kernel/tty/audit_log_icanon with a default value of 0
to not log passwords.

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
 drivers/tty/tty_audit.c |   45 +++++++++++++++++++++++++++++++++++++++++++++
 drivers/tty/tty_io.c    |    2 ++
 include/linux/tty.h     |    4 ++++
 3 files changed, 51 insertions(+), 0 deletions(-)

diff --git a/drivers/tty/tty_audit.c b/drivers/tty/tty_audit.c
index 6953dc8..689f8d8 100644
--- a/drivers/tty/tty_audit.c
+++ b/drivers/tty/tty_audit.c
@@ -22,6 +22,49 @@ struct tty_audit_buf {
 	unsigned char *data;	/* Allocated size N_TTY_BUF_SIZE */
 };
 
+int tty_audit_log_icanon = 0;
+static int tty_audit_log_icanon_limit_min;
+static int tty_audit_log_icanon_limit_max = INT_MAX; //1?
+
+static struct ctl_table tty_table[] = {
+	{
+		.procname	= "audit_log_icanon",
+		.maxlen		= sizeof(int),
+		.mode		= 0644,
+		.data		= &tty_audit_log_icanon,
+		.proc_handler	= proc_dointvec_minmax,
+		.extra1		= &tty_audit_log_icanon_limit_min,
+		.extra2		= &tty_audit_log_icanon_limit_max,
+	},
+	{}
+};
+
+static struct ctl_table tty_kern_table[] = {
+	{
+		.procname	= "tty",
+		.mode		= 0555,
+		.child		= tty_table,
+	},
+	{}
+};
+
+static struct ctl_table tty_root_table[] = {
+	{
+		.procname	= "kernel",
+		.mode		= 0555,
+		.child		= tty_kern_table,
+	},
+	{}
+};
+
+void tty_audit_sysctl_register(void)
+{
+	struct ctl_table_header *table;
+
+	table = register_sysctl_table(tty_root_table);
+	// if error, unregister_sysctl_table(table);
+}
+
 static struct tty_audit_buf *tty_audit_buf_alloc(int major, int minor,
 						 unsigned icanon)
 {
@@ -296,6 +339,8 @@ void tty_audit_add_data(struct tty_struct *tty, unsigned char *data,
 	if (unlikely(size == 0))
 		return;
 
+	if (!tty_audit_log_icanon && icanon) return;
+
 	if (tty->driver->type == TTY_DRIVER_TYPE_PTY
 	    && tty->driver->subtype == PTY_TYPE_MASTER)
 		return;
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 05400ac..72ce653 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -3495,6 +3495,8 @@ int __init tty_init(void)
 	else
 		WARN_ON(device_create_file(consdev, &dev_attr_active) < 0);
 
+	tty_audit_sysctl_register();
+
 #ifdef CONFIG_VT
 	vty_init(&console_fops);
 #endif
diff --git a/include/linux/tty.h b/include/linux/tty.h
index c75d886..2710abe 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -544,6 +544,7 @@ extern void tty_audit_tiocsti(struct tty_struct *tty, char ch);
 extern void tty_audit_push(struct tty_struct *tty);
 extern int tty_audit_push_task(struct task_struct *tsk,
 			       kuid_t loginuid, u32 sessionid);
+extern void tty_audit_sysctl_register(void);
 #else
 static inline void tty_audit_add_data(struct tty_struct *tty,
 		unsigned char *data, size_t size, unsigned icanon)
@@ -566,6 +567,9 @@ static inline int tty_audit_push_task(struct task_struct *tsk,
 {
 	return 0;
 }
+static inline tty_audit_sysctl_register(void)
+{
+}
 #endif
 
 /* tty_ioctl.c */
-- 
1.7.1


[-- Attachment #3: Type: text/plain, Size: 0 bytes --]



  reply	other threads:[~2013-03-13 16:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-11 19:48 PCI-DSS: Log every root actions/keystrokes but avoid passwords Tracy Reed
2013-03-12 11:06 ` Miloslav Trmac
2013-03-12 20:47   ` Richard Guy Briggs
2013-03-12 21:09     ` Steve Grubb
2013-03-13 14:55       ` Richard Guy Briggs
2013-03-13 15:59         ` Steve Grubb
2013-03-13 20:24         ` Tracy Reed
2013-03-12 21:09     ` Tracy Reed
2013-03-13 16:26       ` Richard Guy Briggs [this message]
2013-03-13 16:43         ` Miloslav Trmac
2013-03-13 16:53           ` Richard Guy Briggs
2013-03-13 17:37             ` Miloslav Trmac
2013-03-14 14:56               ` Richard Guy Briggs
  -- strict thread matches above, loose matches on Subject: below --
2012-07-10  7:29 Florian Crouzat
2012-07-12 19:41 ` Thugzclub
2012-07-13  8:14   ` Florian Crouzat
2012-07-13 13:27     ` Steve Grubb
2012-07-13 13:50       ` Florian Crouzat
2012-07-13 14:11         ` Valentin Avram
2012-07-13 14:23 ` Miloslav Trmac

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130313154358.GF23106@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=mitr@redhat.com \
    --cc=treed@ultraviolet.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox