mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tony Jones <tonyj@suse.de>
To: linux-kernel@vger.kernel.org
Cc: chrisw@sous-sol.org, Tony Jones <tonyj@suse.de>,
	linux-security-module@vger.kernel.org
Subject: [RFC][PATCH 8/11] security: AppArmor - Pathname matching submodule
Date: Wed, 19 Apr 2006 10:50:10 -0700	[thread overview]
Message-ID: <20060419175010.29149.30803.sendpatchset@ermintrude.int.wirex.com> (raw)
In-Reply-To: <20060419174905.29149.67649.sendpatchset@ermintrude.int.wirex.com>

The file match.h specifies a sub module interface consisting of the following
functions:

	aamatch_alloc
	aamatch_free
		Allocates/deallocates submodule specific data used by each
		loaded profile (policy).

	aamatch_features
		Returns the list of features implemented by the submodule.
		These are literal, tailglob ("/path/**" match all paths
		below /path) and pattern (full shell based pathname expansion).

	aamatch_serialize
		Called by the module interface to serialize submodule specific
		data from userspace.

	aamatch_match
		Called to perform matching on a generated pathname.


The submodule submitted here implements only "literal" and "tailglob".
The version included with SuSE Linux implements "pattern" but via a method
that is not acceptable for mainline inclusion. We plan on developing
a new submodule as soon as possible that will implement the missing
functionality of the SuSE release using the textsearch framework and
a new bounded textsearch algorithm acceptable for subsequent inclusion
into the mainline kernel.


Signed-off-by: Tony Jones <tonyj@suse.de>

---
 security/apparmor/match/Makefile        |    5 +
 security/apparmor/match/match.h         |  132 ++++++++++++++++++++++++++++++++
 security/apparmor/match/match_default.c |   57 +++++++++++++
 3 files changed, 194 insertions(+)

--- /dev/null
+++ linux-2.6.17-rc1/security/apparmor/match/Makefile
@@ -0,0 +1,5 @@
+# Makefile for AppArmor aamatch submodule
+#
+obj-$(CONFIG_SECURITY_APPARMOR) += aamatch_default.o
+
+aamatch_default-y := match_default.o
--- /dev/null
+++ linux-2.6.17-rc1/security/apparmor/match/match.h
@@ -0,0 +1,132 @@
+/*
+ *	Copyright (C) 2002-2005 Novell/SUSE
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License as
+ *	published by the Free Software Foundation, version 2 of the
+ *	License.
+ *
+ *	AppArmor submodule (match) prototypes
+ */
+
+#ifndef __MATCH_H
+#define __MATCH_H
+
+#include "../module_interface.h"
+#include "../apparmor.h"
+
+/* The following functions implement an interface used by the primary
+ * AppArmor module to perform name matching (n.b. "AppArmor" was previously
+ * called "SubDomain").
+
+ * aamatch_alloc
+ * aamatch_free
+ * aamatch_features
+ * aamatch_serialize
+ * aamatch_match
+ *
+ * The intent is for the primary module to export (via virtual fs entries)
+ * the features provided by the submodule (aamatch_features) so that the
+ * parser may only load policy that can be supported.
+ *
+ * The primary module will call aamatch_serialize to allow the submodule
+ * to consume submodule specific data from parser data stream and will call
+ * aamatch_match to determine if a pathname matches an aa_entry.
+ */
+
+typedef int (*aamatch_serializecb)
+	(struct aa_ext *, enum aa_code, void *, const char *);
+
+/**
+ * aamatch_alloc: allocate extradata (if necessary)
+ * @type: type of entry being allocated
+ * Return value: NULL indicates no data was allocated (ERR_PTR(x) on error)
+ */
+extern void* aamatch_alloc(enum entry_match_type type);
+
+/**
+ * aamatch_free: release data allocated by aamatch_alloc
+ * @entry_extradata: data previously allocated by aamatch_alloc
+ */
+extern void aamatch_free(void *entry_extradata);
+
+/**
+ * aamatch_features: return match types supported
+ * Return value: space seperated string (of types supported - use type=value
+ * to indicate variants of a type)
+ */
+extern const char* aamatch_features(void);
+
+/**
+ * aamatch_serialize: serialize extradata
+ * @entry_extradata: data previously allocated by aamatch_alloc
+ * @e: input stream
+ * @cb: callback fn (consume incoming data stream)
+ * Return value: 0 success, -ve error
+ */
+extern int aamatch_serialize(void *entry_extradata, struct aa_ext *e,
+			     aamatch_serializecb cb);
+
+/**
+ * aamatch_match: determine if pathname matches entry
+ * @pathname: pathname to verify
+ * @entry_name: entry name
+ * @type: type of entry
+ * @entry_extradata: data previously allocated by aamatch_alloc
+ * Return value: 1 match, 0 othersise
+ */
+extern unsigned int aamatch_match(const char *pathname, const char *entry_name,
+				  enum entry_match_type type,
+				  void *entry_extradata);
+
+
+/**
+ * sd_getmatch_type - return string representation of entry_match_type
+ * @type: entry match type
+ */
+static inline const char *sd_getmatch_type(enum entry_match_type type)
+{
+	const char *names[] = {
+		"aa_entry_literal",
+		"aa_entry_tailglob",
+		"aa_entry_pattern",
+		"aa_entry_invalid"
+	};
+
+	if (type >= aa_entry_invalid) {
+		type = aa_entry_invalid;
+	}
+
+	return names[type];
+}
+
+/**
+ * aamatch_match_common - helper function to check if a pathname matches
+ * a literal/tailglob
+ * @path: path requested to search for
+ * @entry_name: name from aa_entry
+ * @type: type of entry
+ */
+static inline int aamatch_match_common(const char *path,
+					   const char *entry_name,
+			   		   enum entry_match_type type)
+{
+	int retval;
+
+	/* literal, no pattern matching characters */
+	if (type == aa_entry_literal) {
+		retval = (strcmp(entry_name, path) == 0);
+	/* trailing ** glob pattern */
+	} else if (type == aa_entry_tailglob) {
+		retval = (strncmp(entry_name, path,
+				  strlen(entry_name) - 2) == 0);
+	} else {
+		AA_WARN("%s: Invalid entry_match_type %d\n",
+			__FUNCTION__, type);
+		retval = 0;
+	}
+
+	return retval;
+}
+
+#endif /* __MATCH_H */
--- /dev/null
+++ linux-2.6.17-rc1/security/apparmor/match/match_default.c
@@ -0,0 +1,57 @@
+/*
+ *	Copyright (C) 2002-2005 Novell/SUSE
+ *
+ *	This program is free software; you can redistribute it and/or
+ *	modify it under the terms of the GNU General Public License as
+ *	published by the Free Software Foundation, version 2 of the
+ *	License.
+ *
+ *	http://forge.novell.com/modules/xfmod/project/?apparmor
+ *
+ *	AppArmor default match submodule (literal and tailglob)
+ */
+
+#include <linux/module.h>
+#include "match.h"
+
+static const char *features="literal tailglob";
+
+void* aamatch_alloc(enum entry_match_type type)
+{
+	return NULL;
+}
+
+void aamatch_free(void *ptr)
+{
+}
+
+const char *aamatch_features(void)
+{
+	return features;
+}
+
+int aamatch_serialize(void *entry_extradata, struct aa_ext *e,
+		      aamatch_serializecb cb)
+{
+	return 0;
+}
+
+unsigned int aamatch_match(const char *pathname, const char *entry_name,
+			   enum entry_match_type type, void *entry_extradata)
+{
+	int ret;
+
+	ret = aamatch_match_common(pathname, entry_name, type);
+
+	return ret;
+}
+
+EXPORT_SYMBOL_GPL(aamatch_alloc);
+EXPORT_SYMBOL_GPL(aamatch_free);
+EXPORT_SYMBOL_GPL(aamatch_features);
+EXPORT_SYMBOL_GPL(aamatch_serialize);
+EXPORT_SYMBOL_GPL(aamatch_match);
+
+MODULE_DESCRIPTION("AppArmor match module (aamatch) [default]");
+MODULE_AUTHOR("Tony Jones <tonyj@suse.de>");
+MODULE_LICENSE("GPL");

  parent reply	other threads:[~2006-04-19 17:56 UTC|newest]

Thread overview: 173+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-04-19 17:49 [RFC][PATCH 0/11] security: AppArmor - Overview Tony Jones
2006-04-19 17:49 ` [RFC][PATCH 1/11] security: AppArmor - Integrate into kbuild Tony Jones
2006-04-19 17:57   ` Arjan van de Ven
2006-04-19 18:10     ` Tony Jones
2006-04-19 18:35   ` Valdis.Kletnieks
2006-04-19 19:55   ` Adrian Bunk
2006-04-19 20:52     ` Tony Jones
2006-04-19 17:49 ` [RFC][PATCH 2/11] security: AppArmor - Core headers Tony Jones
2006-04-19 18:01   ` Arjan van de Ven
2006-04-20 17:43     ` Tony Jones
2006-04-19 17:49 ` [RFC][PATCH 3/11] security: AppArmor - LSM interface Tony Jones
2006-04-19 18:05   ` Arjan van de Ven
2006-04-19 17:49 ` [RFC][PATCH 4/11] security: AppArmor - Core access controls Tony Jones
2006-04-19 18:10   ` Arjan van de Ven
2006-04-19 18:57     ` Crispin Cowan
2006-04-19 23:05       ` Rik van Riel
2006-04-19 23:18         ` Seth Arnold
2006-04-19 23:21           ` Rik van Riel
2006-04-19 23:50             ` Crispin Cowan
2006-04-20 12:33       ` Stephen Smalley
2006-04-20 16:27         ` Lars Marowsky-Bree
2006-04-20 17:39     ` Tony Jones
2006-04-19 19:32   ` Jan Engelhardt
2006-04-19 19:50   ` Stephen Smalley
2006-04-20  9:40   ` Al Viro
2006-04-20 11:40     ` Serge E. Hallyn
2006-04-20 21:39       ` Tony Jones
2006-04-19 17:49 ` [RFC][PATCH 5/11] security: AppArmor - Filesystem Tony Jones
2006-04-21 21:13   ` Amy Griffis
2006-04-19 17:49 ` [RFC][PATCH 6/11] security: AppArmor - Userspace interface Tony Jones
2006-04-20 21:39   ` Pavel Machek
2006-04-21 18:01     ` Tony Jones
2006-04-21 18:41       ` Pavel Machek
2006-04-19 17:50 ` [RFC][PATCH 7/11] security: AppArmor - Misc (capabilities, data structures) Tony Jones
2006-04-19 18:16   ` Stephen Hemminger
2006-04-19 17:50 ` Tony Jones [this message]
2006-04-19 17:50 ` [RFC][PATCH 9/11] security: AppArmor - Audit changes Tony Jones
2006-04-21 21:21   ` Amy Griffis
2006-04-22  0:13     ` Steve Grubb
2006-04-22  0:19       ` Tony Jones
2006-04-19 17:50 ` [RFC][PATCH 10/11] security: AppArmor - Add flags to d_path Tony Jones
2006-04-19 22:12   ` Christoph Hellwig
2006-04-20  5:36     ` Tony Jones
2006-04-20  8:26       ` Arjan van de Ven
2006-04-20 16:43         ` Tony Jones
2006-04-20 17:04           ` Christoph Hellwig
2006-04-20 17:50             ` Tony Jones
2006-04-21 12:16               ` Stephen Smalley
2006-04-24 13:05       ` Alan Cox
2006-04-19 17:50 ` [RFC][PATCH 11/11] security: AppArmor - Export namespace semaphore Tony Jones
2006-04-19 22:10   ` Christoph Hellwig
2006-04-20 12:39   ` Stephen Smalley
2006-04-20 12:46     ` Serge E. Hallyn
2006-04-20 12:05       ` Stephen Smalley
2006-04-20 13:21         ` Serge E. Hallyn
2006-04-20 12:48           ` Stephen Smalley
2006-04-20 12:58             ` Stephen Smalley
2006-04-20 22:11             ` Linda A. Walsh
2006-04-20 23:05               ` Christoph Hellwig
2006-04-21  1:29                 ` Linda A. Walsh
2006-04-21  2:09                   ` Chris Wright
2006-04-21  5:10                     ` Linda Walsh
2006-04-23 12:11                       ` Arjan van de Ven
2006-04-21 14:02               ` Stephen Smalley
2006-04-20 19:45           ` Tony Jones
2006-04-20 20:16             ` Serge E. Hallyn
2006-04-20 20:22             ` James Morris
2006-04-20 21:50     ` Linda Walsh
2006-04-20 21:56       ` Al Viro
2006-04-20 23:54         ` James Morris
2006-04-21 13:59       ` Stephen Smalley
2006-04-19 18:14 ` [RFC][PATCH 0/11] security: AppArmor - Overview Arjan van de Ven
2006-04-19 22:32   ` Andi Kleen
2006-04-19 23:00     ` grundig
2006-04-19 23:38       ` Andi Kleen
2006-04-20  1:32         ` Crispin Cowan
2006-04-20 13:00           ` grundig
2006-04-20 13:09             ` Serge E. Hallyn
2006-04-20 13:15               ` Al Viro
2006-04-21  0:11               ` Tony Jones
2006-04-24 13:01             ` Alan Cox
2006-04-20  8:42     ` Arjan van de Ven
2006-04-20 19:26       ` Crispin Cowan
2006-04-20 19:27       ` Chris Wright
2006-04-21 12:18         ` Stephen Smalley
2006-04-21 17:30           ` Chris Wright
2006-04-21 18:07             ` Stephen Smalley
2006-04-21 20:06               ` Valdis.Kletnieks
2006-04-21 20:35                 ` Stephen Smalley
2006-04-21 20:44                   ` Stephen Smalley
2006-04-21 21:38                   ` Dave Neuer
2006-04-22 10:01                     ` Thomas Bleher
2006-04-24  4:18               ` Neil Brown
2006-04-24  7:03                 ` Theodore Ts'o
2006-04-24 13:04                   ` Pavel Machek
2006-04-24 13:43                     ` Joshua Brindle
2006-04-24 21:07                   ` Stephen Smalley
2006-04-24 23:52                     ` Theodore Ts'o
2006-04-25  6:22                       ` Arjan van de Ven
2006-04-25 16:45                       ` Stephen Smalley
2006-04-25 16:52                         ` Arjan van de Ven
2006-04-25 17:43                           ` Seth Arnold
2006-04-25 18:34                         ` Valdis.Kletnieks
2006-04-25 18:48                           ` Stephen Smalley
2006-04-25 18:56                             ` Valdis.Kletnieks
2006-04-25  4:25                     ` Casey Schaufler
2006-04-25  7:50                       ` James Morris
2006-04-25 12:46                         ` Theodore Ts'o
2006-04-25 15:06                           ` Stephen Smalley
2006-04-25 16:00                         ` Casey Schaufler
2006-04-25 16:21                           ` Randy.Dunlap
2006-04-26  3:42                             ` Casey Schaufler
2006-04-26 12:15                               ` Stephen Smalley
2006-04-27  0:21                                 ` Casey Schaufler
2006-04-27 14:47                                   ` Karl MacMillan
2006-04-25 17:29                           ` Stephen Smalley
2006-04-26  3:56                             ` Casey Schaufler
2006-04-26 11:32                               ` Stephen Smalley
2006-04-25 16:47                       ` Stephen Smalley
2006-04-24  7:14                 ` Arjan van de Ven
2006-04-24  8:11                   ` Lars Marowsky-Bree
2006-04-25 19:27                   ` Seth Arnold
2006-04-24 13:11                 ` Joshua Brindle
2006-04-24 13:26                   ` Andi Kleen
2006-04-24 13:39                     ` Joshua Brindle
2006-04-24 15:16                       ` Joshua Brindle
2006-04-24 15:50                         ` Tony Jones
2006-04-24 17:03                           ` Joshua Brindle
2006-04-25 17:12                         ` Valdis.Kletnieks
2006-04-25 17:34                           ` Tony Jones
2006-04-24 13:52                     ` Alan Cox
2006-04-24 14:09                       ` Andi Kleen
2006-04-24 20:45                 ` Stephen Smalley
2006-04-25  8:10                   ` Neil Brown
2006-04-25  8:28                     ` Al Viro
2006-04-25 12:42                     ` James Carter
2006-04-25 12:43                       ` Andi Kleen
2006-04-25 14:50                         ` James Carter
2006-04-25 15:01                         ` Stephen Smalley
2006-04-25 18:11                           ` Tony Jones
2006-04-25 21:25                             ` Stephen Smalley
2006-04-25 17:07                     ` Stephen Smalley
2006-04-26 22:15                       ` Some Concrete AppArmor Questions - was " Neil Brown
2006-04-26 23:06                         ` Ken Brush
2006-04-27  4:15                           ` Andi Kleen
2006-04-27  6:52                             ` Arjan van de Ven
2006-04-27  7:40                               ` Chris Wright
2006-04-27 10:17                             ` Chris Wright
2006-04-27 14:42                               ` Karl MacMillan
2006-04-27 23:44                                 ` Chris Wright
2006-04-28 13:02                                   ` Stephen Smalley
2006-04-28 15:49                                     ` Casey Schaufler
2006-04-28 16:04                                       ` Stephen Hemminger
2006-04-28 21:49                                         ` James Morris
2006-04-28 16:56                                       ` Karl MacMillan
2006-04-27 16:03                               ` Stephen Smalley
2006-04-27 22:38                                 ` Chris Wright
2006-04-28 13:00                                   ` Stephen Smalley
2006-04-27 17:43                           ` Stephen Smalley
2006-04-27 17:58                             ` Ken Brush
2006-04-28 11:28                               ` Stephen Smalley
2006-04-28 11:47                                 ` Andi Kleen
2006-04-28 12:28                                   ` Stephen Smalley
2006-04-27 11:02                         ` Christoph Hellwig
2006-04-27 11:05                           ` Andi Kleen
2006-04-20 11:29     ` Serge E. Hallyn
2006-04-20 13:24     ` Christoph Hellwig
2006-04-20 22:32     ` Linda A. Walsh
2006-04-20 12:17 ` Stephen Smalley
2006-04-20 15:38   ` Joshua Brindle
2006-04-20 19:57   ` Crispin Cowan
2006-04-21 13:34     ` Stephen Smalley
2006-04-22 12:27 ` Pavel Machek

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=20060419175010.29149.30803.sendpatchset@ermintrude.int.wirex.com \
    --to=tonyj@suse.de \
    --cc=chrisw@sous-sol.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.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

Powered by JetHome