From: Harry Ciao <qingtao.cao@windriver.com>
To: <cpebenito@tresys.com>, <slawrence@tresys.com>
Cc: <selinux@tycho.nsa.gov>
Subject: Re: [v1 PATCH 3/7] Write and read TUNABLE flags in related data structures.
Date: Mon, 29 Aug 2011 16:24:02 +0800 [thread overview]
Message-ID: <4E5B4CA2.70702@windriver.com> (raw)
In-Reply-To: <1314604432-12156-3-git-send-email-qingtao.cao@windriver.com>
Please ignore this patch, I would re-send it with 0/7 patch for extra
comments for the v1 patchset.
Sorry for any inconvenience!
Thanks,
Harry
On 08/29/2011 03:53 PM, Harry Ciao wrote:
> All flags in cond_bool_datum_t and cond_node_t structures are
> written/read for policy modules which version is no less than
> MOD_POLICYDB_VERSION_TUNABLE_SEP.
>
> Note, for cond_node_t the TUNABLE flag bit would be used only at expand,
> however, it won't hurt to read/write this field for modules(potentially
> for future usage).
>
> Signed-off-by: Harry Ciao<qingtao.cao@windriver.com>
> ---
> libsepol/src/conditional.c | 21 +++++++++++++++++++--
> libsepol/src/write.c | 18 ++++++++++++++++++
> 2 files changed, 37 insertions(+), 2 deletions(-)
>
> diff --git a/libsepol/src/conditional.c b/libsepol/src/conditional.c
> index efdedb0..d9d4fee 100644
> --- a/libsepol/src/conditional.c
> +++ b/libsepol/src/conditional.c
> @@ -564,8 +564,8 @@ static int bool_isvalid(cond_bool_datum_t * b)
> return 1;
> }
>
> -int cond_read_bool(policydb_t * p
> - __attribute__ ((unused)), hashtab_t h,
> +int cond_read_bool(policydb_t * p,
> + hashtab_t h,
> struct policy_file *fp)
> {
> char *key = 0;
> @@ -597,6 +597,15 @@ int cond_read_bool(policydb_t * p
> if (rc< 0)
> goto err;
> key[len] = 0;
> +
> + if (p->policy_type != POLICY_KERN&&
> + p->policyvers>= MOD_POLICYDB_VERSION_TUNABLE_SEP) {
> + rc = next_entry(buf, fp, sizeof(uint32_t));
> + if (rc< 0)
> + goto err;
> + booldatum->flags = le32_to_cpu(buf[0]);
> + }
> +
> if (hashtab_insert(h, key, booldatum))
> goto err;
>
> @@ -810,6 +819,14 @@ static int cond_read_node(policydb_t * p, cond_node_t * node, void *fp)
> if (avrule_read_list(p,&node->avfalse_list, fp))
> goto err;
> }
> +
> + if (p->policy_type != POLICY_KERN&&
> + p->policyvers>= MOD_POLICYDB_VERSION_TUNABLE_SEP) {
> + rc = next_entry(buf, fp, sizeof(uint32_t));
> + if (rc< 0)
> + goto err;
> + node->flags = le32_to_cpu(buf[0]);
> + }
>
> return 0;
> err:
> diff --git a/libsepol/src/write.c b/libsepol/src/write.c
> index 290e036..4284c93 100644
> --- a/libsepol/src/write.c
> +++ b/libsepol/src/write.c
> @@ -607,6 +607,7 @@ static int cond_write_bool(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
> unsigned int items, items2;
> struct policy_data *pd = ptr;
> struct policy_file *fp = pd->fp;
> + struct policydb *p = pd->p;
>
> booldatum = (cond_bool_datum_t *) datum;
>
> @@ -621,6 +622,15 @@ static int cond_write_bool(hashtab_key_t key, hashtab_datum_t datum, void *ptr)
> items = put_entry(key, 1, len, fp);
> if (items != len)
> return POLICYDB_ERROR;
> +
> + if (p->policy_type != POLICY_KERN&&
> + p->policyvers>= MOD_POLICYDB_VERSION_TUNABLE_SEP) {
> + buf[0] = cpu_to_le32(booldatum->flags);
> + items = put_entry(buf, sizeof(uint32_t), 1, fp);
> + if (items != 1)
> + return POLICYDB_ERROR;
> + }
> +
> return POLICYDB_SUCCESS;
> }
>
> @@ -727,6 +737,14 @@ static int cond_write_node(policydb_t * p,
> return POLICYDB_ERROR;
> }
>
> + if (p->policy_type != POLICY_KERN&&
> + p->policyvers>= MOD_POLICYDB_VERSION_TUNABLE_SEP) {
> + buf[0] = cpu_to_le32(node->flags);
> + items = put_entry(buf, sizeof(uint32_t), 1, fp);
> + if (items != 1)
> + return POLICYDB_ERROR;
> + }
> +
> return POLICYDB_SUCCESS;
> }
>
--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.
next prev parent reply other threads:[~2011-08-29 8:24 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-29 7:53 [v1 PATCH 2/7] Separate tunable from boolean during compile Harry Ciao
2011-08-29 7:53 ` [v1 PATCH 3/7] Write and read TUNABLE flags in related data structures Harry Ciao
2011-08-29 8:24 ` Harry Ciao [this message]
2011-08-29 7:53 ` [v1 PATCH 4/7] Copy and check the cond_bool_datum_t.flags during link Harry Ciao
2011-08-29 8:24 ` Harry Ciao
2011-08-29 7:53 ` [PATCH 5/7] Permanently discard disabled branches of tunables in expansion Harry Ciao
2011-08-29 8:24 ` Harry Ciao
2011-08-29 7:53 ` [v1 PATCH 6/7] Skip tunable identifier and cond_node_t " Harry Ciao
2011-08-29 8:24 ` Harry Ciao
2011-08-29 7:53 ` [v1 PATCH 7/7] Create a new preserve_tunables flag in sepol_handle_t Harry Ciao
2011-08-29 8:25 ` Harry Ciao
2011-08-29 8:22 ` [v1 PATCH 2/7] Separate tunable from boolean during compile Harry Ciao
-- strict thread matches above, loose matches on Subject: below --
2011-08-29 8:20 v1 Discard unused tunables from raw policy Harry Ciao
2011-08-29 8:21 ` [v1 PATCH 3/7] Write and read TUNABLE flags in related data structures Harry Ciao
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=4E5B4CA2.70702@windriver.com \
--to=qingtao.cao@windriver.com \
--cc=cpebenito@tresys.com \
--cc=selinux@tycho.nsa.gov \
--cc=slawrence@tresys.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 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.