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

On Fri, Oct 16, 2026 at 04:30:04PM +0800, ZhaoJinming wrote:
> 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(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

      reply	other threads:[~2026-11-06 11:27 UTC|newest]

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

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=au25lCTnY1FmsPuT@gondor.apana.org.au \
    --to=herbert@gondor.apana.org.au \
    --cc=davem@davemloft.net \
    --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 \
    --cc=zhaojinming@uniontech.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®