提交 3ed02ada 编写于 作者: J John Johansen 提交者: James Morris

AppArmor: Ensure the size of the copy is < the buffer allocated to hold 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: NJohn Johansen <john.johansen@canonical.com>
Acked-by: NKees Cook <kees.cook@canonical.com>
Signed-off-by: NJames Morris <jmorris@namei.org>
上级 9f1c1d42
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
* aa_simple_write_to_buffer - common routine for getting policy from user * aa_simple_write_to_buffer - common routine for getting policy from user
* @op: operation doing the user buffer copy * @op: operation doing the user buffer copy
* @userbuf: user buffer to copy data from (NOT NULL) * @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 * @copy_size: size of data to copy from user buffer
* @pos: position write is at in the file (NOT NULL) * @pos: position write is at in the file (NOT NULL)
* *
...@@ -42,6 +42,8 @@ static char *aa_simple_write_to_buffer(int op, const char __user *userbuf, ...@@ -42,6 +42,8 @@ static char *aa_simple_write_to_buffer(int op, const char __user *userbuf,
{ {
char *data; char *data;
BUG_ON(copy_size > alloc_size);
if (*pos != 0) if (*pos != 0)
/* only writes from pos 0, that is complete writes */ /* only writes from pos 0, that is complete writes */
return ERR_PTR(-ESPIPE); return ERR_PTR(-ESPIPE);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册