From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 860C4301473 for ; Wed, 26 Nov 2025 10:55:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.41 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154516; cv=none; b=ec070NWKiY+Uui5PtN7St8kF7q6Rirj3ODOL0zkewwK+98hZtX7IWcIfxXtaDi97fG57/E0tZ7GqDWgLFuuK9+rUhUurYlbmm5o8KqEmUcsypqJ9VmKPJ6rByeoVMpZe7N/E0/iBQLyyNr+ut9/PTZZEDiyBJ5xVvmUGdKQVzm4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764154516; c=relaxed/simple; bh=ox7MSuzPIeIIE7aLoA8rsi8xRs8yOy1dZB8ukDyKoNo=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=E/fg8m8CZZIRI6Bpyf5IZvujyr46QDiLjL/F6BRY7eDTZTkiwysLvKlirfKVhN4VREU7QNjjt68wnGAjYKSwr0+5VIcVDIAbWUdRQpDx39PovFSHtRL+bcJv4HYp02bc2vTjwY8bwmxNBUE2EPlnXvQt+H0Cxlifg0BMzzlVRxM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=UtY0J4dq; arc=none smtp.client-ip=209.85.128.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UtY0J4dq" Received: by mail-wm1-f41.google.com with SMTP id 5b1f17b1804b1-477b198f4bcso43054035e9.3 for ; Wed, 26 Nov 2025 02:55:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1764154513; x=1764759313; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=ox7MSuzPIeIIE7aLoA8rsi8xRs8yOy1dZB8ukDyKoNo=; b=UtY0J4dqD2YFIap9aAvGeQVZn1gHqyu75H2wdHUXsc1TZ9br8bvMI9dRv3Q5u2MDTW PkVnA0+car8RYWAhiuKAs2MhcPwOZe9xDq5eb1Kn8ow0aqv/bBiQL1K6sBrx0TANP9NF aG4nqWAfYBWDsfCd5Q4TIk9/OJmOHtoD78BtQ2S8opyljcUMHLW1RoWs8AmJ3k221oRn Cl+YEDLuw2g7rgaEA0UjRo3vwePPi/XFM9Cob8YY2TY1bOJD6dywGmKe9bh4HlhUo1SY s52gijFXz5N2bv5F4VoYZI+PvZ6ZTmBcdnGzP4f/hUKmePu/fsVymgyJun8Dyqgzf3v5 dvnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764154513; x=1764759313; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ox7MSuzPIeIIE7aLoA8rsi8xRs8yOy1dZB8ukDyKoNo=; b=pqEx+09VwptwR0Jw1ccYrZdga4TDQBwd9Ekd0eU8Vitocj7mQE3h62SpK1WpfBTEV8 kC19yphmpCgci+fATSQfBmQTF1zWa36KgzSpFiNvXWd7VLYMqw11SDd8Mnc4906RW0ji W6PC9dSeV2nySqb4BrRjmfLyyZhB34AV36ZLgD75IbCN0zgHmkKrR2z+S5PGb7F9oYXI TAIMnfvB+4eOj7mnn2ojsHe8Wq2dxphnb30HZVaotf2UBL9Xys9mGjVglmI8vxLfXUOP DxYI0kuE30fU4miW4PWt8iY+vCfBJL484ncktIMnUWthbIaxluuXwOk1kE7EgAgmrFYz B7JQ== X-Forwarded-Encrypted: i=1; AJvYcCWndkAZLX3THX2wJz4kBbW9a4FPVOxPwYLzUX8aXMHopazsz1RxaiSpntWDM7AIBZNSxXKGsHIFPAzHlrA=@vger.kernel.org X-Gm-Message-State: AOJu0YwFLD+vq7MsmBtqk83zehl16PGwX4tZrPDLFYaESiVCuuh9VMAQ pGE/s4ae+uIMXLLLYHmEqjhJkkkDgqchBzerOhU2eyvCaVCykrgydu/9 X-Gm-Gg: ASbGncs9neZ6lGGrxCr64QeWmwglQ3X4ct7Nnx80Gfhfe7zTLY2v7ikRMxSKU0jO+50 3CQ1ZJo401Nu2WtlQt8F2EFSzh33l2xh4z0YqOTe7YJphphAEpeiV9CGCo6ICstr6wkudN2UL6X 9pQulgzjn+p0AESD6f1VMH/5S299CpYs5g/0yswIdhMzunrBvREZUdQJJgcs5iyVqyT8ToMeGKe nG8Sy98C5zPp08WDmQ+lW9Xxuxe+WCtKGUCM1Ra+UhbnAzOh/hbrIWdLCVA7V1hGKcgPFJgUpyx SPh4RcnMa8wWYzzOFk1CTCI3bLEVYDFzs3YFQcbyvhzEbvEJCbUtVyB8CTLZPqaBd39UCtXAUgw i+Jt2IEGEnU+Jr6IZRWo0SpyVR0rKNnC8XwD0cC3+FwDAk59jbICab/CxWQIlQOlkfIxcqoIGIl BfYcNCPGDxLsepbbz3yoSO0M5A1aZKLgUXSA== X-Google-Smtp-Source: AGHT+IHcHI6170B8NfKQQMp8egrR1vGwUk5xF9DhlZO/uq9fy+Xjr5nT4MGqEAz9VgSn2UVWyQL5GA== X-Received: by 2002:a05:600c:1d0e:b0:477:bb0:751b with SMTP id 5b1f17b1804b1-477c01c4d79mr178895815e9.27.1764154512550; Wed, 26 Nov 2025 02:55:12 -0800 (PST) Received: from vitor-nb.Home (bl19-170-125.dsl.telepac.pt. [2.80.170.125]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4790add2648sm40933725e9.4.2025.11.26.02.55.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 26 Nov 2025 02:55:11 -0800 (PST) Message-ID: Subject: Re: CAAM RSA breaks cfg80211 certificate verification on iMX8QXP From: Vitor Soares To: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev Cc: horia.geanta@nxp.com, pankaj.gupta@nxp.com, gaurav.jain@nxp.com, herbert@gondor.apana.org.au, john.ernberg@actia.se, meenakshi.aggarwal@nxp.com Date: Wed, 26 Nov 2025 10:55:10 +0000 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.44.4-0ubuntu2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ++imx@lists.linux.dev On Mon, 2025-11-24 at 19:03 +0000, Vitor Soares wrote: > I=E2=80=99m currently investigating an issue on our Colibri iMX8QXP SoM r= unning kernel > 6.18-rc6 (also reproducible on v6.17), where cfg80211 fails to load the > compiled-in X.509 certificates used to verify the regulatory database > signature. >=20 > During boot, I consistently see the following messages: > =C2=A0cfg80211: Loading compiled-in X.509 certificates for regulatory dat= abase > =C2=A0Problem loading in-kernel X.509 certificate (-22) > =C2=A0Problem loading in-kernel X.509 certificate (-22) > =C2=A0cfg80211: loaded regulatory.db is malformed or signature is missing= /invalid >=20 > As part of the debugging process, I removed the CAAM crypto drivers and > manually > reloaded cfg80211. In this configuration, the certificates load correctly= and > the regulatory database is validated with no errors. >=20 > With additional debugging enabled, I traced the failure to > crypto_sig_verify(), > which returns -22 (EINVAL). > At this stage, I=E2=80=99m trying to determine whether: > =C2=A0- This is a known issue involving cfg80211 certificate validation w= hen the > CAAM > hardware crypto engine is enabled on i.MX SoCs, or > =C2=A0- CAAM may be returning unexpected values to the X.509 verification= logic. >=20 > If anyone has encountered similar behavior or can suggest areas to > investigate=E2=80=94particularly around CAAM=E2=80=94I would greatly appr= eciate your guidance. >=20 > Thanks in advance for any insights, > V=C3=ADtor Soares Following up with additional debugging findings. I traced the -EINVAL to rsassa_pkcs1_verify() in the PKCS#1 v1.5 verificati= on path. The check that fails expects a leading 0x00 byte in the RSA output bu= ffer. To investigate further, I poisoned the output buffer with 0xAA before the R= SA operation. CAAM RSA operation returns success, but the output buffer is nev= er written to. During debugging, I loaded cfg80211 multiple times and observed that sporadically one of the certificates gets verified correctly, but never bot= h. I confirmed that other CAAM operations work correctly by testing hwrng via /dev/hwrng, which produces valid random data. Given that CAAM reports success but does not populate the RSA output buffer= , the problem appears to be somewhere in the RSA execution flow (possibly in how = the result buffer is handled or returned), but I don=E2=80=99t have enough insi= ght into CAAM's RSA implementation or firmware interaction to pinpoint the exact cau= se. As noted previously, blacklisting caam_pkc to force rsa-generic resolves th= e issue. Regards, V=C3=ADtor