mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: ZhaoJinming <zhaojinming@uniontech.com>
To: Herbert Xu <herbert@gondor.apana.org.au>,
	 "David S. Miller" <davem@davemloft.net>,
	Lokesh Vutla <lokeshvutla@ti.com>,  Tero Kristo <t-kristo@ti.com>
Cc: linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	 linux-omap@vger.kernel.org, stable@vger.kernel.org,
	 ZhaoJinming <zhaojinming@uniontech.com>
Subject: [PATCH] crypto: omap-aes - fix NULL pointer dereference in omap_aes_remove()
Date: Fri, 16 Oct 2026 16:30:04 +0800	[thread overview]
Message-ID: <20261016-omap-aes-remove-null-deref-v1-1-195d36295ed4@uniontech.com> (raw)

omap_aes_remove() unconditionally dereferences dd->pdata->aead_algs_info,
but only omap_aes_pdata_omap4 initializes that field:

	static const struct omap_aes_pdata omap_aes_pdata_omap2 = {
		.algs_info	= omap_aes_algs_info_ecb_cbc,
		...
	};

	static const struct omap_aes_pdata omap_aes_pdata_omap3 = {
		.algs_info	= omap_aes_algs_info_ecb_cbc_ctr,
		...
	};

	static const struct omap_aes_pdata omap_aes_pdata_omap4 = {
		...
		.aead_algs_info	= &omap_aes_aead_info,
		...
	};

For omap2 and omap3 the field stays NULL, so on those SoCs unbinding
the bound device (e.g. via sysfs unbind) or unloading the module (rmmod)
dereferences a NULL pointer:

	crypto_engine_unregister_aeads(dd->pdata->aead_algs_info->algs_list,
				       dd->pdata->aead_algs_info->registered);
	dd->pdata->aead_algs_info->registered = 0;

This is a hard crash, reachable from the teardown path only; probe
errors do not get here.  The asymmetry dates back to the commit that
introduced GCM support, which guarded the registration of the AEAD
algorithms but not their unregistration.  The registration path in
omap_aes_probe() already guards the same access with
"if (dd->pdata->aead_algs_info && ...)", so add the matching check to
the remove path.

Fixes: ad18cc9d0f91 ("crypto: omap-aes - Add support for GCM mode")
Cc: stable@vger.kernel.org
Signed-off-by: ZhaoJinming <zhaojinming@uniontech.com>
---
 drivers/crypto/omap-aes.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/crypto/omap-aes.c b/drivers/crypto/omap-aes.c
index d40074e5a142..8a932451ccf9 100644
--- a/drivers/crypto/omap-aes.c
+++ b/drivers/crypto/omap-aes.c
@@ -1199,9 +1199,11 @@ static void omap_aes_remove(struct platform_device *pdev)
 
 	omap_aes_unregister_algs(dd->pdata);
 
-	crypto_engine_unregister_aeads(dd->pdata->aead_algs_info->algs_list,
-				       dd->pdata->aead_algs_info->registered);
-	dd->pdata->aead_algs_info->registered = 0;
+	if (dd->pdata->aead_algs_info) {
+		crypto_engine_unregister_aeads(dd->pdata->aead_algs_info->algs_list,
+					       dd->pdata->aead_algs_info->registered);
+		dd->pdata->aead_algs_info->registered = 0;
+	}
 
 	crypto_engine_exit(dd->engine);
 

---
base-commit: 2f2f7eeef8b0a1a9b9ca998231419873ccae8d4e
change-id: 20261016-omap-aes-remove-null-deref-a3444b7bb17d

Best regards,
--  
ZhaoJinming <zhaojinming@uniontech.com>


             reply	other threads:[~2026-10-16  8:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-16  8:30 ZhaoJinming [this message]
2026-11-06 11:27 ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261016-omap-aes-remove-null-deref-v1-1-195d36295ed4@uniontech.com \
    --to=zhaojinming@uniontech.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=lokeshvutla@ti.com \
    --cc=stable@vger.kernel.org \
    --cc=t-kristo@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®