Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3628500rdg; Wed, 18 Oct 2023 00:39:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEfKsfuDy4QeoBSuHtdNDR7aW/1Lw0yKWIfJCidSkkiuIZFbYjCsUndRcT25b8r3vpgYcr8 X-Received: by 2002:a05:6a21:6d93:b0:17a:e941:b0a3 with SMTP id wl19-20020a056a216d9300b0017ae941b0a3mr4318523pzb.39.1697614787029; Wed, 18 Oct 2023 00:39:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697614787; cv=none; d=google.com; s=arc-20160816; b=F0+jYz/uXuY10UHnNQA+Bo8/5sIgHikDyqttoiYFM3Z77/7ObdiBao+/zp+a+kVod9 e/TbzNFZSrQYv3SIZEsd26bKSzoOiNkYB9ZI+/iONGyf6GX5kE9pBNxoTom5Jsp726t6 OnHXjVSo3OnggwFmGoDIrAqg5oucQ0j2vdYj9hgse+GKIG3n4J9/+8+0d5dMZuIK7NPb 4Q1FMA2QbAIsQBXAC8LWmjZo4kBkcFDKvmOUKJUQVgy21BMqAlkFhTQEm3L2U9VMIwmH 79WRTQxbNdb9Nqybj91mcIFztOXXyLrklurDQbz5gxC6PM1EEabIbMn+HeIU8pbDp5LI D0Ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FP440yfbH9QBRNvzY9SfOC0Qg948s+EXhbym78MGCqE=; fh=r0NhzNkzG/tB07Dxmrma0ySEpGN9s5vJnZ1ksbPlU/w=; b=ycdkayYoBGZ6pky+zXrOSTCSgdzh6m5A8ybnDayAdvHtwcpPxWNG4PJROmbICskWrx JZp9k7bOFDwJ8iSiJgyws2ZnCbX4uF0h/kLwytg9O0zf1Z+wUwLdvpTD1O7eKZTsfMHG vLUXLxQHP7P37g560/wiGnbLugznSPBZoB6vRx5ylWne7X2NgqrHZV4Ihxd/nyux8Ki7 Oa5J80/e7tp7BWWxDjCAUXfxCUV0Db9P1yepWokoKqUtdLDGH1/1h2ZtFcDuxsZANxJw 4wQrj8/A6z5vqxgWfbTFw1UpzBZQmbeqv8Rz8xyH13SfXRWWv42DFdGnOpJwkC+7Le9Z OedQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RKJRBP7Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id e124-20020a636982000000b005af979066c0si1606221pgc.306.2023.10.18.00.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 00:39:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=RKJRBP7Q; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 8999E80C3A30; Wed, 18 Oct 2023 00:39:44 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229797AbjJRHjf (ORCPT + 99 others); Wed, 18 Oct 2023 03:39:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229441AbjJRHjd (ORCPT ); Wed, 18 Oct 2023 03:39:33 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5A8C3C6 for ; Wed, 18 Oct 2023 00:39:30 -0700 (PDT) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 31A6FC433C7; Wed, 18 Oct 2023 07:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1697614769; bh=DOT4lFyDPmpnV7LNhAX7vgMrRhFylHUDm7eC6XlMQpg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=RKJRBP7Q5AOj9uas6TiNVEJ9C23ujJ3Kex45bw9Z6aFY4gjGyQhNR0H4MT3MsV5Sy tmiV7HymHdsavP/YUqVOk966+Onn9lOXY0D90rRxPzdcDkUsB+a03nK0NJAw6S0bji uwqHVfm2PDZET7joHbpeaf66KjSQzSO8tnU9Ko9w= Date: Wed, 18 Oct 2023 09:39:25 +0200 From: Greg Kroah-Hartman To: Calvince Otieno Cc: gustavo@embeddedor.com, outreachy@lists.linux.dev, Martyn Welch , Manohar Vanga , Julia Lawall , linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev Subject: Re: [PATCH] staging: vme_user: replace strcpy with strscpy Message-ID: <2023101844-phoniness-gory-635a@gregkh> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Wed, 18 Oct 2023 00:39:44 -0700 (PDT) On Wed, Oct 18, 2023 at 10:29:51AM +0300, Calvince Otieno wrote: > Checkpatch suggests using strscpy() instead of strncpy(). > > The advantages of strscpy() are that it always adds a NUL terminator > and prevents read overflows if the source string is not properly > terminated. One potential disadvantage is that it doesn't zero pad the > string like strncpy() does. > > In this code, strscpy() and strncpy() are equivalent and do not affect > runtime behavior. strscpy() simply copies the known string value of the > variable driver_name into the fake_bridge->name variable, which also > has a fixed size. > > While using strscpy() does not address any bugs, it is considered a better > practice and aligns with checkpatch recommendations. > > Signed-off-by: Calvince Otieno > --- > drivers/staging/vme_user/vme_fake.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c > index 0e02c194298d..09b05861017a 100644 > --- a/drivers/staging/vme_user/vme_fake.c > +++ b/drivers/staging/vme_user/vme_fake.c > @@ -67,6 +67,7 @@ struct fake_driver { > unsigned long long lm_base; > u32 lm_aspace; > u32 lm_cycle; > + > void (*lm_callback[4])(void *); > void *lm_data[4]; Why did you make this extra line change? > struct tasklet_struct int_tasklet; > @@ -1091,7 +1092,7 @@ static int __init fake_init(void) > tasklet_init(&fake_device->int_tasklet, fake_VIRQ_tasklet, > (unsigned long)fake_bridge); > > - strcpy(fake_bridge->name, driver_name); > + strscpy(fake_bridge->name, driver_name, sizeof(fake_bridge->name)) Are you sure this change is identical? You need to document how you have proved that. thanks, greg k-h