From patchwork Mon Feb 22 05:10:47 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zhiyuan Dai X-Patchwork-Id: 12097901 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 80E2BC433E0 for ; Mon, 22 Feb 2021 05:11:00 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 9300D64E92 for ; Mon, 22 Feb 2021 05:10:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9300D64E92 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=phytium.com.cn Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id F32636B0071; Mon, 22 Feb 2021 00:10:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id EBB166B0072; Mon, 22 Feb 2021 00:10:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D5AF66B0073; Mon, 22 Feb 2021 00:10:54 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0161.hostedemail.com [216.40.44.161]) by kanga.kvack.org (Postfix) with ESMTP id BD23C6B0071 for ; Mon, 22 Feb 2021 00:10:54 -0500 (EST) Received: from smtpin05.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 778268248047 for ; Mon, 22 Feb 2021 05:10:54 +0000 (UTC) X-FDA: 77844729228.05.E218709 Received: from zg8tmty1ljiyny4xntqumjca.icoremail.net (zg8tmty1ljiyny4xntqumjca.icoremail.net [165.227.154.27]) by imf19.hostedemail.com (Postfix) with SMTP id 640FD90009E9 for ; Mon, 22 Feb 2021 05:10:50 +0000 (UTC) Received: from centos7u5.localdomain (unknown [202.43.158.76]) by c1app2 (Coremail) with SMTP id AgINCgCnrsLVPDNgmiIUAw--.49101S3; Mon, 22 Feb 2021 13:10:46 +0800 (CST) From: Zhiyuan Dai To: ryabinin.a.a@gmail.com, glider@google.com, andreyknvl@gmail.com, dvyukov@google.com, akpm@linux-foundation.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Zhiyuan Dai Subject: [PATCH] mm/kasan: switch from strlcpy to strscpy Date: Mon, 22 Feb 2021 13:10:47 +0800 Message-Id: <1613970647-23272-1-git-send-email-daizhiyuan@phytium.com.cn> X-Mailer: git-send-email 1.8.3.1 X-CM-TRANSID: AgINCgCnrsLVPDNgmiIUAw--.49101S3 X-Coremail-Antispam: 1UD129KBjvdXoW7Xr4rAFyDtw4UArW7Ww4Durg_yoWfWFgE9w n7tay7G395Xr9xZ3ZrK3yrJFyS93WFgr1kuFy5JF90ga1aqws0gF93J34akrW8XwsI9asI yrZ09r1rJw4a9jkaLaAFLSUrUUUUUb8apTn2vfkv8UJUUUU8Yxn0WfASr-VFAUDa7-sFnT 9fnUUIcSsGvfJTRUUUbcAFF20E14v26r4j6ryUM7CY07I20VC2zVCF04k26cxKx2IYs7xG 6rWj6s0DM7CIcVAFz4kK6r1j6r18M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48ve4kI8w A2z4x0Y4vE2Ix0cI8IcVAFwI0_Jr0_JF4l84ACjcxK6xIIjxv20xvEc7CjxVAFwI0_Gr0_ Cr1l84ACjcxK6I8E87Iv67AKxVWxJr0_GcWl84ACjcxK6I8E87Iv6xkF7I0E14v26F4UJV W0owAS0I0E0xvYzxvE52x082IY62kv0487Mc02F40EFcxC0VAKzVAqx4xG6I80ewAv7VC0 I7IYx2IY67AKxVWUGVWUXwAv7VC2z280aVAFwI0_Gr0_Cr1lOx8S6xCaFVCjc4AY6r1j6r 4UM4x0Y48IcxkI7VAKI48JM4x0x7Aq67IIx4CEVc8vx2IErcIFxwCY02Avz4vE14v_GrWl 42xK82IYc2Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJV WUGwC20s026x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAK I48JMIIF0xvE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r4j6F 4UMIIF0xvE42xK8VAvwI8IcIk0rVWrJr0_WFyUJwCI42IY6I8E87Iv67AKxVWUJVW8JwCI 42IY6I8E87Iv6xkF7I0E14v26r4j6r4UJbIYCTnIWIevJa73UjIFyTuYvjfUYPEfDUUUU X-Originating-IP: [202.43.158.76] X-CM-SenderInfo: hgdl6xpl1xt0o6sk53xlxphulrpou0/ X-Stat-Signature: ptnzmqrzuafjktkyu8diydwatszeofw3 X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 640FD90009E9 Received-SPF: none (phytium.com.cn>: No applicable sender policy available) receiver=imf19; identity=mailfrom; envelope-from=""; helo=zg8tmty1ljiyny4xntqumjca.icoremail.net; client-ip=165.227.154.27 X-HE-DKIM-Result: none/none X-HE-Tag: 1613970650-918741 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000103, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: strlcpy is marked as deprecated in Documentation/process/deprecated.rst, and there is no functional difference when the caller expects truncation (when not checking the return value). strscpy is relatively better as it also avoids scanning the whole source string. Signed-off-by: Zhiyuan Dai Acked-by: Alexander Potapenko Reviewed-by: Andrey Konovalov --- mm/kasan/report_generic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/kasan/report_generic.c b/mm/kasan/report_generic.c index 8a9c889..fc7f7ad 100644 --- a/mm/kasan/report_generic.c +++ b/mm/kasan/report_generic.c @@ -148,7 +148,7 @@ static bool __must_check tokenize_frame_descr(const char **frame_descr, } /* Copy token (+ 1 byte for '\0'). */ - strlcpy(token, *frame_descr, tok_len + 1); + strscpy(token, *frame_descr, tok_len + 1); } /* Advance frame_descr past separator. */