Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1870832lqe; Tue, 9 Apr 2024 02:59:44 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXMa2sxg/PwRFyN29r0vVmlYmSFpJqPwoqJ+UiucMKTwW6ynJg/A7TUFDh4yOfXer/rHUpFYOmh9P9kQj2nm4L3/a5TFKqX1QukFiCfnw== X-Google-Smtp-Source: AGHT+IG+DyviHfy6jYBiMUipNQedRPEbvBa3TIZrmIVtdox0OjpvT7Qf3jnuIT9FKMN8xx6hM/ZY X-Received: by 2002:a17:90b:1bcc:b0:2a0:2fb3:c1ff with SMTP id oa12-20020a17090b1bcc00b002a02fb3c1ffmr9172086pjb.15.1712656784470; Tue, 09 Apr 2024 02:59:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712656784; cv=pass; d=google.com; s=arc-20160816; b=PX4d9w/yRbnNGH5ChY5Frmp9JaFuE5l3m+vStIo5sTnRwH5f84jSLDmuLTSDT13k5z Uz1AbhsiXuyMtoGT0h9WWUrwmUBxYRVJox0sCOCTA9hPEMGRVm64mYIM+TeYUo3BW7Fb ATX1D66EI+xdTe6FtTE0LZSCMQDcprhZHv2k+0AMB8Dk3Hq941Hu7g3DSxaPhR2E8MXB zJGCYef/ZcKXwfhEMSMeGvcvLXIEwU3sEjMR2FIqCL8XVTfjwLkdZ2VzQu8jsGl2tZPK SgIqGbGDaPMqosjqEOo2HBPpt0DsIgeZgdb8AweX7Vywq3Vbqm7jQKe3C8ejGNX/v54v PduQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date; bh=Gm5jRktmPncxytHdqQwYcbbiHk2yg1IhHdnhuVIbEp4=; fh=coGNHahnVK83nBmFQeuhi8SwgTDzYHrIp3ijTmdYZlo=; b=HkB/AIBUuEDpz4v14TD6g5gD1Hjs8THjzVJAYUltfUpju28D7IBpI8hzMs37dq6FBC gcx2N1AP3APKP/1QDB/k+7f/zu/KQfUnQVCQfFkKKK1AmZtXvV5pwisY8817CG7p5wvp BD3LDAxD3Y1+JsO0ZJV+/IuAZx2U/2EZ/nzDcTh3Io3tc47gATe2hVgfGP3gaVeRzCF2 GPHn5qv9I06K0lM5o+tfpYT5Z5GjFq1rkwG+BOUMjzS6KsklN6HkGZDzZH2IHf/uxo3j 6gnHx3cRsqldUQtQYcL7d5SgYNFWOio5ltj/DvqyogE9NaQ2xFhrw9nVkDkqlw0ladzu z/+Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au dmarc=pass fromdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-3417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=QUARANTINE dis=NONE) header.from=apana.org.au Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id m193-20020a633fca000000b005e438e94b1esi8553851pga.382.2024.04.09.02.59.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:59:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=gondor.apana.org.au dmarc=pass fromdomain=gondor.apana.org.au); spf=pass (google.com: domain of linux-crypto+bounces-3417-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3417-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (p=REJECT sp=QUARANTINE dis=NONE) header.from=apana.org.au Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id B1B0DB214B8 for ; Tue, 9 Apr 2024 09:56:21 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B48FF8003F; Tue, 9 Apr 2024 09:56:17 +0000 (UTC) X-Original-To: linux-crypto@vger.kernel.org Received: from abb.hmeau.com (abb.hmeau.com [144.6.53.87]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 20B7A80038 for ; Tue, 9 Apr 2024 09:56:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=144.6.53.87 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656577; cv=none; b=Gs7Gb9eEo1GVcnHC8CyMNKO0MAkPeg+k+SNpoYDV5MxfD5fIqXRnsK4Pjsy+/aI30c1nul7gof0S5uAdv8x961cRwTdK0qsRomlI9vdqEsvs8AjQeHGcbDnpn4IigLQGM2NO9IAS/pRomJk7wZkAQTQcp98tqRFM2c8K/dTWuJs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712656577; c=relaxed/simple; bh=3tudJ8zr0TwEy9GzsXNb7ZK28bJrYL87s3kQv+Iyiog=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Jk5D3Ak+YkuvmWdznQoDQnBL3S5kwl9aBopUicJ6ykQ0lVtJZVkKi46Na2S26yCwSrRWdMZ3yCkieM0sETdC+Y1w2n9YDfFIt6wSYYwCYEKXq5hH1/UW9LqAS8EbNvp0eQJY5wuTaIiYf3OnfVxXbji5rjmDfidl3tBqnlxOiRM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au; spf=pass smtp.mailfrom=gondor.apana.org.au; arc=none smtp.client-ip=144.6.53.87 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=gondor.apana.org.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gondor.apana.org.au 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 1ru8Cr-00GyEv-JI; Tue, 09 Apr 2024 17:55:58 +0800 Received: by loth.rohan.me.apana.org.au (sSMTP sendmail emulation); Tue, 09 Apr 2024 17:56:14 +0800 Date: Tue, 9 Apr 2024 17:56:14 +0800 From: Herbert Xu To: David Howells Cc: "David S. Miller" , linux-crypto@vger.kernel.org Subject: Re: Incorrect use of CRYPTO_ALG_ASYNC in crypto_alloc_sync_skcipher()? Message-ID: References: <1068289.1712656290@warthog.procyon.org.uk> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1068289.1712656290@warthog.procyon.org.uk> On Tue, Apr 09, 2024 at 10:51:30AM +0100, David Howells wrote: > Hi Herbert, > > Is the following code in crypto_alloc_sync_skcipher() wrong: > > /* Only sync algorithms allowed. */ > mask |= CRYPTO_ALG_ASYNC | CRYPTO_ALG_SKCIPHER_REQSIZE_LARGE; > > in its specification of CRYPTO_ALG_ASYNC? Given what the docs say: > > The mask flag restricts the type of cipher. The only allowed flag is > CRYPTO_ALG_ASYNC to restrict the cipher lookup function to > asynchronous ciphers. Usually, a caller provides a 0 for the mask flag. > ^^^^^^^^^^^^ > > or are the docs wrong? The mask is used together with the type bitfield. You need to set CRYPTO_ALG_ASYNC in both bitfields if you want to guarantee getting an async cipher. If you set CRYPTO_ALG_ASYNC in the mask but leave it unset in the type bitfield then you are guaranteed to get an algorithm with this bit turned off, in other words a synchronous cipher. Cheers, -- Email: Herbert Xu Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt