All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gary Tierney <gary.tierney@gmx.com>
To: selinux@tycho.nsa.gov
Subject: Filtering an avtab in libsepol
Date: Tue, 6 Dec 2016 17:00:55 +0000	[thread overview]
Message-ID: <20161206170055.GA30914@workstation> (raw)

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

Hi,

I've been working on optimizing out AV rules with no applicable types as 
well as unused attributes to trim down the size of a policy which uses 
CIL blocks and attributes extensively.  Looking into the avtab code (and 
how creating a new avtab is implemented in expand.c) I have a question:

Does the following suffice for taking an existing avtab and creating a 
new one with all of its elements?  Or do I need to consider 
avtab_insert_nonunique() like expand.c does?  If I'm following the 
expand_avtab() code correctly, I'd think I'd need to consider conditional 
avtabs in the following code:

static int copy_avtab_map_fn(avtab_key_t *key, avtab_datum_t *datum,
			     void *args)
{
	avtab_t *avtab = (avtab_t *) args;

	return avtab_insert(avtab, key, datum);
}

static int copy_avtab(avtab_t *avtab, avtab_t **out)
{
	avtab_t *tmp = NULL;
	if (avtab_init(tmp)) {
		return POLICYDB_ERROR;
	}

	if (avtab_alloc(tmp, MAX_AVTAB_SIZE)) {
		return POLICYDB_ERROR;
	}

	if (avtab_map(avtab, copy_avtab_map_fn, tmp)) {
		return POLICYDB_ERROR;
	}

	*out = tmp;
	return POLICYDB_SUCCESS;
}

Is that the right idea?

Thanks.

-- 
Gary Tierney
 
GPG fingerprint: 412C 0EF9 C305 68E6 B660BDAF 706E D765 85AA 79D8
https://sks-keyservers.net/pks/lookup?op=get&search=0x706ED76585AA79D8 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 473 bytes --]

             reply	other threads:[~2016-12-06 17:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-06 17:00 Gary Tierney [this message]
2016-12-06 17:53 ` Filtering an avtab in libsepol Stephen Smalley
2016-12-06 18:05   ` Gary Tierney
2016-12-06 18:06   ` Stephen Smalley
2016-12-06 21:32     ` Gary Tierney

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=20161206170055.GA30914@workstation \
    --to=gary.tierney@gmx.com \
    --cc=selinux@tycho.nsa.gov \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.