Message ID | 20221103011713.138974-1-liaochang1@huawei.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp250038wru; Wed, 2 Nov 2022 18:25:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6AM5aMcutENMHdPsq9vqfSyzw4Gffm/SsekAxuZ7HxGkiHN6w0Mw+Q9JuEQ9kmPKeT1cth X-Received: by 2002:a05:6402:5483:b0:45c:1336:6d9b with SMTP id fg3-20020a056402548300b0045c13366d9bmr28077613edb.100.1667438729662; Wed, 02 Nov 2022 18:25:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667438729; cv=none; d=google.com; s=arc-20160816; b=okAmg8c5LxJt0Ex7AUh5v1JTKdvd9dd5Y6/0X6nKRai8xA/KK7J4xDSjSsHFKQV7zR nGfD0IP2j+/hhhlt7d6Cy2icLG6SCDfgtmBRAOxxGPcPGfZUcGsE8YgS3ZV+8HODzRSO 1rK5gl8M9Ju66YSWJo+dYN3OQOuGznEn76AmHdobEoIiESvplYdB9wE03Hgq2BajRSJw ZRCwWgxIMKZQaWsjQ0OmGoAW7e+W+MAuEq6GdqkwKPlTxMtYEhPJy/5zUq5U4tABJnVo Y9IC9jWtqt8Oa4zzHKwqqZ+vv7zIS+eHDUK9uHRAAMXwPTKdeXBOyfhtZ1vhohgj07SE jm7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from; bh=ZG0jWu2bz1NzeME7OuI7UHOMKVUaTnE1F1rVPMpw554=; b=Qb5XYQWBIdcHcWpm80P6RNo+WmcpM3gHxdrL6H1NzZU1HxEb6QY7iA//sbX4Dkpz82 SN+gs9XHhv5pWPVDzCDs1nwrvetNb95t5ZuXmNSLjN4xcEVXtl8Q3R6e31dcihHSuEfY hkdUa+OAfMSUq6p73ywP05qVvZdoIc5R3Gc04M1QKyt5ahEkFunxHH0Ey8jglVTG4a0y Athzpl1tA3Rg0WWFq0zo9AFPF0YO/0XdlWtp4FJnparP67Jk5T8wy0ckECGAlYGhholF W9ZnUH1NJ7H7rOiY7zjFQ69ASTTl6Q6VJwwLiVeCc+UirWLyN3Q3oIVLjINsW8GvhxFx BhkA== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id sg39-20020a170907a42700b0078db3ae83d0si18641579ejc.3.2022.11.02.18.25.04; Wed, 02 Nov 2022 18:25:29 -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; 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=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbiKCBUd (ORCPT <rfc822;yves.mi.zy@gmail.com> + 99 others); Wed, 2 Nov 2022 21:20:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229485AbiKCBUb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 2 Nov 2022 21:20:31 -0400 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA05612745 for <linux-kernel@vger.kernel.org>; Wed, 2 Nov 2022 18:20:30 -0700 (PDT) Received: from kwepemi500012.china.huawei.com (unknown [172.30.72.55]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N2m8G2jT7zJnQL; Thu, 3 Nov 2022 09:17:34 +0800 (CST) Received: from huawei.com (10.67.174.53) by kwepemi500012.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Thu, 3 Nov 2022 09:20:28 +0800 From: Liao Chang <liaochang1@huawei.com> To: <linux@armlinux.org.uk>, <linus.walleij@linaro.org>, <ardb@kernel.org>, <liaochang1@huawei.com>, <nico@fluxnic.net>, <rmk+kernel@armlinux.org.uk>, <chenzhongjin@huawei.com> CC: <linux-arm-kernel@lists.infradead.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH] ARM: module: Reclaim the unwind list of module on kmalloc failed Date: Thu, 3 Nov 2022 09:17:13 +0800 Message-ID: <20221103011713.138974-1-liaochang1@huawei.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.67.174.53] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemi500012.china.huawei.com (7.221.188.12) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1748436233381393041?= X-GMAIL-MSGID: =?utf-8?q?1748436233381393041?= |
Series |
ARM: module: Reclaim the unwind list of module on kmalloc failed
|
|
Commit Message
Liao Chang
Nov. 3, 2022, 1:17 a.m. UTC
When unwind table allocation failed, it needs to reclaim the unwind list
of module to avoid potential NULL pointer exception and memory leakage.
Fixes: b6f21d14f1ac ("ARM: 9204/2: module: Add all unwind tables when load module")
Signed-off-by: Liao Chang <liaochang1@huawei.com>
Cc: Chen Zhongjin <chenzhongjin@huawei.com>
---
arch/arm/kernel/module.c | 4 ++++
1 file changed, 4 insertions(+)
Comments
On 2022/11/3 9:17, Liao Chang wrote: > When unwind table allocation failed, it needs to reclaim the unwind list > of module to avoid potential NULL pointer exception and memory leakage. > > Fixes: b6f21d14f1ac ("ARM: 9204/2: module: Add all unwind tables when load module") > Signed-off-by: Liao Chang <liaochang1@huawei.com> > Cc: Chen Zhongjin <chenzhongjin@huawei.com> > --- > arch/arm/kernel/module.c | 4 ++++ > 1 file changed, 4 insertions(+) > > diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c > index d59c36dc0494..cc637dcdcb10 100644 > --- a/arch/arm/kernel/module.c > +++ b/arch/arm/kernel/module.c > @@ -485,6 +485,10 @@ int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs, > s->sh_size, > txt_sec->sh_addr, > txt_sec->sh_size); > + if (!table) { > + module_arch_cleanup(mod); > + return -ENOMEM; > + } > > list_add(&table->mod_list, unwind_list); > Looks good to me. Reviewed-by: Chen Zhongjin <chenzhongjin@huawei.com> Thanks.
On Thu, Nov 3, 2022 at 2:20 AM Liao Chang <liaochang1@huawei.com> wrote: > When unwind table allocation failed, it needs to reclaim the unwind list > of module to avoid potential NULL pointer exception and memory leakage. > > Fixes: b6f21d14f1ac ("ARM: 9204/2: module: Add all unwind tables when load module") > Signed-off-by: Liao Chang <liaochang1@huawei.com> > Cc: Chen Zhongjin <chenzhongjin@huawei.com> Looks good to me: Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Please put this into Russells patch tracker. Yours, Linus Walleij
diff --git a/arch/arm/kernel/module.c b/arch/arm/kernel/module.c index d59c36dc0494..cc637dcdcb10 100644 --- a/arch/arm/kernel/module.c +++ b/arch/arm/kernel/module.c @@ -485,6 +485,10 @@ int module_finalize(const Elf32_Ehdr *hdr, const Elf_Shdr *sechdrs, s->sh_size, txt_sec->sh_addr, txt_sec->sh_size); + if (!table) { + module_arch_cleanup(mod); + return -ENOMEM; + } list_add(&table->mod_list, unwind_list);