Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4501619rdb; Fri, 15 Sep 2023 04:26:14 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEgvh4abYblfYvIEU+7LrP3Zbfn06vzKPceVuZH3K1zowpwD5UDuBV1UFBbbbvhmdhFNcvH X-Received: by 2002:a05:6a21:4994:b0:14c:9b51:f1fc with SMTP id ax20-20020a056a21499400b0014c9b51f1fcmr1342672pzc.61.1694777174544; Fri, 15 Sep 2023 04:26:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694777174; cv=none; d=google.com; s=arc-20160816; b=LJbB4PAuzFYvaYH0bKs5sFdKq7queWoQaLrBjK6m2N2LsNWE6uA5rzjPum2X7cXKbS Lqxx8jJZuD0RhU/BQ70nj4q5UzFspo31Qwn2lO0WEGjoOOd3BYghAhX2wNU08rat8sJ8 8oTzt77OWUGF0mnqfnbpKP8HFGZINjT4JRLPNoophfxT5BwqyJiQMxkrcHVTqpSrWMM/ RuKLdJcL3yjK1yRUPJlj/eWzQyo0cFNBOqKIKB9UL4c3e+Mz5rFFLUrk0r02r6x8zEgu +q4tG4KsMkTAr6ActYS1T0al8LwSaX2cHeEqAkHBodq9iXXFlfSwW1P0hysiIaV27JmH ZDbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=87PX7oainfj93/8XJYxZJWgjssTKHHctvq3UjqkSuco=; fh=rQ/6R+5eRdrz4tS+C5lbgFAJ3TSeKAK/1Hf7nM9jk00=; b=kZx2TFdn32TqtKIX8FCQYGURFPCWASM8X6ytD4k2/Mo32X8UmkFgMhNxsSLmsaWZl1 Z6EfQxPUcGKbFwEZ4o7MgN3RRaB65oaerNSYIcQNlzflUrfWDdgS5JieMtweQMOXjW4M KVXG7mTxlLPivP0JAK/t3GhdCGO9Gg8r2PdDT8Khy0Jcg/uSxuEF2Q2lPUzf99FekWBM upXe8SwUQlkFa5eLHlcLOYgmX22UuTe4q8G9lXdDhxu1RVseagk3NGNVddNKsz/5k7oa zUuC5dwcqwX8+uqBSg8MVXjMeGb/F0L/XwWjXLomTzBiDOIHAKa1fSn0gJx2qOSK8cia AaEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id r135-20020a632b8d000000b00563ef545828si3172690pgr.8.2023.09.15.04.26.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 04:26:14 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 9EB4483DD688; Fri, 15 Sep 2023 04:19:04 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230153AbjIOLSy (ORCPT + 99 others); Fri, 15 Sep 2023 07:18:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40086 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232147AbjIOLSx (ORCPT ); Fri, 15 Sep 2023 07:18:53 -0400 Received: from out30-130.freemail.mail.aliyun.com (out30-130.freemail.mail.aliyun.com [115.124.30.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E46A7101 for ; Fri, 15 Sep 2023 04:18:46 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R941e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018045170;MF=tianjia.zhang@linux.alibaba.com;NM=1;PH=DS;RN=2;SR=0;TI=SMTPD_---0Vs7-ZUD_1694776723; Received: from 30.240.107.178(mailfrom:tianjia.zhang@linux.alibaba.com fp:SMTPD_---0Vs7-ZUD_1694776723) by smtp.aliyun-inc.com; Fri, 15 Sep 2023 19:18:44 +0800 Message-ID: <6f11a61f-1575-2886-0198-1f5947f9f835@linux.alibaba.com> Date: Fri, 15 Sep 2023 19:18:42 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.15.0 Subject: Re: [bug report] lib/mpi: Extend the MPI library Content-Language: en-US To: Dan Carpenter Cc: linux-crypto@vger.kernel.org References: <800d9813-af24-4b4a-ba0f-45a37515902c@moroto.mountain> From: Tianjia Zhang In-Reply-To: <800d9813-af24-4b4a-ba0f-45a37515902c@moroto.mountain> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Fri, 15 Sep 2023 04:19:05 -0700 (PDT) Hi, Dan Carpenter, On 9/15/23 3:21 PM, Dan Carpenter wrote: > Hello Tianjia Zhang, > > The patch a8ea8bdd9df9: "lib/mpi: Extend the MPI library" from Sep > 21, 2020 (linux-next), leads to the following Smatch static checker > warning: > > lib/crypto/mpi/mpiutil.c:202 mpi_copy() error: potential null dereference 'b'. (mpi_alloc returns null) > lib/crypto/mpi/mpiutil.c:224 mpi_alloc_like() error: potential null dereference 'b'. (mpi_alloc returns null) > lib/crypto/mpi/mpiutil.c:258 mpi_set() error: potential null dereference 'w'. ( returns null) > lib/crypto/mpi/mpiutil.c:277 mpi_set_ui() error: potential null dereference 'w'. ( returns null) > lib/crypto/mpi/mpiutil.c:289 mpi_alloc_set_ui() error: potential null dereference 'w'. (mpi_alloc returns null) > > lib/crypto/mpi/mpiutil.c > 195 MPI mpi_copy(MPI a) > 196 { > 197 int i; > 198 MPI b; > 199 > 200 if (a) { > 201 b = mpi_alloc(a->nlimbs); > > Allocations can fail. > > --> 202 b->nlimbs = a->nlimbs; > 203 b->sign = a->sign; > 204 b->flags = a->flags; > 205 b->flags &= ~(16|32); /* Reset the immutable and constant flags. */ > 206 for (i = 0; i < b->nlimbs; i++) > 207 b->d[i] = a->d[i]; > 208 } else > 209 b = NULL; > 210 return b; > 211 } > > regards, > dan carpenter Thanks for reminding me, these are some remaining issues that needs more modifications. I will take the time to fix them. Cheers, Tianjia