Received: by 2002:a05:6358:16cc:b0:ea:6187:17c9 with SMTP id r12csp797870rwl; Thu, 5 Jan 2023 04:52:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXuAeOrgq7W96pwZ47PZwBS69BtR/AuDN0AqOx+MnpicN/PWpcWj2Os4CvkTe2Aj2nD9AMWZ X-Received: by 2002:a17:906:8e91:b0:7c1:5248:4f3a with SMTP id ru17-20020a1709068e9100b007c152484f3amr40236445ejc.56.1672923127220; Thu, 05 Jan 2023 04:52:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672923127; cv=none; d=google.com; s=arc-20160816; b=JvpPlghx962lGBSU7D81wlup/VFcYf7arJmnALzW+FlhHTfaTQTCmUKXNoeoA1v+B7 V3OxwBZ5j0ps7J5uwOhO9THe9JQ2IoBzz30QRsZe2k4bU2Za6Za0I83HeZo8qTKI+6zY 6jB+DTfY6V2aw8/O+MxZbOhppaV841Yh4234IC+QqX7qH6BjIe1F3u8zSrZTXocSHmCT VsQHtQ/fRSVUotqz9JYIE1h5h7O6znr6dsKYmRiDJhjwu+ERhHqRATvgzEG1dKUSYf2y 5r8PluP8tUvQkbzn4cutkRpk3lRsaRhHgXoZfh49iS/Uy5h2x7zsTwQf8Xbg0dmW4LSL pCjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:mime-version:message-id:date; bh=kEyRcWCb9KFEBzGCrjjrvF45cpAGvOemNEZixEUTWkk=; b=MT8aJndsbfaeCULCTzg4X54panrRZJZuZDuTlsFIEWS5BaNpke1z2vX7TohBSMujyJ n9O+5jwD4OVdpOJU2jpIT1bTfk+cA8inJOeRa55XaQ4NhUlQk+H0qw6xyuFxxiT0+Pmo 9I0qM5DF6PgOvwKxod7ssx7dQEbAgK96Cc3sEsOl/MMautbk8MzAUvUTgFVt75BxEv5D vvVs0dQ4BgJTXfUFKWBb6V+A4CMe4/8QVnzhYeBTKtv8qk69Y127XoYxICia+zajmslS FVk/GIyKm1XL7wwojVxb1X2AyvSjTIJ8xDU/CeSfZTBQNbqIkfVVyL6UMQOpCSLmH1FN mFog== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id wv8-20020a170907080800b008327270a7ffsi27562914ejb.663.2023.01.05.04.51.50; Thu, 05 Jan 2023 04:52:07 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=zte.com.cn Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231326AbjAEMQh (ORCPT + 55 others); Thu, 5 Jan 2023 07:16:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50830 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231869AbjAEMQ1 (ORCPT ); Thu, 5 Jan 2023 07:16:27 -0500 Received: from mxct.zte.com.cn (mxct.zte.com.cn [183.62.165.209]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70F6C44C5B; Thu, 5 Jan 2023 04:16:24 -0800 (PST) Received: from mse-fl2.zte.com.cn (unknown [10.5.228.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mxct.zte.com.cn (FangMail) with ESMTPS id 4NnlnK6gRTz501Qw; Thu, 5 Jan 2023 20:16:21 +0800 (CST) Received: from szxlzmapp01.zte.com.cn ([10.5.231.85]) by mse-fl2.zte.com.cn with SMTP id 305CGAi6064280; Thu, 5 Jan 2023 20:16:10 +0800 (+08) (envelope-from yang.yang29@zte.com.cn) Received: from mapi (szxlzmapp01[null]) by mapi (Zmail) with MAPI id mid14; Thu, 5 Jan 2023 20:16:13 +0800 (CST) Date: Thu, 5 Jan 2023 20:16:13 +0800 (CST) X-Zmail-TransId: 2b0363b6bf8dffffffffd846a38d X-Mailer: Zmail v1.0 Message-ID: <202301052016131375697@zte.com.cn> Mime-Version: 1.0 From: To: Cc: , , , , , , Subject: =?UTF-8?B?W1BBVENIIGxpbnV4LW5leHRdIGJsa3RyYWNlOiB1c2Ugc3Ryc2NweSgpIHRvIGluc3RlYWQgb2Ygc3RybmNweSgp?= Content-Type: text/plain; charset="UTF-8" X-MAIL: mse-fl2.zte.com.cn 305CGAi6064280 X-Fangmail-Gw-Spam-Type: 0 X-FangMail-Miltered: at cgslv5.04-192.168.251.13.novalocal with ID 63B6BF95.000 by FangMail milter! X-FangMail-Envelope: 1672920981/4NnlnK6gRTz501Qw/63B6BF95.000/10.5.228.133/[10.5.228.133]/mse-fl2.zte.com.cn/ X-Fangmail-Anti-Spam-Filtered: true X-Fangmail-MID-QID: 63B6BF95.000/4NnlnK6gRTz501Qw X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_PASS,UNPARSEABLE_RELAY 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 From: Xu Panda The implementation of strscpy() is more robust and safer. That's now the recommended way to copy NUL-terminated strings. Signed-off-by: Xu Panda Signed-off-by: Yang Yang --- kernel/trace/blktrace.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c index 918a7d12df8f..ff0cc68d7667 100644 --- a/kernel/trace/blktrace.c +++ b/kernel/trace/blktrace.c @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, if (!buts->buf_size || !buts->buf_nr) return -EINVAL; - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; + strscpy(buts->name, name, BLKTRACE_BDEV_SIZE); /* * some device names have larger paths - convert the slashes -- 2.15.2