Received: by 10.223.185.116 with SMTP id b49csp1105375wrg; Fri, 23 Feb 2018 12:02:16 -0800 (PST) X-Google-Smtp-Source: AH8x227Xum6/5LCcuomdPYX+2KzNCLaU2286lbzeVDNP8w5j4wBhO/YcxNyZE9Ng/kMgsKNAhKKV X-Received: by 2002:a17:902:aa0b:: with SMTP id be11-v6mr2713248plb.250.1519416136370; Fri, 23 Feb 2018 12:02:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519416136; cv=none; d=google.com; s=arc-20160816; b=prjW7/8LdMuIlZbhnL+YJYR4n9fqZhWOrAO3gq4ITP8FD7xAiIdqlXVnN9uA3iAvmT JRwL1+xoQAq4tNtaQG8AvecC8zQwhx47mLXLjSJNvEyIbcF4EAFhp3MxMahSLzAvrSBk 9pvkC2d2npznLOiNbmsw14a72Rh1/Sjcl5PQLp27JxzUQRNJCylFG0cOBK+BJyvcM6dW eCNbdgJnxCzj3RIgXD1PYv1J7xya7UNooc9/+kRfIlBBPfG8ihjOoaNf30GncoAFMzZD eDrb1xeU0lgrppM1PMKwclBgttVYRi1GHJGeHwl2e2jZrjWQDVMgkvYocwbR4BZOfs9F V3Zw== 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=2jMw+xSAHBrlmkhxpnBZfNpFeQ1VEYy2/M24ezRfNkI=; b=bmstaYQx/8gEH9xQ7F0yMM14ZOlH1CAUjB+1sCFHivohU4MtS0pjuQBjcCfvbPlrOj KzRUDw/A+lKVp8GWHh98aNc9fiJtZcsCcyIZte2E0imNKMI6fum9kw/soR6U+wEr2/5f E8110ZNlIloB7hJl5Rw287wvJ/EepR/4gfJBQUz3XOsvibqACXaRjCSysMLWsM4n8Vca ToFT18npL3RYD/KDCOzJkO/pJw+1FLdvz37qSg5I/5JV5eajifcqybP3IEa0irBpZq3y O6132Q9SupSdnpnv1I5izLiBhB7IKQBg1vm7ZZusNBxFoqyhZLnLo/z9CrRQVaZwzekq Vowg== 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 q26si1706216pfh.129.2018.02.23.12.02.00; Fri, 23 Feb 2018 12:02:16 -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 S933414AbeBWSnw (ORCPT + 99 others); Fri, 23 Feb 2018 13:43:52 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:42356 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932953AbeBWSnt (ORCPT ); Fri, 23 Feb 2018 13:43:49 -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 C67FF120B; Fri, 23 Feb 2018 18:43:48 +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.9 038/145] binder: check for binder_thread allocation failure in binder_poll() Date: Fri, 23 Feb 2018 19:25:44 +0100 Message-Id: <20180223170729.872536682@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170724.669759283@linuxfoundation.org> References: <20180223170724.669759283@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.9-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 @@ -2628,6 +2628,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;