]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commit
binder: Handle start==NULL in binder_update_page_range()
authorJann Horn <jannh@google.com>
Fri, 18 Oct 2019 20:56:31 +0000 (22:56 +0200)
committerMarcelo Henrique Cerri <marcelo.cerri@canonical.com>
Fri, 17 Jan 2020 17:22:30 +0000 (14:22 -0300)
commit8d75e251833eb36d6d13ee8d85eb11daceca9883
tree8263e4f37d86f7f5912f7be75931baa3b692721b
parentcc5a68acea9e72e43ccc3f9c2145785e7f260e51
binder: Handle start==NULL in binder_update_page_range()

BugLink: https://bugs.launchpad.net/bugs/1857158
commit 2a9edd056ed4fbf9d2e797c3fc06335af35bccc4 upstream.

The old loop wouldn't stop when reaching `start` if `start==NULL`, instead
continuing backwards to index -1 and crashing.

Luckily you need to be highly privileged to map things at NULL, so it's not
a big problem.

Fix it by adjusting the loop so that the loop variable is always in bounds.

This patch is deliberately minimal to simplify backporting, but IMO this
function could use a refactor. The jump labels in the second loop body are
horrible (the error gotos should be jumping to free_range instead), and
both loops would look nicer if they just iterated upwards through indices.
And the up_read()+mmput() shouldn't be duplicated like that.

Cc: stable@vger.kernel.org
Fixes: 457b9a6f09f0 ("Staging: android: add binder driver")
Signed-off-by: Jann Horn <jannh@google.com>
Acked-by: Christian Brauner <christian.brauner@ubuntu.com>
Link: https://lore.kernel.org/r/20191018205631.248274-3-jannh@google.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Kleber Sacilotto de Souza <kleber.souza@canonical.com>
drivers/android/binder_alloc.c