Skip to contentSkip to conversation

CVE-2023-52605: ACPI: extlog: fix NULL pointer dereference check

DISCUSSION Greg Kroah-Hartman 5 participants 6 messages Mar 6, 2024 – Mar 18, 2024 ACPI

lore
Share & tools
lore
#0 lore raw

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour. The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]

    |
    |  306 |         ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
    |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
    |      |                                                  |
    |      |                                                  (1) pointer ‘extlog_l1_addr’ is dereferenced here
    |  307 |         if (extlog_l1_addr)
    |      |            ~
    |      |            |
    |      |            (2) pointer ‘extlog_l1_addr’ is checked for NULL here but it was already dereferenced at (1)
    |

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

Affected and fixed versions
===========================

	Fixed in 4.19.307 with commit b7b33627be06
	Fixed in 5.4.269 with commit d2049af7ddbc
	Fixed in 5.10.210 with commit b17a71435e7e
	Fixed in 5.15.149 with commit 5457b0cbaa02
	Fixed in 6.1.77 with commit 33650372e3ea
	Fixed in 6.6.16 with commit f066171de33d
	Fixed in 6.7.4 with commit 77846571b3ba
	Fixed in 6.8-rc1 with commit 72d9b9747e78

Please see https://www.kernel.org or a full list of currently supported kernel versions by the kernel community.

Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at

	https://cve.org/CVERecord/?id=CVE-2023-52605

will be updated if fixes are backported, please check that for the most up to date information about this issue.

Affected files
==============

The file(s) affected by this issue are:
drivers/acpi/acpi_extlog.c

Mitigation
==========

The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits:

	https://git.kernel.org/stable/c/b7b33627be0626b16ca321b982d6a2261ef7f703
	https://git.kernel.org/stable/c/d2049af7ddbc361702c3e1f09bd6c5e9488454ca
	https://git.kernel.org/stable/c/b17a71435e7e153e949df018244a98b4ede04069
	https://git.kernel.org/stable/c/5457b0cbaa0238fc56b855c4ef2c0b9cc9c559ab
	https://git.kernel.org/stable/c/33650372e3ead97c5ab3b84d9ad97737bc5e00c0
	https://git.kernel.org/stable/c/f066171de33d71ff0f7c46bd17636a5a26db3fb6
	https://git.kernel.org/stable/c/77846571b3ba6a6125a20ad109bb8514ba884cf9
	https://git.kernel.org/stable/c/72d9b9747e78979510e9aafdd32eb99c7aa30dd1
#1 lore raw

(Added author/maintainer to Cc)

Quoted 23 lines · Greg Kroah-Hartman

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour. The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]

     |
     |  306 |         ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
     |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
     |      |                                                  |
     |      |                                                  (1) pointer ‘extlog_l1_addr’ is dereferenced here
     |  307 |         if (extlog_l1_addr)
     |      |            ~
     |      |            |
     |      |            (2) pointer ‘extlog_l1_addr’ is checked for NULL here but it was already dereferenced at (1)
     |
Quoted 3 lines

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

This code is in an __exit function:

drivers/acpi/acpi_extlog.c +3 -2
index e120a96e1eaee..193147769146e 100644
@@ -303,9 +303,10 @@ err:
 static void __exit extlog_exit(void)
 {
 	mce_unregister_decode_chain(&extlog_mce_dec);
-	((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-	if (extlog_l1_addr)
+	if (extlog_l1_addr) {
+		((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
 		acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+	}
 	if (elog_addr)
 		acpi_os_unmap_iomem(elog_addr, elog_size);
 	release_mem_region(elog_base, elog_size);

This can only run when you unload a module, which is a privileged operation (restricted to CAP_SYS_MODULE).

Moreover, extlog_l1_addr is only ever assigned in the corresponding module init function, and it looks like it will never be NULL if the module was loaded successfully, at least on a recent mainline kernel.

Since the module exit won't be called unless module init succeeded, I don't see a way to trigger this bug. Is this a vulnerability?

It might be better to just delete the NULL check altogether.

As usual, I could be wrong...

Vegard

#2 lore raw
Quoted 55 lines · Vegard Nossum

(Added author/maintainer to Cc)

Quoted 23 lines · Greg Kroah-Hartman

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour.  The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]

     |
     |  306 |         ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
     |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
     |      |                                                  |
     |      |                                                  (1) pointer ‘extlog_l1_addr’ is dereferenced here
     |  307 |         if (extlog_l1_addr)
     |      |            ~
     |      |            |
     |      |            (2) pointer ‘extlog_l1_addr’ is checked for NULL here but it was already dereferenced at (1)
     |
Quoted 3 lines

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

This code is in an __exit function:

drivers/acpi/acpi_extlog.c +3 -2
index e120a96e1eaee..193147769146e 100644
@@ -303,9 +303,10 @@ err:
  static void __exit extlog_exit(void)
  {
      mce_unregister_decode_chain(&extlog_mce_dec);
-    ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-    if (extlog_l1_addr)
+    if (extlog_l1_addr) {
+        ((struct extlog_l1_head *)extlog_l1_addr)->flags &= 
 ~FLAG_OS_OPTIN;
          acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+    }
      if (elog_addr)
          acpi_os_unmap_iomem(elog_addr, elog_size);

     release_mem_region(elog_base, elog_size);

This can only run when you unload a module, which is a privileged operation (restricted to CAP_SYS_MODULE).

Quoted 7 lines

Moreover, extlog_l1_addr is only ever assigned in the corresponding module init function, and it looks like it will never be NULL if the module was loaded successfully, at least on a recent mainline kernel.

Since the module exit won't be called unless module init succeeded, I don't see a way to trigger this bug. Is this a vulnerability?

This is certainly not a CVE.

Quoted 4 lines

It might be better to just delete the NULL check altogether.

As usual, I could be wrong...

When I made this code change I thought the same thing: Perhaps it's better to remove the NULL check given the status of the code. I assumed that the check was there as a failsafe on unload.

P.

Quoted 3 lines

Vegard

#3 lore raw
Quoted 71 lines · Prarit Bhargava
Quoted 60 lines · Vegard Nossum

(Added author/maintainer to Cc)

Quoted 25 lines · Greg Kroah-Hartman

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour.  The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
     |
     |  306 |         ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;

     |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
     |      |                                                  |
     |      |                                                  (1)
pointer ‘extlog_l1_addr’ is dereferenced here
     |  307 |         if (extlog_l1_addr)
     |      |            ~
     |      |            |
     |      |            (2) pointer ‘extlog_l1_addr’ is checked for
Quoted 6 lines

NULL here but it was already dereferenced at (1)
     |

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

This code is in an __exit function:

drivers/acpi/acpi_extlog.c +3 -2
index e120a96e1eaee..193147769146e 100644
@@ -303,9 +303,10 @@ err:
  static void __exit extlog_exit(void)
  {
      mce_unregister_decode_chain(&extlog_mce_dec);
-    ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-    if (extlog_l1_addr)
+    if (extlog_l1_addr) {
+        ((struct extlog_l1_head *)extlog_l1_addr)->flags &=
 ~FLAG_OS_OPTIN;
          acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+    }
      if (elog_addr)
          acpi_os_unmap_iomem(elog_addr, elog_size);

     release_mem_region(elog_base, elog_size);

This can only run when you unload a module, which is a privileged operation (restricted to CAP_SYS_MODULE).

Quoted 7 lines

Moreover, extlog_l1_addr is only ever assigned in the corresponding module init function, and it looks like it will never be NULL if the module was loaded successfully, at least on a recent mainline kernel.

Since the module exit won't be called unless module init succeeded, I don't see a way to trigger this bug. Is this a vulnerability?

This is certainly not a CVE.

Quoted 8 lines
Quoted 4 lines

It might be better to just delete the NULL check altogether.

As usual, I could be wrong...

When I made this code change I thought the same thing: Perhaps it's better to remove the NULL check given the status of the code. I assumed that the check was there as a failsafe on unload.

If Rafael agrees with you both, I'd be happy to revoke its CVE status.

Signature · 1 line
Lee Jones [李琼斯]
#4 lore raw
Quoted 70 lines · Lee Jones
Quoted 68 lines · Prarit Bhargava
Quoted 58 lines · Vegard Nossum

(Added author/maintainer to Cc)

Quoted 25 lines · Greg Kroah-Hartman

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour.  The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
     |
     |  306 |         ((struct extlog_l1_head
*)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;

      |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
      |      |                                                  |
      |      |                                                  (1)
pointer ‘extlog_l1_addr’ is dereferenced here
      |  307 |         if (extlog_l1_addr)
      |      |            ~
      |      |            |
      |      |            (2) pointer ‘extlog_l1_addr’ is checked for
Quoted 6 lines

NULL here but it was already dereferenced at (1)
     |

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

This code is in an __exit function:

drivers/acpi/acpi_extlog.c +3 -2
index e120a96e1eaee..193147769146e 100644
@@ -303,9 +303,10 @@ err:
   static void __exit extlog_exit(void)
   {
       mce_unregister_decode_chain(&extlog_mce_dec);
-    ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-    if (extlog_l1_addr)
+    if (extlog_l1_addr) {
+        ((struct extlog_l1_head *)extlog_l1_addr)->flags &=
 ~FLAG_OS_OPTIN;
           acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+    }
       if (elog_addr)
           acpi_os_unmap_iomem(elog_addr, elog_size);
       release_mem_region(elog_base, elog_size);

This can only run when you unload a module, which is a privileged operation (restricted to CAP_SYS_MODULE).

Quoted 7 lines

Moreover, extlog_l1_addr is only ever assigned in the corresponding module init function, and it looks like it will never be NULL if the module was loaded successfully, at least on a recent mainline kernel.

Since the module exit won't be called unless module init succeeded, I don't see a way to trigger this bug. Is this a vulnerability?

This is certainly not a CVE.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

It might be better to just delete the NULL check altogether.

As usual, I could be wrong...

When I made this code change I thought the same thing: Perhaps it's better to remove the NULL check given the status of the code. I assumed that the check was there as a failsafe on unload.

If Rafael agrees with you both, I'd be happy to revoke its CVE status.

I do agree with the analysis above, sorry for the delay.

Thanks,

Rafael

#5 lore raw
Quoted 73 lines · Rafael J
Quoted 72 lines · Lee Jones
Quoted 70 lines · Prarit Bhargava
Quoted 58 lines · Vegard Nossum

(Added author/maintainer to Cc)

Quoted 25 lines · Greg Kroah-Hartman

Description
===========

In the Linux kernel, the following vulnerability has been resolved:

ACPI: extlog: fix NULL pointer dereference check

The gcc plugin -fanalyzer [1] tries to detect various patterns of incorrect behaviour.  The tool reports:

drivers/acpi/acpi_extlog.c: In function ‘extlog_exit’:
drivers/acpi/acpi_extlog.c:307:12: warning: check of ‘extlog_l1_addr’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check]
     |
     |  306 |         ((struct extlog_l1_head
*)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;

      |      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~
      |      |                                                  |
      |      |                                                  (1)
pointer ‘extlog_l1_addr’ is dereferenced here
      |  307 |         if (extlog_l1_addr)
      |      |            ~
      |      |            |
      |      |            (2) pointer ‘extlog_l1_addr’ is checked for
Quoted 6 lines

NULL here but it was already dereferenced at (1)
     |

Fix the NULL pointer dereference check in extlog_exit().

The Linux kernel CVE team has assigned CVE-2023-52605 to this issue.

This code is in an __exit function:

drivers/acpi/acpi_extlog.c +3 -2
index e120a96e1eaee..193147769146e 100644
@@ -303,9 +303,10 @@ err:
   static void __exit extlog_exit(void)
   {
       mce_unregister_decode_chain(&extlog_mce_dec);
-    ((struct extlog_l1_head *)extlog_l1_addr)->flags &= ~FLAG_OS_OPTIN;
-    if (extlog_l1_addr)
+    if (extlog_l1_addr) {
+        ((struct extlog_l1_head *)extlog_l1_addr)->flags &=
 ~FLAG_OS_OPTIN;
           acpi_os_unmap_iomem(extlog_l1_addr, l1_size);
+    }
       if (elog_addr)
           acpi_os_unmap_iomem(elog_addr, elog_size);
       release_mem_region(elog_base, elog_size);

This can only run when you unload a module, which is a privileged operation (restricted to CAP_SYS_MODULE).

Quoted 7 lines

Moreover, extlog_l1_addr is only ever assigned in the corresponding module init function, and it looks like it will never be NULL if the module was loaded successfully, at least on a recent mainline kernel.

Since the module exit won't be called unless module init succeeded, I don't see a way to trigger this bug. Is this a vulnerability?

This is certainly not a CVE.

Quoted 2 lines

It might be better to just delete the NULL check altogether.

Quoted 8 lines
Quoted 6 lines
Quoted 5 lines
Quoted 2 lines

As usual, I could be wrong...

When I made this code change I thought the same thing: Perhaps it's better to remove the NULL check given the status of the code. I assumed that the check was there as a failsafe on unload.

If Rafael agrees with you both, I'd be happy to revoke its CVE status.

I do agree with the analysis above, sorry for the delay.

No problem Rafael.

Okay, CVE-2023-52605 has now been rejected.

https://lore.kernel.org/all/[email protected]/

Signature · 1 line
Lee Jones [李琼斯]