Received: by 10.223.185.116 with SMTP id b49csp1049781wrg; Fri, 23 Feb 2018 11:00:44 -0800 (PST) X-Google-Smtp-Source: AH8x224AJ4ISwicxYm7ZWaVrgEB250mGa114oqilmdqOA8ch4ZMuoim779hxEXpkUSHu748iSM8g X-Received: by 2002:a17:902:46a:: with SMTP id 97-v6mr2559695ple.96.1519412444673; Fri, 23 Feb 2018 11:00:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519412444; cv=none; d=google.com; s=arc-20160816; b=h4MPup0owLxEZ+FqofZZiqIUcmO+/oYsHOOSqL7cZvEaySGFgJPW2q9EaQXB8b+uFi Y8eOeNnicGEa9xKFtbEVrXkk8UqK0m7SYcDbv16kZVznh/iZALHL9UxDXREGcuJ3AJhF fAQbpU7TqZjcmJhC+HwJDZE2cy5WRIesvdNZdcKRt7R9Iqbvwblwl3kyGyE0xeZ7INEH 6qpfngagzhRVFnU6QgGLk+QhYPHb5nQdQYA7N6CYfiAhlVhMXu6VJ9KbJLsF34MW/kFk 9idefTxZBmanBdmdTtnOAHXx0Lim/UNcB4ORXCMsccOTWtP67kVEn5tJNBlurMwbS3Kz QDIQ== 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=AiCkHz6FBk1qF17NESipmNQZCc4qG5MlOKUBfkT80iA=; b=lwNLXgsmLNvGY9g4sSn+ZebckoHsF4d+mB72NPEYMvV/ZvTK0lw5wKWWpK1ksXHBFS Cc0LkxuMIrUIezGbVj3kXnj/3gsyTisd6Qoi2ytXNbtbwmJ4xCJY25UCR0wK78QmhF63 Pmw9sdUH5OTi8s/FaRUKAbGshfpheagFF9hLqrMFR2x57U70aMYExFecPNBpNpdNpUfZ phh26mZu6QsoUbo/wFS0GEgzjRlCK0Y07QOi4qfsXcXH2VudFXAtO6/Bmg1vWja/U0HY pLvVuUAUMtke7xIuxpZjBnk7VHEOr4w/8z0NJPLZ9JDOMDyASF5j8AYitxKWAzsWsKv/ G4Yg== 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 g1si1417115pge.257.2018.02.23.11.00.29; Fri, 23 Feb 2018 11:00:44 -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 S935719AbeBWS7T (ORCPT + 99 others); Fri, 23 Feb 2018 13:59:19 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:50864 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935707AbeBWS7Q (ORCPT ); Fri, 23 Feb 2018 13:59:16 -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 ADBF41216; Fri, 23 Feb 2018 18:59:15 +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.15 32/45] binder: check for binder_thread allocation failure in binder_poll() Date: Fri, 23 Feb 2018 19:29:11 +0100 Message-Id: <20180223170720.426965518@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170715.197760019@linuxfoundation.org> References: <20180223170715.197760019@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.15-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;