Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1985233imu; Fri, 14 Dec 2018 04:05:55 -0800 (PST) X-Google-Smtp-Source: AFSGD/WQo9q1o4JoYONnd6p9zICzLKG+FKz8U690FXAZXNtr0yCcAbVLi4L9BxKTsDOMiftEDUCl X-Received: by 2002:a63:5153:: with SMTP id r19mr2438196pgl.281.1544789155642; Fri, 14 Dec 2018 04:05:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544789155; cv=none; d=google.com; s=arc-20160816; b=sIGJSE/XkBAdt8zkV7YjTlMWbgXiMVpSgMBYpfXIxhg1Nsql9I/FBzH3FGWdRRRL4/ UdLdKgmoMV/YsqItsqn6YGaf4M+VfxVZ2hywpyQ5ru79F3wAqHB0z+KHhDmJiuVd3Pgv gE0AgBpYVYSCb4HDch8aGxHbKFvvL6yOarJ9w/2gx2QzmaFCPJ34AHkJxptV8x0lvHv0 NQR8FMdfKO1jJ1C+PRQFpfL4UxbsgaFePlS18l5DRsdEcTiXvdiZ+bmt6BshYJwjcV0n t+63MKyWkYv3XZziPPByK8Wa6m+fDPAT6zJAx/9cySDSAqCFrIdg7mL08Bw3y6FjIe2M 0wrw== 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=5AYq99bsizbfKwfYUcBzPFGGhme1IARn3jw+toURE0E=; b=mZCDBDWaNWwIs3c4+8mL1tHADgkyZdK5YCM4pELg0z9LZPWoHPobQnMAl8me9ZbnUL 7P2dyYuzOkIEV2oqhKRkjTFRGuwNBXI/BrQXaSNeLv2nrNN7YohGRoC6/PAaBveg+LQT mIX9KdB59EGCe/u82Mens7q+bWjLFXM0TRH9jv6tsaWlqSC7GR7IOnSq0u/ZqTEgN8nH gAMnKlDDjTRZ5gYTzVJzGCG/1KIz7+TlMXJY2uyJ4pQbjJkGf70rvzeZpqfTbXLhTeAn myuIidxwW1XXxnAUQZFR0VhSeQGol013BuUJr32SRAn05nesQ+HnVcw9tfF9G27XWkzK oHEw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=NOvd6Ze1; 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 q70si3978629pgq.526.2018.12.14.04.05.41; Fri, 14 Dec 2018 04:05:55 -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; dkim=pass header.i=@kernel.org header.s=default header.b=NOvd6Ze1; 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 S1729872AbeLNMDv (ORCPT + 99 others); Fri, 14 Dec 2018 07:03:51 -0500 Received: from mail.kernel.org ([198.145.29.99]:47960 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730372AbeLNMDr (ORCPT ); Fri, 14 Dec 2018 07:03:47 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.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 B204F2146E; Fri, 14 Dec 2018 12:03:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544789027; bh=e1a/2wCPgUDjTDQjzayiTJM0wvQm9O4+poxvGL18Ngs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NOvd6Ze1igaIUikFOUHWZHJ1imQ22mu6TYnzNvgU1q+H8mT7EEJiy7Ex9VLCpaGtx I1Rq9LOb78YjcvnQND0tyBNYEahiv+gXVggFkNIhOOzD39fW3dqTYvliDvIkHJMrrX B1BMziMdgbv02KtsjZw4a7zNfXo30e4qh/xd6hOk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Artem Savkov , Josh Poimboeuf , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar , Sasha Levin Subject: [PATCH 4.19 065/142] objtool: Fix double-free in .cold detection error path Date: Fri, 14 Dec 2018 12:59:10 +0100 Message-Id: <20181214115749.656201027@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181214115747.053633987@linuxfoundation.org> References: <20181214115747.053633987@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore 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 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 0b9301fb632f7111a3293a30cc5b20f1b82ed08d ] If read_symbols() fails during second list traversal (the one dealing with ".cold" subfunctions) it frees the symbol, but never deletes it from the list/hash_table resulting in symbol being freed again in elf_close(). Fix it by just returning an error, leaving cleanup to elf_close(). Signed-off-by: Artem Savkov Signed-off-by: Josh Poimboeuf Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions") Link: http://lkml.kernel.org/r/beac5a9b7da9e8be90223459dcbe07766ae437dd.1542736240.git.jpoimboe@redhat.com Signed-off-by: Ingo Molnar Signed-off-by: Sasha Levin --- tools/objtool/elf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c index 7ec85d567598..a6f543e0b387 100644 --- a/tools/objtool/elf.c +++ b/tools/objtool/elf.c @@ -312,7 +312,7 @@ static int read_symbols(struct elf *elf) if (!pfunc) { WARN("%s(): can't find parent function", sym->name); - goto err; + return -1; } sym->pfunc = pfunc; -- 2.19.1