Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1544300rwb; Wed, 28 Sep 2022 21:31:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7Jm4qrMZ4F9aqXOId/n8WRuBVqsEr4jRW1sNEOB/qZ0xzwPQ25dYMwrlwCQK3ZAZh31taR X-Received: by 2002:a17:907:7b97:b0:782:20fd:b956 with SMTP id ne23-20020a1709077b9700b0078220fdb956mr1071807ejc.204.1664425915661; Wed, 28 Sep 2022 21:31:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664425915; cv=none; d=google.com; s=arc-20160816; b=Ql/r652g8WaXHulNuD52+9Oeq16dLT9kY3uPsxmmy5B9y87PzzL6pPgzymDFWmGFF4 5mmfVDFGClA+sXD1p44jj7How2j26zsKge+OxCxGhWDVJeVRwmhHv4WxmHDXqYbR+p8X urNb9F5aY6SPzDrQfRnolflw+nEVFmvr+MQgx3Ho1Jpk9Gu58N7WM8f1/TwrtZnG83q1 FU2ol3rxCI3Iod1QS7IQoehufG8IgNAwd9iB7SnzQTQtphBtAewlF70nvEr98lSJsnPc u2CJIUZ91Bpx0IiJbDNiXxds57lKKweBfwMbyavG2I7bbb8UXrkRr0hsxSunyhXJnxGf BGXg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MQ6eVGHIuPCxsfzLZ7r6f4XtIMBx2hQBbA300A4TTy0=; b=TL5xH3bJyRO/66aQgeh73xVv0/qY4t9p7CBh0C4C3IWflS3Wc2oGaHw56bJOHNWoZD q5jtsU80IKLqZiUp3bFnuN6PP2qYT8VxuXrDY+ve/95oJdnYU+PyWAr+FpSl96Fh+ILs jXnqNN7whegCjBx8kVnXIHmiV+plEJ5NmGBuGvtT3xN/vEL3tJjj03gGpL/jBlDwvhCd J6X14tObX4+uCzL+s31Y3A3YO5NYaeRKE52ByOG5ORH3nJOpk+P/MowVrU0qnQv9nROW vXiyClagXOwxow6yGqrMPqa4v1ngULAu++4bFzDR/wdlFfDD2tVO3whgCM1s51dvjVhI fvpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NYTIFQxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l3-20020a170906794300b007414dda0c62si8741956ejo.817.2022.09.28.21.31.30; Wed, 28 Sep 2022 21:31:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=NYTIFQxT; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234729AbiI2E34 (ORCPT + 99 others); Thu, 29 Sep 2022 00:29:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234606AbiI2E3x (ORCPT ); Thu, 29 Sep 2022 00:29:53 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C047D43636 for ; Wed, 28 Sep 2022 21:29:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664425790; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=MQ6eVGHIuPCxsfzLZ7r6f4XtIMBx2hQBbA300A4TTy0=; b=NYTIFQxTl+b50fag2hWlA+xvS68UGO8lxn7E3ag95wvrR4O3RY1R9B9fLDoFWcVVkRShIj v9xHGCSRH5jECSekq0Pg/3z5MAadmXQFlogAKb7Shczj4gL6Av6DP/sWCT0dVYM5t1f7mL WB/EJfoqJ7MTjgtsrbBfsUo9lvik3+Y= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-663-x6xpR9HsPlutFSmX5-z1XQ-1; Thu, 29 Sep 2022 00:29:48 -0400 X-MC-Unique: x6xpR9HsPlutFSmX5-z1XQ-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3071981172A; Thu, 29 Sep 2022 04:29:48 +0000 (UTC) Received: from MiWiFi-R3L-srv.redhat.com (ovpn-13-179.pek2.redhat.com [10.72.13.179]) by smtp.corp.redhat.com (Postfix) with ESMTP id 206E87AE5; Thu, 29 Sep 2022 04:29:44 +0000 (UTC) From: Baoquan He To: linux-kernel@vger.kernel.org, akpm@linux-foundation.org Cc: kexec@lists.infradead.org, ebiederm@xmission.com, Jianglei Nie , Baoquan He Subject: [PATCH RESEND 1/4] proc/vmcore: fix potential memory leak in vmcore_init() Date: Thu, 29 Sep 2022 12:29:33 +0800 Message-Id: <20220929042936.22012-2-bhe@redhat.com> In-Reply-To: <20220929042936.22012-1-bhe@redhat.com> References: <20220929042936.22012-1-bhe@redhat.com> MIME-Version: 1.0 Content-type: text/plain Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.1 on 10.11.54.5 X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jianglei Nie elfcorehdr_alloc() allocates a memory chunk for elfcorehdr_addr with kzalloc(). If is_vmcore_usable() returns false, elfcorehdr_addr is a predefined value. If parse_crash_elf_headers() gets some error and returns a negetive value, the elfcorehdr_addr should be released with elfcorehdr_free(). Fix it by calling elfcorehdr_free() when parse_crash_elf_headers() fails. Signed-off-by: Jianglei Nie Acked-by: Baoquan He Signed-off-by: Baoquan He --- fs/proc/vmcore.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/proc/vmcore.c b/fs/proc/vmcore.c index f2aa86c421f2..74747571d58e 100644 --- a/fs/proc/vmcore.c +++ b/fs/proc/vmcore.c @@ -1567,6 +1567,7 @@ static int __init vmcore_init(void) return rc; rc = parse_crash_elf_headers(); if (rc) { + elfcorehdr_free(elfcorehdr_addr); pr_warn("Kdump: vmcore not initialized\n"); return rc; } -- 2.34.1