Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2340102rdb; Sun, 3 Dec 2023 12:33:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFCv+4XWSBF8xwB+Is+4l0lUUYTFyKxb3VZoIy/u39HnJPAyLzhxpCxWwFPOUNRXFiOlEjf X-Received: by 2002:a05:600c:9a2:b0:40b:5e59:99bd with SMTP id w34-20020a05600c09a200b0040b5e5999bdmr1505970wmp.221.1701635618321; Sun, 03 Dec 2023 12:33:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701635618; cv=none; d=google.com; s=arc-20160816; b=f452Kes1vRhHVzgUm7RzgRLg0+KNm/7KybFzOaFgs4Rt8J2q4Ganr7sTHRNFnMeqL9 ExSMYfq2FpNP9h4qBn3242ehnJ21rAFGjOC7S12zRjyQf1TeGGMoExfIj+bVby1uB/F4 R6F+9NjHk2hBnf+ELJc1A+cSVSyxHEnz8xvXPfZV7mOC2nLiPSJ2OvObVPTrEiRYwkM2 IP49iJ7hPTGkG9wH/7vz7gfHJpt6B5fEOJKEKzIhORjDn25fdBKSq7kFDuGsoxuvOmvA 6Wfgzsw6dn4r0V8ZEN1N8Hs8TIcrvH/JUjocl81a+uz+s1G+TV04QGeOrPn4OszNJvWO 2gJQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=Wq4rDgWW2SmuNmn6jKwaMqEYOLB2GQKsCbNg2kGA0U8=; fh=xBwdP8W9PYNgCVvHjzt6MNXi7JUOcIHv9iCvihbkxQc=; b=AJIrYbZ+Wlp2MTyud78xY2bPoJb/eyoYed7JaY2VGGQKxMGUC4hWU6pVW1seL1yUYx PpJznXNoNzsuELC0ljHP384UvsbGDwatf/UQqbDO2SaOWjp75IJEBSmnnEIXoLC/l44Y tPyP8GN5uweWFgq1sQIKhLCqsgOSYBYK1LFRo7bPAJHvQHtFXULTou0GPD/X+4uFXmmq 2R0Q3elfPEl5XZggGklBFP0deqtSziYJjVqZSB6joaltJGVB55yzUkhB+t2rTFOdeEJq K28/isLQltpGY4/2uMixBCvIm6w4q2i/EAC7ux41R3trEyIcR6PhlpILETK20WuRsF6D eMDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=w8AJALyp; spf=pass (google.com: domain of linux-crypto+bounces-517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d15-20020a170906344f00b009e737bc9173si3858656ejb.164.2023.12.03.12.33.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 03 Dec 2023 12:33:38 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto+bounces-517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=w8AJALyp; spf=pass (google.com: domain of linux-crypto+bounces-517-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-crypto+bounces-517-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev 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 am.mirrors.kernel.org (Postfix) with ESMTPS id 0AF481F2117D for ; Sun, 3 Dec 2023 20:33:38 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 88A461EB39 for ; Sun, 3 Dec 2023 20:33:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="w8AJALyp" X-Original-To: linux-crypto@vger.kernel.org Received: from out-188.mta0.migadu.com (out-188.mta0.migadu.com [IPv6:2001:41d0:1004:224b::bc]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E11D9 for ; Sun, 3 Dec 2023 11:09:02 -0800 (PST) Message-ID: <7ac7b494-2409-6f2d-b18a-ac5154545066@linux.dev> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1701630540; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Wq4rDgWW2SmuNmn6jKwaMqEYOLB2GQKsCbNg2kGA0U8=; b=w8AJALypv0b/Q/gBNDOmGxnxkINypVNQzu/6pThMwUuyxASx5epojzqd/4aco1nZqo/d4U FBvMvlppoIpxAcJUuu5aHseNpDz7+YTmSN/Vg7wzJEeGN8nW2DKDpDnqFge9W4zaih08/A 2+/bv8k4gvT19iv+hrm/wQuzw00+y4o= Date: Sun, 3 Dec 2023 19:08:58 +0000 Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH bpf-next v7 1/3] bpf: make common crypto API for TC/XDP programs Content-Language: en-US To: Simon Horman , Vadim Fedorenko Cc: Jakub Kicinski , Martin KaFai Lau , Andrii Nakryiko , Alexei Starovoitov , Mykola Lysenko , Herbert Xu , netdev@vger.kernel.org, linux-crypto@vger.kernel.org, bpf@vger.kernel.org References: <20231202010604.1877561-1-vadfed@meta.com> <20231203105748.GD50400@kernel.org> X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20231203105748.GD50400@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 03.12.2023 10:57, Simon Horman wrote: > On Fri, Dec 01, 2023 at 05:06:02PM -0800, Vadim Fedorenko wrote: >> Add crypto API support to BPF to be able to decrypt or encrypt packets >> in TC/XDP BPF programs. Special care should be taken for initialization >> part of crypto algo because crypto alloc) doesn't work with preemtion >> disabled, it can be run only in sleepable BPF program. Also async crypto >> is not supported because of the very same issue - TC/XDP BPF programs >> are not sleepable. >> >> Signed-off-by: Vadim Fedorenko > > ... > >> +/** >> + * bpf_crypto_ctx_create() - Create a mutable BPF crypto context. >> + * >> + * Allocates a crypto context that can be used, acquired, and released by >> + * a BPF program. The crypto context returned by this function must either >> + * be embedded in a map as a kptr, or freed with bpf_crypto_ctx_release(). >> + * As crypto API functions use GFP_KERNEL allocations, this function can >> + * only be used in sleepable BPF programs. >> + * >> + * bpf_crypto_ctx_create() allocates memory for crypto context. >> + * It may return NULL if no memory is available. >> + * @type__str: pointer to string representation of crypto type. >> + * @algo__str: pointer to string representation of algorithm. >> + * @pkey: bpf_dynptr which holds cipher key to do crypto. > > Hi Vadim, > > a minor nit from my side: something about @authsize should go here. > Hi Simon! Good catch, I'll definitely add description to authsize, thanks! >> + * @err: integer to store error code when NULL is returned >> + */ >> +__bpf_kfunc struct bpf_crypto_ctx * >> +bpf_crypto_ctx_create(const char *type__str, const char *algo__str, >> + const struct bpf_dynptr_kern *pkey, >> + unsigned int authsize, int *err) > > ...