Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3055687imu; Mon, 19 Nov 2018 09:58:39 -0800 (PST) X-Google-Smtp-Source: AJdET5fIwbrQE+qji8oEpUd854UQe/ufGkZVEf6RcQZKtrFQLU69rubDQvqiSK4ejfxD54kJcF7z X-Received: by 2002:a62:1b50:: with SMTP id b77mr24013880pfb.36.1542650319843; Mon, 19 Nov 2018 09:58:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542650319; cv=none; d=google.com; s=arc-20160816; b=i5sRJ59xJyA8QjuL1fwm72u5jMeUn+ef8ku/VIVX4TSCg76qkGP6WO5nbUb94ncAtx 736yeEB6P+AZfcp1U+pdzySi6xtk1CO1UmEwAHSZ1yLwDbjJK4sgIqR8yCep7oFdM3TY C6Hq4npN9rIzaGYGst88imFL0WvdgWLD4EesOOSp7jnKPjX5liVEdJZ2HKXNUbNBuUvc H7P98cPeYc4Nue0uw/6fsIgcC+K5nH2u9GQ3C9RUXuFHbv1zC/H3dRg8ppT3MpCcGa5J TpU1bD8GTQ/yQy8q5tckN49hA8cizeVEnrqRETKyZ05Yzk+Ykze/XCLw1Gn7PdQ4qzbn Yf9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=01VcrlonJfaUgQe3HL8O2sVAacC9khyjMmm0ruO8wjw=; b=CXvhLfAWz2jISVVl7HlU0AYNgUgeI6IakmmWojzwBDFoaxgFlQ3fkxgTBy85VvFLQo 1pEBU66SSxdlb0G/LPu4NXau6LQdvsoLjaeyQ/NsCrU31IgcU3ZEjqSUQsfsu9vIypIp a1wkOkEVTJuapP+w0+nD7pMxSFnE5PrKOyibpbTLOn1UOhIaAu4lStTOp4xPLIEhGSG6 bXog6uRTwgaowDMAMpKQN/YUxSBkCgtNEngU7dnqSomPfynuw++Ls871CcLt5OfX0EZW JZ2P+GNY/+5ihRsPST9EZFvnN3/AanXXq1x2NNph+XCr7suWyZ6sSQjVMhOUo5sYjWd9 bjrg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a16si23224774plm.365.2018.11.19.09.58.24; Mon, 19 Nov 2018 09:58:39 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732301AbeKTEVq (ORCPT + 99 others); Mon, 19 Nov 2018 23:21:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:42212 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732234AbeKTEVq (ORCPT ); Mon, 19 Nov 2018 23:21:46 -0500 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 51A5980470; Mon, 19 Nov 2018 17:57:13 +0000 (UTC) Received: from treble (ovpn-126-32.rdu2.redhat.com [10.10.126.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CC054662C5; Mon, 19 Nov 2018 17:57:12 +0000 (UTC) Date: Mon, 19 Nov 2018 11:57:10 -0600 From: Josh Poimboeuf To: Artem Savkov Cc: Peter Zijlstra , linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 1/2] objtool: fix failed cold symbol doublefree Message-ID: <20181119175710.6tcqxtevhg422wsg@treble> References: <20181112033800.ujolxvkwzz72lxhm@treble> <20181112125519.26855-1-asavkov@redhat.com> <20181112125519.26855-2-asavkov@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20181112125519.26855-2-asavkov@redhat.com> User-Agent: NeoMutt/20180716 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 19 Nov 2018 17:57:13 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Nov 12, 2018 at 01:55:18PM +0100, Artem Savkov wrote: > 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(). > > Fixes: 13810435b9a7 "objtool: Support GCC 8's cold subfunctions" This needs parentheses, like: Fixes: 13810435b9a7 ("objtool: Support GCC 8's cold subfunctions") > Signed-off-by: Artem Savkov > --- > tools/objtool/elf.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c > index 6dbb9fae0f9d..3decd43477df 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; > + goto cold_err; Since it will get freed properly in elf_close() anyway, maybe it would be simpler to just 'return -1' here. > } > > sym->pfunc = pfunc; > @@ -336,6 +336,9 @@ static int read_symbols(struct elf *elf) > > return 0; > > +cold_err: > + list_del(&sym->list); > + hash_del(&sym->hash); > err: > free(sym); > return -1; > -- > 2.17.2 > -- Josh