Received: by 10.223.185.116 with SMTP id b49csp1141921wrg; Fri, 23 Feb 2018 12:41:08 -0800 (PST) X-Google-Smtp-Source: AH8x227+x7A+lpVSDHVZZRn+lz26LvGbPuRAO3KMTNWmAjZDZsbEYfGFD8YKVdeqiVeOLsg8ELxd X-Received: by 10.98.71.3 with SMTP id u3mr2955037pfa.219.1519418468202; Fri, 23 Feb 2018 12:41:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519418468; cv=none; d=google.com; s=arc-20160816; b=DASzbLPAbl0xrM6Ubfv4EllDraAJCsG4Vo41GDRbK+PWK6fts1HAMtNClPwnE5A1yr Ys7d7r0hd3pU+EiHNITLYeUHl+N0JLD1ja2qsqCwY64BcTzuBx3cjLXbpr4zITemYzUi SvYl7xaHEaApEwaGPCI07GShIp4OVeOjQlfsS9igKCnAiwD6xo1b31fxjJlQfCkQC2+4 vOimKdzUkaNAz1xSTMbno13xBLyT0Lw7gotv1B/ioH6tEe2Tq/YSr+266R41G9+JB1ke a6hML+GBqTwrZEPDVlCQbJarzukqPyUvUsM8NYKOx2A2Oi+dz4qpahZkF9x9IMz1lDa2 oFLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=rfGYLUpsO9GpTb+AtncDoZVdvASqQ9I8aAwbB3TIjiQ=; b=gS+l4SbHeQsI95fAChLeefAu8eF/es8+fDJgBCaaNgxToyi/okhzcZHs98xe516dIV 0tXh77MDA7SWu0EGNXqX6ZyPpN5nYpTvi/lxeR+BIaaeDbIcmrXwv2Ya7cD7p6Tz90sH jCs8UtU9tryq3CYgnVMnnSFhrBDxJBEHtFzE0xk0qh6IjSMBhrvueywKUvQ1Lbk9jrVT 0m2tJOSDXGPq8rcSbtCGn+6oPAzmWrofgJyAYm+BqEwkLlYpranibdUG8XM0TQ1MRygt xFOy8flAXf+oC44IoT03vLSdockF2URq/A8VN4AxCo7wvYYTein5sOco01LwiUoE0GnJ 89eA== ARC-Authentication-Results: i=1; mx.google.com; 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 q3si1932108pgp.701.2018.02.23.12.40.53; Fri, 23 Feb 2018 12:41:08 -0800 (PST) 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; 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 S1752261AbeBWSdv (ORCPT + 99 others); Fri, 23 Feb 2018 13:33:51 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:36672 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753321AbeBWSds (ORCPT ); Fri, 23 Feb 2018 13:33:48 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id B6ECC122E; Fri, 23 Feb 2018 18:33:47 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot , Eric Biggers Subject: [PATCH 4.4 027/193] binder: check for binder_thread allocation failure in binder_poll() Date: Fri, 23 Feb 2018 19:24:20 +0100 Message-Id: <20180223170330.322805082@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Eric Biggers commit f88982679f54f75daa5b8eff3da72508f1e7422f upstream. If the kzalloc() in binder_get_thread() fails, binder_poll() dereferences the resulting NULL pointer. Fix it by returning POLLERR if the memory allocation failed. This bug was found by syzkaller using fault injection. Reported-by: syzbot Fixes: 457b9a6f09f0 ("Staging: android: add binder driver") Cc: stable@vger.kernel.org Signed-off-by: Eric Biggers Signed-off-by: Greg Kroah-Hartman --- drivers/android/binder.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/android/binder.c +++ b/drivers/android/binder.c @@ -2622,6 +2622,8 @@ static unsigned int binder_poll(struct f binder_lock(__func__); thread = binder_get_thread(proc); + if (!thread) + return POLLERR; wait_for_proc_work = thread->transaction_stack == NULL && list_empty(&thread->todo) && thread->return_error == BR_OK;