Received: by 10.223.185.116 with SMTP id b49csp1078614wrg; Fri, 23 Feb 2018 11:31:52 -0800 (PST) X-Google-Smtp-Source: AH8x226HEH9IlsSf0aUT7RCjx9DZd01ZvJ4guxIwnoZg3RD/dQhC5g/D1n207faOi0OdWt8MsN9d X-Received: by 10.99.96.137 with SMTP id u131mr2274175pgb.103.1519414312013; Fri, 23 Feb 2018 11:31:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519414311; cv=none; d=google.com; s=arc-20160816; b=0kqRXtSAZrP09HfKCodvBX0+bxPcNC0+qiYlO71rWut/1fhjIwwQXuZwj8H8Hdmj2L kmVbJdEaZvv41XS05B17g4XxwhmbFNStM2kjUpvF4xbCmteVwTP6LlzZ3B7j/fs2y1jP 0Sf0jYdAS2cQ7FsKEvgR38VIDUYbVgyR0wWC16KtRYGo9H3VeU4d6ZvfZlsJkmunBTxI w6+Vd3y6posNDsygTBRf5oDfwrVHRIj6ZLeWk25wdF9e3dSvrl/rnRppiWRATx7u1yUv bP87hhDWjzFwg5iLcPiKZxvFVRWDtKoFQgYUXHIp9Hl/HvKEdb1k8J5bEPtyakgUpdHk ZDdw== 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=ecpH2lUGKGhaFXOiC7pugXoq8fMMTrFV+EWJetWxq9g=; b=lDwLucEUbLdP9O/DjHykzRoLME4Ywp5SFkUZhLT1+OJtlztjPufyJb0aqjjvjBaHYa q0EdmnMS9+D4eRukVx5FFLzaIAFRerSbbDYbfV0+XZ/hvzui2fyNtymp3kVtr23K4iJ7 eyFoM6jgtIolOLGfHFBgNAegz9YBIael7qOIbzRp132PhkwNhizO0sbddVHnEUYcZROJ KxAgn9REgoxIs+6NK3kNTRUUJUG6PpIjHX+yEyytOV1sK5iaP/LDbVU0o726cSxfAu9w aMhy6Rrf3Vyqm7ntdqCabJVl5xg9c+QwZDuCZ/RHhDXtenixkTQ6jqbsZAwW0CE3tmt1 Q6RA== 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 d2si1863632pgc.758.2018.02.23.11.31.37; Fri, 23 Feb 2018 11:31:51 -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 S934992AbeBWSvi (ORCPT + 99 others); Fri, 23 Feb 2018 13:51:38 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:46050 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934552AbeBWSvf (ORCPT ); Fri, 23 Feb 2018 13:51:35 -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 DAEA11318; Fri, 23 Feb 2018 18:51:34 +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.14 053/159] binder: check for binder_thread allocation failure in binder_poll() Date: Fri, 23 Feb 2018 19:26:01 +0100 Message-Id: <20180223170749.994498164@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170743.086611315@linuxfoundation.org> References: <20180223170743.086611315@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.14-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 @@ -4346,6 +4346,8 @@ static unsigned int binder_poll(struct f bool wait_for_proc_work; thread = binder_get_thread(proc); + if (!thread) + return POLLERR; binder_inner_proc_lock(thread->proc); thread->looper |= BINDER_LOOPER_STATE_POLL;