Skip to content

Commit

Permalink
AppArmor: Ensure the size of the copy is < the buffer allocated to ho…
Browse files Browse the repository at this point in the history
…ld it

Actually I think in this case the appropriate thing to do is to BUG as there
is currently a case (remove) where the alloc_size needs to be larger than
the copy_size, and if copy_size is ever greater than alloc_size there is
a mistake in the caller code.

Signed-off-by: John Johansen <john.johansen@canonical.com>
Acked-by: Kees Cook <kees.cook@canonical.com>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
John Johansen authored and James Morris committed Oct 20, 2010
1 parent 9f1c1d4 commit 3ed02ad
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion security/apparmor/apparmorfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
* aa_simple_write_to_buffer - common routine for getting policy from user
* @op: operation doing the user buffer copy
* @userbuf: user buffer to copy data from (NOT NULL)
* @alloc_size: size of user buffer
* @alloc_size: size of user buffer (REQUIRES: @alloc_size >= @copy_size)
* @copy_size: size of data to copy from user buffer
* @pos: position write is at in the file (NOT NULL)
*
Expand All @@ -42,6 +42,8 @@ static char *aa_simple_write_to_buffer(int op, const char __user *userbuf,
{
char *data;

BUG_ON(copy_size > alloc_size);

if (*pos != 0)
/* only writes from pos 0, that is complete writes */
return ERR_PTR(-ESPIPE);
Expand Down

0 comments on commit 3ed02ad

Please sign in to comment.