From patchwork Sat Jan 14 08:50:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 43716 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp194377wrn; Sat, 14 Jan 2023 00:54:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDnQlw754lvMWWN4uIcroeyOeFnqvB5Nhzer7NznqAvjIPsOZZ0I+uhQ/PnaTJOlUlBo9C X-Received: by 2002:a17:90a:202:b0:226:fa8c:e50a with SMTP id c2-20020a17090a020200b00226fa8ce50amr14510845pjc.35.1673686457561; Sat, 14 Jan 2023 00:54:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673686457; cv=none; d=google.com; s=arc-20160816; b=io3+HAbDpV/IhUPLVfk13kR03wp39ZW7xaD+c7wkSVGsN1mZmVbeMZR0u+5uxzpgbB VN9cwQ7N01dXQnw+n6flqLAz3xi07xuzYjgNXSDb2UTsd1px7JGIUfhLmRohRxLc/ghc yU4a+yzWwN0mV6KQCutIX8SodqANhFlObvsSPxnDpZQO/8woz72rqK9Q+1SwL9UA/RR+ cqcIXxJJSnQplg5BML3iwL2IPT58jmaXItSwblk2tXY+jvtAamP2Op+qd6FtZXQYaycD XnFFOrHAORk3Thvsliqlarkqx58SsXKTRSArfunHZtyOlRmEm3H+an6irnveMWh+mE8h wF6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iYrGvVtfb/qBpLe5Rz87ApLKZAby815kSImkqii6gKM=; b=kdATIHmFID1ZQInYcdVtZ+B6qu0mYTseKg6FyPiDgLli2oJp7yYhsOG5TFznoC+9HP 9aK7OZLUY39v+5MpoklmfgeBUdS3r+He5lVhqOiYP0pwdQk5LrvaQvx1zprtfdBdrfAC cizEZ+vM0vqKGhAHu8U8sQV5dyFO+LzTru9rhqNGtgped4ELV1chdGXBbt+PTJv2juiI CbN5aLctecRd+Iy31fzyrxbgTd/bblqQ0un0CT5oDeH6n5FxJlKoY3CEwdVVXisq3CB+ sToZ7iXmCrrPxFUrUkoyE5RsdNftAbQsf5WaURIrrq91Tqwhphoe4rT97ra3+hUJRB0g lxdQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="jl/+AWUS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v69-20020a638948000000b0047895cb1543si7021554pgd.874.2023.01.14.00.54.05; Sat, 14 Jan 2023 00:54:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b="jl/+AWUS"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229627AbjANIvR (ORCPT + 99 others); Sat, 14 Jan 2023 03:51:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229815AbjANIvG (ORCPT ); Sat, 14 Jan 2023 03:51:06 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.15.15]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 895856E84; Sat, 14 Jan 2023 00:51:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673686257; bh=ecSPvHCNjAvVeCQzbDjFrZEbtxhwySp2CjVRnX3yiRY=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=jl/+AWUSgF3KF0rnllZ9T2SkWBIYgsomNDbLkujsOkL8IOaVDqeIATWN1TdUVgQNY gGamUDmP/FJSQa2xo1lNYRv2CmvVYhCJVErVkXwD2S+p/1k7UPbuto207VflvxFk5e rIr/2XaEt6vi5gTfEk7XohDJC+0n1JWULXDPSEzeCKYGTkfI5vcZzk+F1E/kLp8eGh pgMpAXE+J512DtY9yKIJD0/BwyYgiTZE81qnp163xI5+KSkM0mV0dTmWPh8HIyxksF hkXk5D9GUzMFq1OTYCwkdmM1MoSjzgS7TIo+uqvjWgvwapGH8lAGeL99EuYoevwpMi Lj1KxWhK5nBlw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx004 [212.227.17.190]) with ESMTPSA (Nemesis) id 1MIMbO-1pUtS03vpE-00EJoI; Sat, 14 Jan 2023 09:50:57 +0100 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/4] ACPI: battery: Fix missing NUL-termination with large strings Date: Sat, 14 Jan 2023 09:50:50 +0100 Message-Id: <20230114085053.72059-2-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230114085053.72059-1-W_Armin@gmx.de> References: <20230114085053.72059-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:Wnx0zZfkWOTNqc0y565JEVWCMcUdeD35UbCLS0wpCTRKXW7GKsx 3WiNFgzjgxLl18K3aaWZXQb7Lg0Dm6qGydvsVav90ct5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nLV 2S3S4n09x93bN5jKX0SJtJqwMyHd9a5F+JNzNx5unS9GX+Cm6VpTIfpk8REYrbhHw7vGnO1Vs nZCLtvg7XCPnxxLYxnU2OYVJs+E= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754987451166662779?= X-GMAIL-MSGID: =?utf-8?q?1754987451166662779?= 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. Signed-off-by: Armin Wolf --- drivers/acpi/battery.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) -- 2.30.2 diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index f4badcdde76e..fb64bd217d82 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -440,7 +440,7 @@ static int extract_package(struct acpi_battery *battery, 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)); From patchwork Sat Jan 14 08:50:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 43717 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp194438wrn; Sat, 14 Jan 2023 00:54:29 -0800 (PST) X-Google-Smtp-Source: AMrXdXs28Wo06hP5X+bELU5siDjhrlUY7jQlENJbeCdmXaJWSsADuBuvOwUUGmBRYljoOQSJ58K8 X-Received: by 2002:a17:902:a9c8:b0:194:4a0e:3024 with SMTP id b8-20020a170902a9c800b001944a0e3024mr12855165plr.62.1673686469248; Sat, 14 Jan 2023 00:54:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673686469; cv=none; d=google.com; s=arc-20160816; b=bmLvpOGidq8KcwLKNDHetmc/JPv109FvLQvkdHSc4LM2cNLEOxsN2DFYoH5o53jxYy lWjZR8kLvWGAXOdi8IO1W+rtm8gqICzpsiMK2IlzWISWD79EPzkYP8vqjgsGyUjZoatQ St7VZc+q01XvjS2mbG1lTuQ/liYuFj1BPC8fQX9ZNGLwstsZy2n1li+LjEykq20aiP8f IWUk10IPy1eMvu1+/lt80oAMUDyBgtUsL/+Pw/i/lqQhbekpeFhXE1DtuUEKst/gDVkZ 8esSZrlrZiXtgktG277ylV6+dmq1qSj8FbZwNtn+GUaKOuFDPGFVbOOo1OSKS2Srali2 om6g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=+cNo969/y6+26mQU0yOkafJ8dt7VLhXVpmrhvlqnKWA=; b=XcvqGZyttIo4241+z5KUr8BFt9dMV7qZOBBmkfaLO7roft8d/3GqQSTBEWmEfc9sxR cYqM0yo0SeVTYc0ZnLl1ffyd1hcoJWnV4HwXlnKJa86whoS0S6GzbPYXinr5R8cUBijR 3iPx4eAEu29s3blP9zlQBxCi+Gu8FK0uWDmdvg8To+U3wYWC4gVk0an6Pg5cnMtCGDY4 MotQEZHcoDFsdKPFvkftPgtvCzrUBaoQuYlBVt7rAmpqcD7jVyHnAdrvWC/KCmx3HiQP /TAeiGFIiC3B6a4u3iFGJ19hDVvpQD6r9ppFKzi4c+fCHBim7fRf43M85H2zAjfisRQG L9/Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=ugaENJWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b2-20020a170902d50200b00192721d6a97si25314714plg.499.2023.01.14.00.54.17; Sat, 14 Jan 2023 00:54:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=ugaENJWe; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229894AbjANIvZ (ORCPT + 99 others); Sat, 14 Jan 2023 03:51:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229751AbjANIvH (ORCPT ); Sat, 14 Jan 2023 03:51:07 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.22]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0AC215B99; Sat, 14 Jan 2023 00:51:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673686258; bh=jB33Q3jeI0y5s9Ce2m9M9FDF30UYlvKOmlqfrMJD11U=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=ugaENJWeI55eqyyb5bGIF1NEu5kzlI89qmpp2KE2QC+lKlPvEezcMeLvQRj7NOkl7 lxN/YZyg7EPhKnzVg58fjuCxiNmamVd8v71NuczHfHGNt+RnC/2/Qlr8ctC07dLBj0 +UoECYUpv6BtOu4dhaWOhAEhS7AIv3iixJUqGvu2nBcRgu1o1NLLRqG92QyVsiFFcR hzaSKxUCAnDUW4PXKSs45e9ZZrWLrV+ZscZUZcj6R1ApdinTAi1JSY4ZfWLEVlQrjI cNzQsQQVm6vni5nKNfb7pkV0JidnGLTOwdA1OMszI+khx8LNfPwCz/WS3PGdhkEdAA OFJDuOdj83uQw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MnJhU-1orPq22NYS-00jIKm; Sat, 14 Jan 2023 09:50:58 +0100 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] ACPI: battery: Fix buffer overread if not NUL-terminated Date: Sat, 14 Jan 2023 09:50:51 +0100 Message-Id: <20230114085053.72059-3-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230114085053.72059-1-W_Armin@gmx.de> References: <20230114085053.72059-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:z5GgtgT7CSW+fcGI445TpQI8PlZHp7xc332KAN0bgoMYytypbq2 1UkqHJbkKuy4aDiYLowSkXz3+/FcoXqcfR8Olxu+tiaeMW/qSMGtfXNUA8Bq10urn80MU4f GGm7zFMPLOZKOF2HIcP6ecnoCTe1+yR43IQ1f/ot3IRmSRYYYkZhW8CFm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89vCvJXkAC4= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754987463159179903?= X-GMAIL-MSGID: =?utf-8?q?1754987463159179903?= If the buffer containing string data is not NUL-terminated (which is perfectly legal according to the ACPI specification), the acpi battery driver might not honor its length. Fix this by limiting the amount of data to be copied to the buffer length while also using strscpy() to make sure that the resulting string is always NUL-terminated. Also use '\0' instead of a plain 0. Signed-off-by: Armin Wolf --- drivers/acpi/battery.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) -- 2.30.2 diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index fb64bd217d82..9f6daa9f2010 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -438,15 +438,24 @@ static int extract_package(struct acpi_battery *battery, if (offsets[i].mode) { u8 *ptr = (u8 *)battery + offsets[i].offset; - if (element->type == ACPI_TYPE_STRING || - element->type == ACPI_TYPE_BUFFER) + switch (element->type) { + case ACPI_TYPE_STRING: strscpy(ptr, element->string.pointer, 32); - else if (element->type == ACPI_TYPE_INTEGER) { - strncpy(ptr, (u8 *)&element->integer.value, - sizeof(u64)); + + break; + case ACPI_TYPE_BUFFER: + strscpy(ptr, element->buffer.pointer, + min_t(u32, element->buffer.length + 1, 32)); + + break; + case ACPI_TYPE_INTEGER: + strncpy(ptr, (u8 *)&element->integer.value, sizeof(u64)); ptr[sizeof(u64)] = 0; - } else - *ptr = 0; /* don't have value */ + + break; + default: + *ptr = '\0'; /* don't have value */ + } } else { int *x = (int *)((u8 *)battery + offsets[i].offset); *x = (element->type == ACPI_TYPE_INTEGER) ? From patchwork Sat Jan 14 08:50:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 43719 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp194529wrn; Sat, 14 Jan 2023 00:54:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXvaWD3HSi8wCYfMrGXwtP2d3z60jc4dRefwsjOqMCFKOFkD1Th+ra9hwb0i8m+PfByKCjZq X-Received: by 2002:a17:902:bd09:b0:193:3716:78cf with SMTP id p9-20020a170902bd0900b00193371678cfmr18946754pls.65.1673686488617; Sat, 14 Jan 2023 00:54:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673686488; cv=none; d=google.com; s=arc-20160816; b=ES1RYEIodFa1biQQ8sZpYo9suNlxz++R1MOFGmM/Qd6C1x7zA8ECpCSMGhR3nNH2sM l8Mu0h68lhx1yZ5gcF7fvigubnTGG33Ad2CRaBRKyTgRbRTKdtYlp7hPCTIemd+ZQaTU uNdFRMPDMPoEPSEwuhKhIPbiiroMu+s6qc/P9csJ1gylxjXNxcjvucfW0Ya4dHrQwiuF GDbncU7JMT3UQXfpzRs+PIL/BEx8iqCeG0jTE4MC1Cb7MCH6oNznFImPBmpZ3rsUfTry 4VHH0zqOSsTpqjoP/RUOd5T6Aaa/J1FGMsMDKr1VoOutTRnYxwwrogUqZkgN/STeu/E7 Od7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=1ZPzE/x/V9gRI1TogFetowagFJHEvIpVuCJrtMlLBXM=; b=IgbN4karaZqP6vZMgxDi5RRUf3K2o68qAfa1E9V245UspIaxCtJD4jnysTIU6LYo59 FW1Kbxvk4A62jM6M0Mdi2QKTXfkVAn7hWpFT2o5g8MjhrF8aE5N6PPapT4WqatyZf+zF hGthZQPMZE5GqH8qNkKird++ZPTwxaR7ihVWQqL/82KdDRoEtv5qhYol2dtBkSoPXtHb 3IWMuWypwmaaF2aTNp2gWOeNSYw/pvkvODX3YR8IA1Y5Rd9+vNzmT/LEfPQaAQ90/L0Y 2DeNEt4mgLU/fPJA8MV73n9PsZPyKhi8f3lgY2AWohHFvqOnjedNkGnHuMYwtKNGwTKR LnAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=pLvDoi+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020a634d46000000b004a32a462c19si22527664pgl.843.2023.01.14.00.54.36; Sat, 14 Jan 2023 00:54:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=pLvDoi+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbjANIvg (ORCPT + 99 others); Sat, 14 Jan 2023 03:51:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41440 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229845AbjANIvH (ORCPT ); Sat, 14 Jan 2023 03:51:07 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 789AD5BA6; Sat, 14 Jan 2023 00:51:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673686260; bh=ZRXDOHGn9yZu57/DPz1iMB9OlkHhVNY+RiI8eWQZy7Y=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=pLvDoi+UkLmHCYXsNyLYXYV53IObWoyJZafOBDM7/xWU9N2OdOERE+YWsiX9kr8QE 21sD5GeM4fvtVk6H6wp4rQWv/rJhUhl9RsSVar35f6QYxod2K3jsgDJCTLQo6hAQrp G/U58GQ/193DUoulcnHyjjsIcWiqInNdAKuZ2dG061FCKGu9//lzxnRkPCrGoC1/w6 L9Xy+Usbspusw79LnqU1iX8jN/Gu5IsepspIfmflkTIxSKr3d3lJ7d7H4OoO95znmd IYef5GOS8GZSdeJCd8FnWxUvZgxkYAlJmF91wH23ZjvhEvC60LPHv6baZVILvbnXSt taDtekps0eb7w== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MTzb8-1p7AIr3qJG-00R4ov; Sat, 14 Jan 2023 09:51:00 +0100 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/4] ACPI: battery: Replace strncpy() with strscpy() Date: Sat, 14 Jan 2023 09:50:52 +0100 Message-Id: <20230114085053.72059-4-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230114085053.72059-1-W_Armin@gmx.de> References: <20230114085053.72059-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-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o7n0QvNLUrVeY354GeHtakIn89w9Yy CnmJyQg6EHpEQIrm8sOuvacuHP5uu5YPMHs05GI+pL3uN9p9xvwlI4dxKo1Qbrl/2TMxRCkZ5 qIXa7C54LuMA/pBLa03jlKCAX2Lmfg4tZUKJkXaDOj/x+7lc55qELSZLy2QpqTa72kATGk8hH JEsOV7fJW2zrZoFZkISpQqkHTak= X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754987483756859249?= X-GMAIL-MSGID: =?utf-8?q?1754987483756859249?= Currently, strncpy() and manual NUL-termination is used when copying integers. Switch to strscpy() which takes care of NUL-terminating the result. Signed-off-by: Armin Wolf --- drivers/acpi/battery.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) -- 2.30.2 diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index 9f6daa9f2010..b39b84b8f3ae 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -449,8 +449,7 @@ static int extract_package(struct acpi_battery *battery, break; case ACPI_TYPE_INTEGER: - strncpy(ptr, (u8 *)&element->integer.value, sizeof(u64)); - ptr[sizeof(u64)] = 0; + strscpy(ptr, (u8 *)&element->integer.value, sizeof(u64) + 1); break; default: From patchwork Sat Jan 14 08:50:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Armin Wolf X-Patchwork-Id: 43718 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp194450wrn; Sat, 14 Jan 2023 00:54:32 -0800 (PST) X-Google-Smtp-Source: AMrXdXuQCzsFmUfVoH8YdwDA/ChE3QnX4I9oY1gPorlqHjJ59zWWJ8Xlr7ks3uaeP1ow2fvXMKg9 X-Received: by 2002:a17:902:ea94:b0:193:c79:657a with SMTP id x20-20020a170902ea9400b001930c79657amr28352250plb.5.1673686472657; Sat, 14 Jan 2023 00:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673686472; cv=none; d=google.com; s=arc-20160816; b=rGUQhhvhCAMMZflgxy0wogws+htoVTznjzWV+sRRkudyf5//ETuGWwwwH75DmDH4vR OGfRftETPFvxk6JSk57ejPmaYDzpMjf72sbvSbBzKRsywke6F9+VxPcLRNJDYIBFVSL8 tYdlfYAfcUogLfWtLf7dhkw8plb+S0KODT346AyyQEcY5bmftr3Fj1PMyLGykddG0mJc YGvkVM6iRauAO8W49vgOvAFewACi+l4tSF23KsKx9z7gOBjaBiW4JNB6OepvHPw6WlEy 89K4X/f21AA+H35LqujjM6m9HJn42B9gZkUAmkXY0SxejTfknT3dEt/C4CMD/j4bfhDw 327g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:ui-outboundreport:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=w8iQ3bu3LS6AbMt+hhzmswdAuzi2DwdQzJnVL9kgzp8=; b=vaGMGDAeIGdMAWNWD8GBW65rLPBWqC+FNPxlTFllZ3Gjrb5dujzH0rEBUVRx/MW1K0 c01lz3O7A8VFXXk1wTKZH787wKvc0qPwnJMSJgFAHAsqFkxuHEojrykih8tufoAm5k8c VslxhTnkXCQ57L0dg3WvaeSfFMTi/AI441YtXZNy6YYdjMaJsRVQxSv2t3OQDlMn8TbH pYFGCKhhYMrnH5meJOfWgjYxZiKasEK5g7iemk9yPglXwXJglbhqIVIY9DnRUXDWUO/m F3jmVeOPUydQUBo0n/bJemLEYZ5k2GlBVUixPF0ZwbjLOzVT468A2HNEzEyJB2QvMQWt UjXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=culIWb2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j8-20020a170903024800b0017a034f7246si22751463plh.560.2023.01.14.00.54.21; Sat, 14 Jan 2023 00:54:32 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gmx.de header.s=s31663417 header.b=culIWb2u; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gmx.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229909AbjANIvc (ORCPT + 99 others); Sat, 14 Jan 2023 03:51:32 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229752AbjANIvI (ORCPT ); Sat, 14 Jan 2023 03:51:08 -0500 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCC2F5B8C; Sat, 14 Jan 2023 00:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.de; s=s31663417; t=1673686261; bh=qDiU8VzRpc8nbJnYzYiamI1ZZHk6Ixfnz0knnvQyrtw=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date:In-Reply-To:References; b=culIWb2uze8BZDLoxLW3BOBsno2ppEyXLxjZck1m6j2ct080SjWu6y9zkAG7AEZxb JK++ri/ia8H7dSfJONvL4nHLs2irhTS8qzR0XESaeZpkjbcVawveS20dRrkAJGuTS3 dm4vXyrU2pt4v5wJJGvBtvj4rgzQxXNpRO+HiN9Erp2ROQB8jhwvDdNyYdMCA+6RGi Y0MgZMJZBlxlCpeXitRne1zJ6rwbp0ubQFx5NKKQgoAWMt2NYPnUccGcrfSB6/puGG P3Y/FF9gsiripXGkTVxQacAu90eemLhWaw6TluSaCEdmU5UHQDvfpsVxf9Rszx4348 7pTKrQHdJ8pkw== X-UI-Sender-Class: 724b4f7f-cbec-4199-ad4e-598c01a50d3a Received: from esprimo-mx.users.agdsn.de ([141.30.226.129]) by mail.gmx.net (mrgmx104 [212.227.17.168]) with ESMTPSA (Nemesis) id 1MG9g4-1pX5JJ0ZNU-00GXYi; Sat, 14 Jan 2023 09:51:01 +0100 From: Armin Wolf To: rafael@kernel.org, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/4] ACPI: battery: Increase maximum string length Date: Sat, 14 Jan 2023 09:50:53 +0100 Message-Id: <20230114085053.72059-5-W_Armin@gmx.de> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230114085053.72059-1-W_Armin@gmx.de> References: <20230114085053.72059-1-W_Armin@gmx.de> MIME-Version: 1.0 X-Provags-ID: V03:K1:zYDjh5yQ6xfg+VdyX+ZG78depAZcOfdAewOPFoaubCgLLSYJ6KF t80XIBjuMtxn08FpN+opH2TXsQ3ChX7tc2WGyZ3u+u6p5baMKjftlYaKZmHQ+qbGdUOb5cZ 5cE2VUwKRVOu4MvUN2TCyVuVgPfOlrIuM74gSrxUZlvJ5e3oXVdlZtgDt3YUjst0cyDbI6C epSCx8aO76ZQSVahx7hxQ== UI-OutboundReport: notjunk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NED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1754987466666499276?= X-GMAIL-MSGID: =?utf-8?q?1754987466666499276?= On the Dell Inspiron 3505, the battery model name is represented as a hex string containing seven numbers, causing it to be larger than the current maximum string length (32). Increase this length to 64 to avoid truncating the string in such cases. Also introduce a common define for the length. Signed-off-by: Armin Wolf --- drivers/acpi/battery.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) -- 2.30.2 diff --git a/drivers/acpi/battery.c b/drivers/acpi/battery.c index b39b84b8f3ae..9f4c31484adc 100644 --- a/drivers/acpi/battery.c +++ b/drivers/acpi/battery.c @@ -42,6 +42,8 @@ #define ACPI_BATTERY_STATE_CHARGING 0x2 #define ACPI_BATTERY_STATE_CRITICAL 0x4 +#define MAX_STRING_LENGTH 64 + MODULE_AUTHOR("Paul Diefenbaugh"); MODULE_AUTHOR("Alexey Starikovskiy "); MODULE_DESCRIPTION("ACPI Battery Driver"); @@ -118,10 +120,10 @@ struct acpi_battery { int capacity_granularity_1; int capacity_granularity_2; int alarm; - char model_number[32]; - char serial_number[32]; - char type[32]; - char oem_info[32]; + char model_number[MAX_STRING_LENGTH]; + char serial_number[MAX_STRING_LENGTH]; + char type[MAX_STRING_LENGTH]; + char oem_info[MAX_STRING_LENGTH]; int state; int power_unit; unsigned long flags; @@ -440,12 +442,12 @@ static int extract_package(struct acpi_battery *battery, switch (element->type) { case ACPI_TYPE_STRING: - strscpy(ptr, element->string.pointer, 32); + strscpy(ptr, element->string.pointer, MAX_STRING_LENGTH); break; case ACPI_TYPE_BUFFER: strscpy(ptr, element->buffer.pointer, - min_t(u32, element->buffer.length + 1, 32)); + min_t(u32, element->buffer.length + 1, MAX_STRING_LENGTH)); break; case ACPI_TYPE_INTEGER: