From: Adrian Bunk <bunk@stusta.de>
To: Andrew Morton <akpm@osdl.org>, Kylene Jo Hall <kjhall@us.ibm.com>
Cc: linux-kernel@vger.kernel.org, Mimi Zohar <zohar@us.ibm.com>,
chrisw@sous-sol.org, linux-security-module@vger.kernel.org
Subject: [-mm patch] slm_set_taskperm(): remove horrible error handling code
Date: Wed, 13 Dec 2006 14:06:46 +0100 [thread overview]
Message-ID: <20061213130646.GE3851@stusta.de> (raw)
In-Reply-To: <20061211005807.f220b81c.akpm@osdl.org>
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@stusta.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;
}
prev parent reply other threads:[~2006-12-13 13:06 UTC|newest]
Thread overview: 41+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-12-11 8:58 2.6.19-mm1 Andrew Morton
2006-12-11 9:18 ` 2.6.19-mm1 Nick Piggin
2006-12-11 10:41 ` 2.6.19-mm1 Jiri Kosina
2006-12-11 14:28 ` 2.6.19-mm1 Nick Piggin
2006-12-11 14:33 ` 2.6.19-mm1 Jiri Kosina
2006-12-11 15:07 ` 2.6.19-mm1 Nick Piggin
2006-12-11 16:00 ` 2.6.19-mm1 Jiri Kosina
2006-12-11 11:10 ` [Ocfs2-devel] [RFC: -mm patch] OCFS2: make code static Adrian Bunk
2006-12-11 19:10 ` Adrian Bunk
2006-12-11 14:26 ` [Ocfs2-devel] " Mark Fasheh
2006-12-11 22:26 ` Mark Fasheh
2006-12-13 15:17 ` [Ocfs2-devel] [-mm patch] fs/ocfs2/dlm/: make functions static Adrian Bunk
2006-12-13 23:17 ` Adrian Bunk
2006-12-11 14:57 ` 2.6.19-mm1: i386: unused idle notifiers added Adrian Bunk
2006-12-11 16:42 ` 2.6.19-mm1: missing MTD_UBI* help texts Adrian Bunk
2006-12-13 12:37 ` Artem Bityutskiy
2006-12-13 12:37 ` Artem Bityutskiy
2006-12-11 18:40 ` [-mm patch] make sysrq_always_enabled_setup() static Adrian Bunk
2006-12-11 19:11 ` Ingo Molnar
2006-12-11 18:40 ` [-mm patch] ACPI: make code static Adrian Bunk
2006-12-11 19:06 ` [-mm patch] drivers/uio/: make 3 functions static Adrian Bunk
2006-12-11 20:46 ` 2.6.19-mm1: drivers/mtd/ubi/debug.c: unused variable Adrian Bunk
2006-12-12 11:53 ` Josh Boyer
2006-12-13 12:36 ` Artem Bityutskiy
2006-12-13 12:36 ` Artem Bityutskiy
2006-12-11 22:41 ` 2.6.19-mm1 Rafael J. Wysocki
2006-12-11 22:52 ` 2.6.19-mm1 (md/raid1 randomly drops partitions) Neil Brown
2006-12-11 23:43 ` Rafael J. Wysocki
2006-12-11 23:54 ` Neil Brown
2006-12-12 20:55 ` Rafael J. Wysocki
2006-12-13 0:53 ` 2.6.19-mm1 (md/raid1 randomly drops partitions - possible sata_uli problem) Neil Brown
2006-12-13 11:51 ` Rafael J. Wysocki
2006-12-12 5:53 ` 2.6.19-mm1 KAMEZAWA Hiroyuki
2006-12-12 6:06 ` 2.6.19-mm1 Andrew Morton
2006-12-12 6:43 ` 2.6.19-mm1 KAMEZAWA Hiroyuki
2006-12-12 8:04 ` 2.6.19-mm1 Andrew Morton
2006-12-13 1:17 ` 2.6.19-mm1 Conke Hu
2006-12-13 1:50 ` 2.6.19-mm1 Andrew Morton
2006-12-13 13:05 ` 2.6.19-mm1: gotemp: memset(..., 0) error Adrian Bunk
2006-12-14 23:50 ` Greg KH
2006-12-13 13:06 ` Adrian Bunk [this message]
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=20061213130646.GE3851@stusta.de \
--to=bunk@stusta.de \
--cc=akpm@osdl.org \
--cc=chrisw@sous-sol.org \
--cc=kjhall@us.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=zohar@us.ibm.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.