Linux-audit Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Guy Briggs <rgb@redhat.com>
To: Steve Grubb <sgrubb@redhat.com>
Cc: linux-audit@redhat.com
Subject: Re: logging changes in tty logging status
Date: Thu, 14 Nov 2013 09:16:15 -0500	[thread overview]
Message-ID: <20131114141615.GN24236@madcap2.tricolour.ca> (raw)
In-Reply-To: <9487947.oMiZKbm04c@x2>

On Wed, Nov 13, 2013 at 03:22:49PM -0500, Steve Grubb wrote:
> On Wednesday, November 13, 2013 03:04:18 PM Richard Guy Briggs wrote:
> > Hi Steve,
> > 
> > I'm reviewing audit_receive_msg() and noticing that the AUDIT_TTY_SET
> > case doesn't log a configuration change.  Should it?
> 
> Yes, it should. Any change in config should be recorded with subject, old 
> value, new value, and results. It should match other config change events.

So perhaps something like this, but should probably re-structure the
code to make it cleaner and re-factor a formatting function...

Any opinion on the labels/tags?

diff --git a/kernel/audit.c b/kernel/audit.c
index 7b0e23a..cba0109 100644
--- a/kernel/audit.c
+++ b/kernel/audit.c
@@ -829,18 +829,36 @@ static int audit_receive_msg(struct sk_buff *skb, struct nlmsghdr *nlh)
 	case AUDIT_TTY_SET: {
 		struct audit_tty_status s;
 		struct task_struct *tsk = current;
+		struct audit_buffer	*ab;
 
 		memset(&s, 0, sizeof(s));
 		/* guard against past and future API changes */
 		memcpy(&s, data, min(sizeof(s), (size_t)nlh->nlmsg_len));
+		audit_log_common_recv_msg(&ab, AUDIT_CONFIG_CHANGE);
+		audit_log_format(ab, " old.audit_tty_status.enabled=%d"
+				 " old.audit_tty_status.log_passwd=%d",
+				 tsk->signal->audit_tty,
+				 tsk->signal->audit_tty_log_passwd);
+		audit_log_format(ab, " new.audit_tty_status.enabled=%d"
+				 " new.audit_tty_status.log_passwd=%d",
+				 s.enabled, s.log_passwd);
 		if ((s.enabled != 0 && s.enabled != 1) ||
 		    (s.log_passwd != 0 && s.log_passwd != 1))
-			return -EINVAL;
+{
+			audit_log_format(ab, " res=0");
+			audit_log_end(ab);
 
+			return -EINVAL;
+}
 		spin_lock(&tsk->sighand->siglock);
 		tsk->signal->audit_tty = s.enabled;
 		tsk->signal->audit_tty_log_passwd = s.log_passwd;
 		spin_unlock(&tsk->sighand->siglock);
+
+		audit_log_format(ab, " res=1");
+		audit_log_end(ab);
+
+
 		break;
 	}
 	default:

> -Steve

- RGB

--
Richard Guy Briggs <rbriggs@redhat.com>
Senior Software Engineer, Kernel Security, AMER ENG Base Operating Systems, Red Hat
Remote, Ottawa, Canada
Voice: +1.647.777.2635, Internal: (81) 32635, Alt: +1.613.693.0684x3545

  reply	other threads:[~2013-11-14 14:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-13 20:04 logging changes in tty logging status Richard Guy Briggs
2013-11-13 20:22 ` Steve Grubb
2013-11-14 14:16   ` Richard Guy Briggs [this message]
2013-11-14 20:43     ` Richard Guy Briggs

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=20131114141615.GN24236@madcap2.tricolour.ca \
    --to=rgb@redhat.com \
    --cc=linux-audit@redhat.com \
    --cc=sgrubb@redhat.com \
    /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