Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp4810817yba; Tue, 30 Apr 2019 04:54:18 -0700 (PDT) X-Google-Smtp-Source: APXvYqyh1xuOUOkdMbFDku96o4ytPSm7lP8jefw/eF/j5DlOB4bLMgl3xRcuLg0s4mM7jbX5EjIy X-Received: by 2002:a63:541d:: with SMTP id i29mr37001390pgb.174.1556625257949; Tue, 30 Apr 2019 04:54:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556625257; cv=none; d=google.com; s=arc-20160816; b=1GqYh6Z/sjl/tDjYVBg6gSnqHgcX0gyja4wcB0LwFJqGdymR/5woYdWyv0ncx/vJmj BROZRd2qjFWrk2QURTUC+W3845nzL1+h2BfwBBO5Jkm6DGaBVVhCRnhE8cDDlmqBrdtW NdolhItO5h/ZRA/aVrFNOLZ8vCgGtN5CKPT6qQUWHqYBG7tfX6j/LZgkiOfn4EQ8P8xJ 0Qmrs6uR6DcV0x6Lp7eaxQbH6rwbt+8uBqD6vNZyVm59LDqZuxnLNNIaJUOZJsnH7joE rANct9oBwb1HI6DcibbCmsNM2JWuyjmBBSlmkAiIoya7OB27RX9tv+LOnwzz3XEG9HK4 yX1A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dCvHCKXpJw9Mc27bvAZb+opGuiQ6WFmsqoV9pLZ7sMQ=; b=Znip/gWn+0jsBql3NDsHhUMirg7jmAhS9qIfW4DgcwlT41JITAv2vk5cib8jxehA/p bUeFn5gCBK5jB1UzPsk/pXoFFPrJJeXTstzF+ySgZMbmES/u2LNEOX9uYcNWOQvwmket gDCUDFM8V65QKhRvVT/ZcRKm1XzEzlmpesPu5jIiKatUCFf3OkNdIyQC5Am14UMjUja3 PW10TU2XKJM/S+lVLo6kwAgm2+mLeIPC2J86i8yBxK0HvcZracWikvP9jb2pmMQ2zA2k EzgUyx11qCLCbxB4cpWH7qcq06Qjfs4JBrjdwmgmdfrEwHInMiFLv0YfInRLdZQAAPKL FPsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDjVcFvh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b96si35223817plb.426.2019.04.30.04.54.02; Tue, 30 Apr 2019 04:54:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rDjVcFvh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730542AbfD3Lvi (ORCPT + 99 others); Tue, 30 Apr 2019 07:51:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:39460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730995AbfD3Lvg (ORCPT ); Tue, 30 Apr 2019 07:51:36 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 02F222054F; Tue, 30 Apr 2019 11:51:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1556625095; bh=QMKhlt3BS7uu0HAFlCN4qcRiUtHGvuEBPQthGHlGW0M=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rDjVcFvhxFPTwLc/tr6/aLKmxCDwV2xAes1ooWP0qShVWVIZHSG48wai8Q/rftFjG V13G6rmijzspsPGTMHJ8pxCvy9sXEugsA/QL4qULCjmnnRl5CXwJLRxGwqWYRvGSOC Z2U3zBBqHN9lFJDFoUYbTk9ZTcmXO9JWxO5kmsMo= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Todd Kjos , "Joel Fernandes (Google)" , syzbot+55de1eb4975dec156d8f@syzkaller.appspotmail.com Subject: [PATCH 5.0 53/89] binder: fix handling of misaligned binder object Date: Tue, 30 Apr 2019 13:38:44 +0200 Message-Id: <20190430113612.171167211@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190430113609.741196396@linuxfoundation.org> References: <20190430113609.741196396@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Todd Kjos commit 26528be6720bb40bc8844e97ee73a37e530e9c5e upstream. Fixes crash found by syzbot: kernel BUG at drivers/android/binder_alloc.c:LINE! (2) Reported-and-tested-by: syzbot+55de1eb4975dec156d8f@syzkaller.appspotmail.com Signed-off-by: Todd Kjos Reviewed-by: Joel Fernandes (Google) Cc: stable # 5.0, 4.19, 4.14 Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder_alloc.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c @@ -959,14 +959,13 @@ enum lru_status binder_alloc_free_page(s index = page - alloc->pages; page_addr = (uintptr_t)alloc->buffer + index * PAGE_SIZE; + + mm = alloc->vma_vm_mm; + if (!mmget_not_zero(mm)) + goto err_mmget; + if (!down_write_trylock(&mm->mmap_sem)) + goto err_down_write_mmap_sem_failed; vma = binder_alloc_get_vma(alloc); - if (vma) { - if (!mmget_not_zero(alloc->vma_vm_mm)) - goto err_mmget; - mm = alloc->vma_vm_mm; - if (!down_write_trylock(&mm->mmap_sem)) - goto err_down_write_mmap_sem_failed; - } list_lru_isolate(lru, item); spin_unlock(lock); @@ -979,10 +978,9 @@ enum lru_status binder_alloc_free_page(s PAGE_SIZE); trace_binder_unmap_user_end(alloc, index); - - up_write(&mm->mmap_sem); - mmput(mm); } + up_write(&mm->mmap_sem); + mmput(mm); trace_binder_unmap_kernel_start(alloc, index);