Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp312538rwb; Thu, 10 Nov 2022 00:56:04 -0800 (PST) X-Google-Smtp-Source: AMsMyM6onMF8WqmPrcyTL0C96k5gEwaapYxL45d5YCIs/uyB8vFDaNscxgLLY42q04ltEdOFJ4D3 X-Received: by 2002:a63:e945:0:b0:464:bb6a:50de with SMTP id q5-20020a63e945000000b00464bb6a50demr2032053pgj.502.1668070563755; Thu, 10 Nov 2022 00:56:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668070563; cv=none; d=google.com; s=arc-20160816; b=h5rk/TIxZ+b4yIdk0OlX/nvFuILVaBQROMMluxRAwCm82U0R6jpWxRU7sLQ88TFPfJ YTwQMBwWjPBPLuPFh/o/HCwP77JkbqjW6BFIeViwFLfbUb5Zn5CKS/H5mzGvjPOg9NeQ B+X5aQ1Yo/o5NgiL1cUxca17QrRL+rE4Pr3zO0PByyhsDaS4R+dV37LeX1qOqzid7qcz Tpi5cLYhji/He62BX3Y++uhmFAfvnD0D301Y5rBmvUkN5nGNJ2ps4SVaDxw6yLTryFci wuM0lUQ1FA/J1t3tXTS/DW984Laqm7c7bw7qimNKxtIHoAUOf1/5IZ/98O4cURwszUKu 58yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=dDa7MtggYjP4yfRCHMKUy99tYxh0km4wwhDStrUHbpw=; b=E7EzBlppFvIWmO+cvgGRGyMKT6WykgkPxgDh3pCxGA2lharNdUVNmPl++aYUJpaB3p colcxWN+mdUzCjJO5ZoxFi8VcSL3OpuagY3WcBVQG4RCQ9CHf29rZ1nw6UQd/T/eFu+j ySr00wRj/EpUsK+xrG2nRcQK6TDOz0S3XsJaN9lIp0pPydGAMnnfDjDvFC2DNWlTkuQA 0bDUKjLh4YpCWuq+EpfiKfixLUxecOP7JTVUs19+KO9Itv6Ep2u9EaPHxGmX4t+cYKep 2+mHDSLjNYlZmY8sz7ObeKNt9XhAeG6ZCTZft5a3WXO/8UmcSdzn5CwkLdyudndXh4Is FcCw== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 143-20020a630695000000b004625c2dbc5csi19904117pgg.718.2022.11.10.00.55.41; Thu, 10 Nov 2022 00:56:03 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231923AbiKJIx3 (ORCPT + 99 others); Thu, 10 Nov 2022 03:53:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58094 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232724AbiKJIxZ (ORCPT ); Thu, 10 Nov 2022 03:53:25 -0500 Received: from formenos.hmeau.com (helcar.hmeau.com [216.24.177.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4BCA2EF17; Thu, 10 Nov 2022 00:53:20 -0800 (PST) Received: from loth.rohan.me.apana.org.au ([192.168.167.2]) by formenos.hmeau.com with smtp (Exim 4.94.2 #2 (Debian)) id 1ot3J3-00CUP3-Vh; Thu, 10 Nov 2022 16:53:07 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Thu, 10 Nov 2022 16:53:05 +0800 Date: Thu, 10 Nov 2022 16:53:05 +0800 From: Herbert Xu To: liulongfang Cc: wangzhou1@hisilicon.com, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] crypto/hisilicon: Add null judgment to the callback interface Message-ID: References: <32686c5b-04b2-7103-bf2e-113db2315ef4@huawei.com> <40a0e7aa-362a-0de7-76c0-77381c07f254@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <40a0e7aa-362a-0de7-76c0-77381c07f254@huawei.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,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 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 unless your driver incorrectly declares itself as sync instead of async, then it will never be used by such a user. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt