Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp83814pxf; Wed, 10 Mar 2021 21:37:55 -0800 (PST) X-Google-Smtp-Source: ABdhPJzIKw0hksvS8MUYeeTklO2Ii7alnV9LELPZHF79tPzWnZtfa4hFzeSTnrRqrWqwkE/9vJAl X-Received: by 2002:a17:906:4117:: with SMTP id j23mr1429085ejk.10.1615441075028; Wed, 10 Mar 2021 21:37:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615441075; cv=none; d=google.com; s=arc-20160816; b=AXOOwS/PQcLbO99w2Q3AVBydCr+Z0ciuhOY6ASN3TWRFnAVl9Tr/y/lnjSc6ks5bQb ki9nMQTc9WnvqHzhU4Hg8qPt7AMJqOJC/M6tmK7GrY1BV3+BxQ7Bx5m8b7HM5WB3lli0 u73mnIv9k7U48C264I/397Dwk8FnNklM9zYssEkiUrc2BK1Oapx/zkCf2pGm1RhYKvQj QbdpoKJioSYQw0zIlrUOIREZFyO6ptvqIHmr4oE6ua/gTGfSDzK8w0tHRFckwVApS8T5 9MKwuSC49sZBYf9l1XjaJKm+THjvtpjdVhp5vYyFwwBo8psy2QmYBp18OgI3mQw4UH9X JvKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=0MOfd/bEGZqrvXqQeTRkt3JSczTsL8Nc19791LwQRsk=; b=Lv+3H5y21Xh0PMjFkN1ByjbqaAQ/UbvB9Ht6Nr8WlBQJ47ZQwtboQdnYiU1ZGSk2Iz t9J3xkqqlGvlDFLT6bpv4qmmaDBZp1xb7txnwfE0f2h7aePoWwq8g/4/KrmVom2tOD/3 md/OKHmnrOSvr397S7DlhpkehbZS+3HQuqO4LhfANn4t7yDxphz12ZPUvHVXBNDIJU4/ lwonWBalJTG+7uPLnkuF5D+vCvtMS2z9460wiB1YAW4zuhUtDcGaIkVfMSdxycbd9NLT zRnHqL5fmWhf9T+Zi+J5vKNCer3vqdfGOUQB4kfx81kD3cgnNmBagWIUYmuq+X7Im9Yd OJrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuTFbWZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si1014314edx.585.2021.03.10.21.37.27; Wed, 10 Mar 2021 21:37:55 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IuTFbWZH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S229735AbhCKFcx (ORCPT + 99 others); Thu, 11 Mar 2021 00:32:53 -0500 Received: from us-smtp-delivery-124.mimecast.com ([216.205.24.124]:29739 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbhCKFcX (ORCPT ); Thu, 11 Mar 2021 00:32:23 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1615440742; 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: in-reply-to:in-reply-to:references:references; bh=0MOfd/bEGZqrvXqQeTRkt3JSczTsL8Nc19791LwQRsk=; b=IuTFbWZHQ1p+72fM9PBZSXABLwPfijSjhe6fVP+Z+1kYuAGEuXg60xUZAY1wxgoZd2oElw FlKGJ8KR1v2YjUEPrPQ2rv8NA3bHJ3M8qZ7+qeVYMewkU6kskGU+AAB8973aAfO3OPl+CH ybMnXfauvNvbNZJkORfFrStbVqUcnVY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-235-hRZQVlZKNmipWqIHdqs62A-1; Thu, 11 Mar 2021 00:32:18 -0500 X-MC-Unique: hRZQVlZKNmipWqIHdqs62A-1 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id D444957; Thu, 11 Mar 2021 05:32:16 +0000 (UTC) Received: from localhost (ovpn-12-68.pek2.redhat.com [10.72.12.68]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3307F60C13; Thu, 11 Mar 2021 05:32:15 +0000 (UTC) Date: Thu, 11 Mar 2021 13:32:13 +0800 From: Baoquan He To: Jia-Ju Bai Cc: ebiederm@xmission.com, kexec@lists.infradead.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org Subject: Re: [PATCH] kernel: kexec_file: fix error return code of kexec_calculate_store_digests() Message-ID: <20210311053213.GH2962@MiWiFi-R3L-srv> References: <20210309083904.24321-1-baijiaju1990@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210309083904.24321-1-baijiaju1990@gmail.com> User-Agent: Mutt/1.10.1 (2018-07-13) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/09/21 at 12:39am, Jia-Ju Bai wrote: > When vzalloc() returns NULL to sha_regions, no error return code of > kexec_calculate_store_digests() is assigned. > To fix this bug, ret is assigned with -ENOMEM in this case. > > Fixes: a43cac0d9dc2 ("kexec: split kexec_file syscall code to kexec_file.c") > Reported-by: TOTE Robot > Signed-off-by: Jia-Ju Bai > --- > kernel/kexec_file.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c > index 5c3447cf7ad5..33400ff051a8 100644 > --- a/kernel/kexec_file.c > +++ b/kernel/kexec_file.c > @@ -740,8 +740,10 @@ static int kexec_calculate_store_digests(struct kimage *image) > > sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region); > sha_regions = vzalloc(sha_region_sz); > - if (!sha_regions) > + if (!sha_regions) { > + ret = -ENOMEM; > goto out_free_desc; A good catch. Even though the chance of failure is very small, it does cause issue if happened. Acked-by: Baoquan He Thanks Baoquan > + } > > desc->tfm = tfm; > > -- > 2.17.1 > > > _______________________________________________ > kexec mailing list > kexec@lists.infradead.org > http://lists.infradead.org/mailman/listinfo/kexec >