Patch "ACPI: battery: Fix missing NUL-termination with large strings" has been added to the 4.19-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    ACPI: battery: Fix missing NUL-termination with large strings

to the 4.19-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     acpi-battery-fix-missing-nul-termination-with-large-.patch
and it can be found in the queue-4.19 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 1b1d2f92956b35ab52cad14f07d8383bfca4806a
Author: Armin Wolf <W_Armin@xxxxxx>
Date:   Sat Jan 14 09:50:50 2023 +0100

    ACPI: battery: Fix missing NUL-termination with large strings
    
    [ Upstream commit f2ac14b5f197e4a2dec51e5ceaa56682ff1592bc ]
    
    When encountering a string bigger than the destination buffer (32 bytes),
    the string is not properly NUL-terminated, causing buffer overreads later.
    
    This for example happens on the Inspiron 3505, where the battery
    model name is larger than 32 bytes, which leads to sysfs showing
    the model name together with the serial number string (which is
    NUL-terminated and thus prevents worse).
    
    Fix this by using strscpy() which ensures that the result is
    always NUL-terminated.
    
    Fixes: 106449e870b3 ("ACPI: Battery: Allow extract string from integer")
    Signed-off-by: Armin Wolf <W_Armin@xxxxxx>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c
index c0c533206e02d..88f4040d6c1f2 100644
--- a/drivers/acpi/battery.c
+++ b/drivers/acpi/battery.c
@@ -478,7 +478,7 @@ static int extract_package(struct acpi_battery *battery,
 			u8 *ptr = (u8 *)battery + offsets[i].offset;
 			if (element->type == ACPI_TYPE_STRING ||
 			    element->type == ACPI_TYPE_BUFFER)
-				strncpy(ptr, element->string.pointer, 32);
+				strscpy(ptr, element->string.pointer, 32);
 			else if (element->type == ACPI_TYPE_INTEGER) {
 				strncpy(ptr, (u8 *)&element->integer.value,
 					sizeof(u64));



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux