From patchwork Thu Aug 18 21:01:10 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12947939 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B3F5C00140 for ; Thu, 18 Aug 2022 21:09:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346327AbiHRVJs (ORCPT ); Thu, 18 Aug 2022 17:09:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346061AbiHRVJE (ORCPT ); Thu, 18 Aug 2022 17:09:04 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FC90DB7DE for ; Thu, 18 Aug 2022 14:04:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=k1; bh=N6BywkBKgygX/iq/S3KMnIP0Yhx fcMiSe4kDyKM/6zk=; b=to2GQpI27KvyBrjSMEvnYI3cxOjZ1WWue2ZyZksxp4s lUkKjWC/aM1Kg7WiT0waKuEpuOXifoJ264hsfgqRj0+pm2JZWjvLQMPOCLxbujpD SdVNc8ZwqiIAPy+BJ5VMst/6PK/t5ElnbHlmiUfTmPjQhLHgeTNxnGTaVubCSENg = Received: (qmail 3961877 invoked from network); 18 Aug 2022 23:01:24 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:24 +0200 X-UD-Smtp-Session: l3s3148p1@YcPASIrm+swucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Hans de Goede , linux-fsdevel@vger.kernel.org Subject: [PATCH 01/14] vboxsf: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:10 +0200 Message-Id: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang Reviewed-by: Hans de Goede --- fs/vboxsf/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/vboxsf/super.c b/fs/vboxsf/super.c index d2f6df69f611..1fb8f4df60cb 100644 --- a/fs/vboxsf/super.c +++ b/fs/vboxsf/super.c @@ -176,7 +176,7 @@ static int vboxsf_fill_super(struct super_block *sb, struct fs_context *fc) } folder_name->size = size; folder_name->length = size - 1; - strlcpy(folder_name->string.utf8, fc->source, size); + strscpy(folder_name->string.utf8, fc->source, size); err = vboxsf_map_folder(folder_name, &sbi->root); kfree(folder_name); if (err) { From patchwork Thu Aug 18 21:01:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12947940 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6A48C00140 for ; Thu, 18 Aug 2022 21:09:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346671AbiHRVJy (ORCPT ); Thu, 18 Aug 2022 17:09:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346637AbiHRVJW (ORCPT ); Thu, 18 Aug 2022 17:09:22 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F73DD83EF for ; Thu, 18 Aug 2022 14:04:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=gdwMVn08U0Xy1O 0ChHwkhYVnApy2tDKyoBT757de7NE=; b=gdxta6iGx7Uc4I/oV9LejgZ99B5mcd PFNWdgtE4wTl3W2RA4mrCtaZciN8jhCWb/sFyeb6iM7yiTK7RkBOzymkEdtofb0v WBz1G16tIq9ZBNDZ9SyMCkweP9WSUrLWaLN22gBe7eZYXbqRcWcEYSkzxnPIjQgz +Oi+8ms+iq4Es= Received: (qmail 3961932 invoked from network); 18 Aug 2022 23:01:26 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:26 +0200 X-UD-Smtp-Session: l3s3148p1@MynhSIrmBb4ucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , linux-fsdevel@vger.kernel.org Subject: [PATCH 03/14] proc: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:12 +0200 Message-Id: <20220818210123.7637-3-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> References: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- fs/proc/kcore.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index dff921f7ca33..9f61d5d405f5 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -422,7 +422,7 @@ read_kcore(struct file *file, char __user *buffer, size_t buflen, loff_t *fpos) char *notes; size_t i = 0; - strlcpy(prpsinfo.pr_psargs, saved_command_line, + strscpy(prpsinfo.pr_psargs, saved_command_line, sizeof(prpsinfo.pr_psargs)); notes = kzalloc(notes_len, GFP_KERNEL); From patchwork Thu Aug 18 21:01:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12947942 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 703B2C00140 for ; Thu, 18 Aug 2022 21:11:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343544AbiHRVLM (ORCPT ); Thu, 18 Aug 2022 17:11:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346493AbiHRVKI (ORCPT ); Thu, 18 Aug 2022 17:10:08 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2722AD3E40 for ; Thu, 18 Aug 2022 14:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=KC1HZoPhJtlqDU UTWW+aiHPOzwFkXoEc81nhUB0Z74M=; b=jdR1k3PE5INssZuPH4/acL1j6ZIF94 VIjO1ZzBRH89T8ZxDZebPxu+fWPxpMnC9W58mL+WYCwligJFtV52RkgLKyOql8iB v/YAvNkVtWLN3z3GWm6XkTQNhIAtNM8TjVtfVhDvxbHqE04FNCRN1LQ+M50rb+co YrtLzdVzA8Hhs= Received: (qmail 3962202 invoked from network); 18 Aug 2022 23:01:37 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:37 +0200 X-UD-Smtp-Session: l3s3148p1@BymMSYrmI6sucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , David Sterba , linux-fsdevel@vger.kernel.org Subject: [PATCH 13/14] affs: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:22 +0200 Message-Id: <20220818210123.7637-13-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> References: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- fs/affs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/affs/super.c b/fs/affs/super.c index 4c5f30a83336..58b391446ae1 100644 --- a/fs/affs/super.c +++ b/fs/affs/super.c @@ -276,7 +276,7 @@ parse_options(char *options, kuid_t *uid, kgid_t *gid, int *mode, int *reserved, char *vol = match_strdup(&args[0]); if (!vol) return 0; - strlcpy(volume, vol, 32); + strscpy(volume, vol, 32); kfree(vol); break; } From patchwork Thu Aug 18 21:01:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wolfram Sang X-Patchwork-Id: 12947941 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0123FC32774 for ; Thu, 18 Aug 2022 21:11:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346528AbiHRVLL (ORCPT ); Thu, 18 Aug 2022 17:11:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346581AbiHRVKD (ORCPT ); Thu, 18 Aug 2022 17:10:03 -0400 Received: from mail.zeus03.de (www.zeus03.de [194.117.254.33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 27315D86E3 for ; Thu, 18 Aug 2022 14:04:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple; d=sang-engineering.com; h= from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; s=k1; bh=h9lROeortCPJyN Mu2qYpibIzx4nTSorTqnTqaxhWY58=; b=ediZ0wDnBy1yzEY0fdE2iiC2BNms5a BHN1vxUlk2hzZjD5DNoHWvKC34tUkouZ0LUOw2gEZta56nyBfI9ecGJ/KApOMSdS 9f2Ifzoceqi5jKKm/evsbkj2RC7ciOWLkW06W1t8cCu5eI5zsbA+TEhp0S7WuZll QZYHIm18hB514= Received: (qmail 3962228 invoked from network); 18 Aug 2022 23:01:38 +0200 Received: by mail.zeus03.de with ESMTPSA (TLS_AES_256_GCM_SHA384 encrypted, authenticated); 18 Aug 2022 23:01:38 +0200 X-UD-Smtp-Session: l3s3148p1@F7SdSYrm5qcucref From: Wolfram Sang To: linux-kernel@vger.kernel.org Cc: Wolfram Sang , Alexander Viro , linux-fsdevel@vger.kernel.org Subject: [PATCH 14/14] fs: move from strlcpy with unused retval to strscpy Date: Thu, 18 Aug 2022 23:01:23 +0200 Message-Id: <20220818210123.7637-14-wsa+renesas@sang-engineering.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> References: <20220818210123.7637-1-wsa+renesas@sang-engineering.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Follow the advice of the below link and prefer 'strscpy' in this subsystem. Conversion is 1:1 because the return value is not used. Generated by a coccinelle script. Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ Signed-off-by: Wolfram Sang --- fs/char_dev.c | 2 +- fs/super.c | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/char_dev.c b/fs/char_dev.c index ba0ded7842a7..c6be63dfef04 100644 --- a/fs/char_dev.c +++ b/fs/char_dev.c @@ -150,7 +150,7 @@ __register_chrdev_region(unsigned int major, unsigned int baseminor, cd->major = major; cd->baseminor = baseminor; cd->minorct = minorct; - strlcpy(cd->name, name, sizeof(cd->name)); + strscpy(cd->name, name, sizeof(cd->name)); if (!prev) { cd->next = curr; diff --git a/fs/super.c b/fs/super.c index 734ed584a946..708569341fe5 100644 --- a/fs/super.c +++ b/fs/super.c @@ -573,7 +573,7 @@ struct super_block *sget_fc(struct fs_context *fc, fc->s_fs_info = NULL; s->s_type = fc->fs_type; s->s_iflags |= fc->s_iflags; - strlcpy(s->s_id, s->s_type->name, sizeof(s->s_id)); + strscpy(s->s_id, s->s_type->name, sizeof(s->s_id)); list_add_tail(&s->s_list, &super_blocks); hlist_add_head(&s->s_instances, &s->s_type->fs_supers); spin_unlock(&sb_lock); @@ -652,7 +652,7 @@ struct super_block *sget(struct file_system_type *type, return ERR_PTR(err); } s->s_type = type; - strlcpy(s->s_id, type->name, sizeof(s->s_id)); + strscpy(s->s_id, type->name, sizeof(s->s_id)); list_add_tail(&s->s_list, &super_blocks); hlist_add_head(&s->s_instances, &type->fs_supers); spin_unlock(&sb_lock);