From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out-176.mta1.migadu.com (out-176.mta1.migadu.com [95.215.58.176]) (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 9A3A644BCA5 for ; Thu, 30 Apr 2026 15:49:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777564154; cv=none; b=UwN2YezyU6DIX/8Oy7I9StVdRQAdM0awOsSVN+H0tYqfuyHijp0HEZScPTBoYOhTLaFRdVBiy0+msA+cNFdTc65Hk2sDZ5nWixmaZhxM07Q+Mr+y6Wb/VFKJkg/BmJopBwmUUyBRUBExp23/iq3HtmujaTjoRGG5+j9JQG1NNKE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777564154; c=relaxed/simple; bh=B/A6auNUdXoDwC07h8sgrRFpq8fcdichT8Vqt7DKumA=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=CldtAgz3vZ09yITiU6z66lu8CThVXAb5DM1VUMGwKf1mIeCXzx1DRjCL6nA3SHsNQtGr5ig0a41Jew4TeXgIMIsn+JtU5sHQ2IPTzFI0aux0qhwzd2gJt2WR57krn009DbyMw/zBoydmINq+u3uNtW61sczSGg8KO3hqRQxsV4o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=iwo+M3QG; arc=none smtp.client-ip=95.215.58.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="iwo+M3QG" Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1777564140; 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=sg09exyfANbcZe40eI+KW434RgIdCLDQC6dSbNk1QGo=; b=iwo+M3QGC2+aMuteqpB4XgW6PETfC0cCr9y2vztm+qkbtmULLim0nNf6RuqKALI7mS+leu 8AuxGb9IrFAvcEaK7MaNC3/Y928kGYbEpIDL+0W47Ou4XaxHLwN0F1nzg5StOBkgPvxPat kB96ryqGmV3ZJdx3aGv9tI/uLp/Z3Gw= Date: Thu, 30 Apr 2026 16:48:54 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH v3] bpf: crypto: snapshot params before string validation To: Pengpeng Hou , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Martin KaFai Lau , Eduard Zingerman , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Shuah Khan , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org References: <20260430043404.58221-1-pengpeng@iscas.ac.cn> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Vadim Fedorenko In-Reply-To: <20260430043404.58221-1-pengpeng@iscas.ac.cn> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 30/04/2026 05:34, Pengpeng Hou wrote: > bpf_crypto_ctx_create() receives a BPF-supplied params pointer. The > current selftests use static initializers, but BPF programs can also > build the struct in writable BPF memory before calling the kfunc. The > verifier checks that the memory is accessible; it does not prove that > the fixed type[] and algo[] fields are NUL-terminated strings. > > Copy the params once into a local snapshot, validate the reserved fields > and fixed-width strings there, and then use the same snapshot for all > later checks and crypto API calls. This also keeps key_len and authsize > stable across validation and use if params points at mutable BPF memory. You didn't answer the question why copying params will somehow help? > > Add a selftest that fills algo[] completely and expects -EINVAL. What happens without the fix? BPF Crypto follows in-kernel Crypto API as all other in-kernel users. If there is a problem in crypto - we have to fix it in crypto subsystem. NAck.