[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20061213130646.GE3851@stusta.de>
Date: Wed, 13 Dec 2006 14:06:46 +0100
From: Adrian Bunk <bunk@...sta.de>
To: Andrew Morton <akpm@...l.org>, Kylene Jo Hall <kjhall@...ibm.com>
Cc: linux-kernel@...r.kernel.org, Mimi Zohar <zohar@...ibm.com>,
chrisw@...s-sol.org, linux-security-module@...r.kernel.org
Subject: [-mm patch] slm_set_taskperm(): remove horrible error handling code
Error handling:
Pass something you memset'ed to 0 to functions that never change it but
dereference it in dprintk()'s.
This patch removes this broken code - plain Oops'es aren't worse.
As a bonus, this function no longer wastes more than 2 kB stack space.
Signed-off-by: Adrian Bunk <bunk@...sta.de>
---
security/slim/slm_main.c | 19 +++----------------
1 file changed, 3 insertions(+), 16 deletions(-)
--- linux-2.6.19-mm1/security/slim/slm_main.c.old 2006-12-13 02:58:34.000000000 +0100
+++ linux-2.6.19-mm1/security/slim/slm_main.c 2006-12-13 03:00:06.000000000 +0100
@@ -608,34 +608,21 @@
struct slm_tsec_data *parent_tsec)
{
return enforce_integrity_write(level, name, parent_tsk, parent_tsec);
}
static int slm_set_taskperm(int mask, struct slm_file_xattr *level,
const unsigned char *name)
{
- struct task_struct *parent_tsk = current->parent, new_tsk;
- struct slm_tsec_data *parent_tsec = NULL, new_tsec;
+ struct task_struct *parent_tsk = current->parent;
+ struct slm_tsec_data *parent_tsec;
int rc = 0;
- if (parent_tsk)
- parent_tsec = parent_tsk->security;
- else {
- printk(KERN_INFO
- "%s: current pid %d: parent_tsk is null\n",
- __FUNCTION__, current->pid);
- memset(&new_tsk, 0, sizeof(struct task_struct));
- parent_tsk = &new_tsk;
- }
-
- if (!parent_tsec) {
- memset(&new_tsec, 0, sizeof(struct slm_tsec_data));
- parent_tsec = &new_tsec;
- }
+ parent_tsec = parent_tsk->security;
if (mask & MAY_READ)
rc = do_task_may_read(level, name, parent_tsk, parent_tsec);
if ((mask & MAY_WRITE) || (mask & MAY_APPEND))
rc |= do_task_may_write(level, name, parent_tsk, parent_tsec);
return rc;
}
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists