login
Login
/
Register
Search
Search this site:
Forums
News
Blogs
Features
Site
Home
»
Mailing list archives
»
linux-kernel
»
2008
»
December
»
23
Re: [PATCH] smackfs: check for allocation failures in smk_set_access()
view
thread
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
[view in full thread]
From: Casey Schaufler
Subject:
Re: [PATCH] smackfs: check for allocation failures in smk_set_access()
Date: Monday, December 22, 2008 - 10:03 pm
Sergio Luis wrote:
quoted text
> smackfs: check for allocation failures in smk_set_access() > > While adding a new subject/object pair to smack_list, smk_set_access() > didn't check the return of kzalloc(). > > This patch changes smk_set_access() to return 0 or -ENOMEM, based on > kzalloc()'s return. It also updates its caller, smk_write_load(), to > check for smk_set_access()'s return, given it is no longer a void > return function. > > Signed-off-by: Sergio Luis <sergio@larces.uece.br> > To: Casey Schaufler <casey@schaufler-ca.com> > Cc: Ahmed S. Darwish <darwish.07@gmail.com> > Cc: LSM <linux-security-module@vger.kernel.org> > Cc: LKLM <linux-kernel@vger.kernel.org> >
Acked-by: Casey Schaufler <casey@schaufler-ca.com>
quoted text
> security/smack/smackfs.c | 20 ++++++++++++++++---- > 1 files changed, 16 insertions(+), 4 deletions(-) > > diff --git a/security/smack/smackfs.c b/security/smack/smackfs.c > index c21d8c8..44eb933 100644 > --- a/security/smack/smackfs.c > +++ b/security/smack/smackfs.c > @@ -185,11 +185,15 @@ static int smk_open_load(struct inode *inode, struct file *file) > * the subject/object pair and replaces the access that was > * there. If the pair isn't found add it with the specified > * access. > + * > + * Returns 0 if nothing goes wrong or -ENOMEM if it fails > + * during the allocation of the new pair to add. > */ > -static void smk_set_access(struct smack_rule *srp) > +static int smk_set_access(struct smack_rule *srp) > { > struct smk_list_entry *sp; > struct smk_list_entry *newp; > + int ret = 0; > > mutex_lock(&smack_list_lock); > > @@ -202,14 +206,20 @@ static void smk_set_access(struct smack_rule *srp) > > if (sp == NULL) { > newp = kzalloc(sizeof(struct smk_list_entry), GFP_KERNEL); > + if (newp == NULL) { > + ret = -ENOMEM; > + goto out; > + } > + > newp->smk_rule = *srp; > newp->smk_next = smack_list; > smack_list = newp; > } > > +out: > mutex_unlock(&smack_list_lock); > > - return; > + return ret; > } > > /** > @@ -309,8 +319,10 @@ static ssize_t smk_write_load(struct file *file, const char __user *buf, > goto out; > } > > - smk_set_access(&rule); > - rc = count; > + rc = smk_set_access(&rule); > + > + if (!rc) > + rc = count; > > out: > kfree(data); > > >
--
unsubscribe notice
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to
majordomo@vger.kernel.org
More majordomo info at
http://vger.kernel.org/majordomo-info.html
Please read the FAQ at
http://www.tux.org/lkml/
Previous message: [
thread
] [
date
] [
author
]
Next message: [
thread
] [
date
] [
author
]
Messages in current thread:
[PATCH] smackfs: check for allocation failures in smk_set_ ...
, Sergio Luis
, (Sun Dec 21, 9:16 pm)
Re: [PATCH] smackfs: check for allocation failures in smk_ ...
, Casey Schaufler
, (Mon Dec 22, 10:03 pm)
Re: [PATCH] smackfs: check for allocation failures in smk_ ...
, James Morris
, (Wed Dec 24, 6:17 pm)
Navigation
Mailing list archives
Recent posts
Popular discussions
linux-kernel
:
Tony Luck
Re: Hardware Error Kernel Mini-Summit
James Bottomley
Re: [PATCH -mm 1/2] scsi: remove dma_is_consistent usage in 53c700
Andrey Borzenkov
Re: [possible regression] 2.6.22 reiserfs/libata sporadically hangs on resume from...
Linus Torvalds
Linux 2.6.26-rc6
Jeffrey V. Merkey
Re: Versioning file system
git
:
Morten Welinder
Re: [PATCH] use xrealloc in help.c
Junio C Hamano
Re: [PATCH 2/3] git-add--interactive: remove hunk coalescing
Jörg Sommer
[PATCH v2 08/13] Unify the lenght of $SHORT* and the commits in the TODO list
Boyd Lynn Gerber
Re: [VOTE] git versus mercurial
Stefan Näwe
Re: [PATCH] git-gui: use --exclude-standard to check for untracked files
linux-netdev
:
Andreas Sundstrom
Re: ~60k interrupts/sec for 1Gb/s iperf with r8169
David Miller
Re: [2.6.30-rc3] powerpc: compilation error of mace module
Denys Fedoryshchenko
Re: circular locking, mirred, 2.6.24.2
David Miller
Re: [PATCH -next] sfc: Use correct macro to set event bitfield
David Miller
Re: [PATCH] ipv6: fix display of local and remote sit endpoints
git-commits-head
:
Linux Kernel Mailing List
V4L/DVB: tm6000: add special usb request to quit i2c tuner transfer
Linux Kernel Mailing List
OMAP: DSS2: SDI driver
Linux Kernel Mailing List
PCI: introduce pci_pcie_cap()
Linux Kernel Mailing List
m68k: amiga - Mouse platform device conversion
Linux Kernel Mailing List
drivers/acpi: use kasprintf
openbsd-misc
:
frantisek holop
Re: mount ffs as msdos, system hangs
Ted Bullock
Re: Proliant DL380 G3 cannot get on network
Úlfar M. E. Johnson
installing openbsd in xen
Eric Furman
Re: Defending OpenBSD Performance
Damien Miller
Re: Patching a SSH 'Weakness'
Colocation donated by:
Syndicate