From patchwork Thu Oct 20 03:09:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: cuijinpeng666@gmail.com X-Patchwork-Id: 5968 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp35090wrs; Wed, 19 Oct 2022 20:10:38 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/VWE2yqDx8Ow0AEzD6CODw1F+g4GMdQb4QWo6tP93cPBy3vU67jpPSDhQqzGg1ClJFOms X-Received: by 2002:a17:906:8a4a:b0:78d:5ff6:7507 with SMTP id gx10-20020a1709068a4a00b0078d5ff67507mr9180868ejc.194.1666235438634; Wed, 19 Oct 2022 20:10:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666235438; cv=none; d=google.com; s=arc-20160816; b=OMILXF1XH4VwWRPzieBfjwQDER30+vd2v4vjTwDXDesWbHM0yf5PJTPH2YNIaanrWu MZ6EMjk8P6Nap9hod0Q7fO3RPO/ej3Qo18ouGxun7oXZUcdJGQ13r+jvBCorX4y+37SM Io7dfjFJvZbsdlLlfQhPAF1/+dKSJDjg2q921Cz/BdoQS92Om9dtrMgw9yy/mhZ5ivl5 TXksFHXN8/59+WKuFGYjDO3vTayCMHMa3qcd3h+rggtMKeRisfhcqGeTYYM9OzFXzUqQ bBTZod8umPW70dscONjk7jqNLdQigvKnqDMQ/W6MatH3e/XJzZNOSShzymxHFLlCHH9y NIZA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=fI84mLWVngwKUi26D1TkjXUQLixkWYJFgxEZz3tPHX8=; b=Hvd3pae3m+Clc2A6jul4CQSKk4CyF8Khc/TYYH8lJNhYX4IVR5ash8oYk8kymfS9UU FR9h3NGVnjwcf/qlVXbAl9GkNc8pIVvIDkL3/jumazFtMF8lAjr36GmguHLlGgXv4obH JFbPxNWF0t3GxSipwhyC/TSYbTTBOayGMR3d37w2oia+xY2AM4WqOuuQ5sXGWrD2nERv LzerCGgTaXwGKvrAxR46BcNwTiQTYl/9QABSAqVt+xuMZcEbCeYODTbxHCX3hy/LGdAx Anbzn40AXsltRgSPSOrIM291DIIoU23DCS3pPXiyLs0fecmLD/uX0njOd2WqXK8azoxb g5xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=mXoImnuB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ga8-20020a1709070c0800b0077a5733ac08si6319519ejc.601.2022.10.19.20.10.14; Wed, 19 Oct 2022 20:10:38 -0700 (PDT) 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=@gmail.com header.s=20210112 header.b=mXoImnuB; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229786AbiJTDJa (ORCPT + 99 others); Wed, 19 Oct 2022 23:09:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41310 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229663AbiJTDJ1 (ORCPT ); Wed, 19 Oct 2022 23:09:27 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1B6F410E4; Wed, 19 Oct 2022 20:09:22 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id fw14so18576671pjb.3; Wed, 19 Oct 2022 20:09:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=fI84mLWVngwKUi26D1TkjXUQLixkWYJFgxEZz3tPHX8=; b=mXoImnuBwYTrzEXpbrq9iPF+KlNKvbh+pkRzZISj+9gL/lA3wkzX/TN48tYGZreI12 6HbT0IR17kV2/c8EMX1db2aRPhEkXwT6i52Zqo3KpeCdEDW+VAYEwiD72g+eUFSDsrHF 75tPWuhWAw2wktcBcAlqT8QJp9nsMA7pgoiHqsPlzQPRjh3ZHAg780LU4JdD3b/01z6A S/M9jXDgByGQNis6Vnx2FvDbPWKGv00FZaNuArl1Qj/zCmFpzgIdVAR/zKfba9RZ+cny 4sdJyla5p1Amx/1POa2kyR4H788vFkGhK+Pk3ISpNJ/yuOOR7JUDzJ1gqzwKu0l8+0Dc al8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=fI84mLWVngwKUi26D1TkjXUQLixkWYJFgxEZz3tPHX8=; b=vYJnpQGFvWbnwZJWJMfgVYcETzqNKizpwMTjSyNIHOHGvkk3Y8jpDt5QImMj/w7AwX 8hWLvOGiBVo+yhtwA5uNgXi/xKw9bmlNtnCFE1xNG5blLSy38EUdo9ff/JxIepRagI4W 5pm/GKX5xorZC1WqJuJZKQ29vAtGCnVKCEFYpj6tkSIZDF73EevhAZwzU/TeLWzKz9ik agJ8hkmYSbByGkYDXxeXACHi0sBJS7+t69dFXsIkFRnXwwDorAwcAJPcIxGwZ/56XZvK lYFaMf4CZXZUdNcZ+sxtZkHvhyhSWmr0wKqkSQWmqjaQucMno/sl77L9CLWMs726mzAC 5A5Q== X-Gm-Message-State: ACrzQf3qOH4G3SRN54YR+yrA0YS+qD5x5Wq0pIHBkQM3hTNYwNSOX5iO +qT5oBM83jinZV3Z/K+MauI= X-Received: by 2002:a17:90b:3c51:b0:20c:2630:5259 with SMTP id pm17-20020a17090b3c5100b0020c26305259mr48319115pjb.177.1666235361609; Wed, 19 Oct 2022 20:09:21 -0700 (PDT) Received: from localhost.localdomain ([193.203.214.57]) by smtp.gmail.com with ESMTPSA id b2-20020a170902d50200b00177324a7862sm718541plg.45.2022.10.19.20.09.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 20:09:19 -0700 (PDT) From: cuijinpeng666@gmail.com X-Google-Original-From: cui.jinpeng2@zte.com.cn To: viro@zeniv.linux.org.uk Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Jinpeng Cui , Zeal Robot Subject: [PATCH linux-next] fs/super.c: use strscpy() is more robust and safer Date: Thu, 20 Oct 2022 03:09:15 +0000 Message-Id: <20221020030915.393801-1-cui.jinpeng2@zte.com.cn> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,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?1747174491666434449?= X-GMAIL-MSGID: =?utf-8?q?1747174491666434449?= From: Jinpeng Cui The implementation of strscpy() is more robust and safer. Reported-by: Zeal Robot Signed-off-by: Jinpeng Cui --- fs/super.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/super.c b/fs/super.c index 8d39e4f11cfa..ca791da59c98 100644 --- a/fs/super.c +++ b/fs/super.c @@ -574,7 +574,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); @@ -653,7 +653,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);