Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2929285rwb; Fri, 11 Nov 2022 17:58:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf4cJB/M1ek6KdlTNBIIX7IAYNMQYhNHvJSwTawCpQcMVreLQfR8aMx8PBdJIF6uovmuEPEh X-Received: by 2002:a05:6402:1682:b0:45c:a9d3:d535 with SMTP id a2-20020a056402168200b0045ca9d3d535mr3867003edv.0.1668218325523; Fri, 11 Nov 2022 17:58:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668218325; cv=none; d=google.com; s=arc-20160816; b=ga84Pko7t2xY2PX89afRKxc9BWJevIY4++T0ZowqF9lsvSr0FPVYg2DdokSc4rpT0S znPwXsSisWZjlThv1mT4YNgnHRh2NrbNmLETIjm2lyQV+aL7Bu+WCDQffqJ0FpRomDEY appMO6tn8PIRUrQIYObQzoyxz3Co495BfOXCCtKcXlLnDuKMWh+bB1v0smmLG4UyzuTJ PPmJ7ILxhe7MYSp3bIex7J/wLYSVYgBLlKNWx5KRnK3QTVF7Q+Dk6VRmzzbtAlO5FIi/ JR0Ivvopj6WmIGB8LN6RXtI6Q/qqljHk7FNrPo3Idmb8aXK4hDufH2XcNAs3fPTJBNZ3 h1tQ== 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 :mime-version:user-agent:date:message-id:from:references:cc:to :subject; bh=SGHnT+dwu6KGQ5fRvmXq34tVK9KYA1Wz21eFVl8GOW8=; b=PVdNAZWm7z3vU9LKp1f0TgjH/oBZOcypt5oQaKaJ1U8VSP/di3mb9KZOzjCEJfvhdt o/Us8BgE27B+KYLFmDnA2mRkxM/NfxCNcKrFT2+2NQxpR+Fkrw6XN8fn+2LbLkC5eT/W hNl8nOlNWrIcNSQUO4eCl5e5mHWqBlzHVh6qqgb77KOtv9ScBcaksHl+OTtDP2UpoIHJ CJv4BjnkIoQed6QSkEtTJnCCjoggbhBT05DMvv63YIizH11+mfYxZim06rj7nq1gcxdO z6qTHU6aata6Uz5XtIJc/yeyNDTc5nuGMFIiguiyxGenv0EuFdwVpsMGMZX9zs0jaYmu rB3A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b8-20020a056402278800b0046771defe07si1729995ede.529.2022.11.11.17.58.11; Fri, 11 Nov 2022 17:58:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-crypto-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 S232921AbiKLBwC (ORCPT + 99 others); Fri, 11 Nov 2022 20:52:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229991AbiKLBwB (ORCPT ); Fri, 11 Nov 2022 20:52:01 -0500 Received: from szxga03-in.huawei.com (szxga03-in.huawei.com [45.249.212.189]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD2DD6A747; Fri, 11 Nov 2022 17:51:59 -0800 (PST) Received: from dggemv711-chm.china.huawei.com (unknown [172.30.72.57]) by szxga03-in.huawei.com (SkyGuard) with ESMTP id 4N8JQF5WYdzJnfp; Sat, 12 Nov 2022 09:48:53 +0800 (CST) Received: from kwepemm600005.china.huawei.com (7.193.23.191) by dggemv711-chm.china.huawei.com (10.1.198.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 09:51:56 +0800 Received: from [10.67.103.158] (10.67.103.158) by kwepemm600005.china.huawei.com (7.193.23.191) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.31; Sat, 12 Nov 2022 09:51:56 +0800 Subject: Re: [PATCH] crypto/hisilicon: Add null judgment to the callback interface To: Herbert Xu CC: , , References: <32686c5b-04b2-7103-bf2e-113db2315ef4@huawei.com> <40a0e7aa-362a-0de7-76c0-77381c07f254@huawei.com> From: liulongfang Message-ID: <54c1aa3a-9e51-a90f-416a-dc65a70a1b8a@huawei.com> Date: Sat, 12 Nov 2022 09:51:55 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="gbk" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.67.103.158] X-ClientProxiedBy: dggems706-chm.china.huawei.com (10.3.19.183) To kwepemm600005.china.huawei.com (7.193.23.191) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,NICE_REPLY_A, 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: X-Mailing-List: linux-crypto@vger.kernel.org On 2022/11/10 16:53, Herbert Xu wrote: > On Thu, Nov 10, 2022 at 12:11:15PM +0800, liulongfang wrote: >> >> When using crypto's skcipher series interfaces for encryption and decryption >> services, User can use synchronous mode(by adjusting some skcipher interfaces, >> here is to remove skcipher_request_set_callback()) or asynchronous mode, >> but when using synchronous mode and the current asynchronous mode is loaded >> it will cause a calltrace. >> >> The current problem is that the interface of skcipher does not restrict users >> to call functions in this way for encryption services. >> >> If the current driver doesn't handle this, there is a possibility that some users >> deliberately create this kind of problem to cause the kernel to crash. > > It sounds like your code is misusing the skcipher API. By default > skcipher is always async. You must always set a callback. > > The only way to legally use skcipher without setting a callback > is by allocating it with crypto_alloc_sync_skcipher. In which case OK! I found in Documentation/crypto/architecture.rst the description that async mode must provide a callback function. However, what is confusing is that this document does not describe the synchronization mode so clearly. > unless your driver incorrectly declares itself as sync instead of > async, then it will never be used by such a user. > > Cheers, > Thanks, Longfang.