Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp3692400rdg; Wed, 18 Oct 2023 03:22:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiIpk+vBsFPJ1aIQyzwpSFKfIxWQKuczrLVPGo7hSfCt4b8Djsb0RyjENFvXuQgxcj4URU X-Received: by 2002:a17:903:110d:b0:1c9:e774:58d1 with SMTP id n13-20020a170903110d00b001c9e77458d1mr5101347plh.36.1697624546551; Wed, 18 Oct 2023 03:22:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697624546; cv=none; d=google.com; s=arc-20160816; b=Bostl59V29cFbm7oXe/GlK2VJ7trOWzQz3ThU+SatTufboNm2hTCqUu3lTHESXyqmx A0itzZzUpPikwtghf0WYlRcc7p44iUXMJnuC7lD7/8T+qwz2TvlhUhI1loDdy+L0J/qq dLmCRqg9a5tP8MW0/tQlCxJdjtSPr7xleIPqVaV+Mqil45YySl+NMmTC0BebCHqmzdh3 /valtqmQTkZAyAVlpeVbDablre84N+AHFYEESOJw2m2X5cZGJZGFs5V9zkJ2YCBJqScN xb/HNawHODmQ9xvRlEBoi56TDb75RmHVSrspwAzC3nUgTLDGcPfRcdpGO5BcQN2Tbvjj UmMQ== 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=+YPVxhrij/9yyiFDCmXjbqG79WA01Bk0XowWcY3BL1k=; fh=7X8wq0HjdBm7UHFqSGs33MDZrMg7V1wycxuO2yJWCuo=; b=Jh49q1+wVvXY3JS3IVSqpas6v3RbZyn7IYPYKHLDJO7Cq0phEqk8dN9JgSqCni5HZz trxgrZj+f7WatG0b27XqF3r5liwCMIRvL6k+bbgsW6u45qB7qC9FVh09vSmyg/hKXNQ7 hxLW+cSyoHXA1KKxefKqY1dclCHVy2HS2aQKEnPktEj0V0MosW5afZM6qXPE/hYd7vN1 L+tAaRGn5komfL6uiZ1Fwzq7zx3QDO9k5JhRcSOshi4cc0IjNkeLH656/foOfTpmTpz+ paMz1Hs+KuuxFqkgjDLvOGS8SwZJHQO0Z6tWa9aCxvzsbf/AVbfiREReinIgdY/cdI9M qWfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u8MnSC4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id k4-20020a170902d58400b001c9fb2acff5si3769560plh.526.2023.10.18.03.22.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:22:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=u8MnSC4A; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 62CAE805A89E; Wed, 18 Oct 2023 03:22:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229778AbjJRKWS (ORCPT + 99 others); Wed, 18 Oct 2023 06:22:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230386AbjJRKWQ (ORCPT ); Wed, 18 Oct 2023 06:22:16 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCE9BB0 for ; Wed, 18 Oct 2023 03:22:12 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id ffacd0b85a97d-3296b49c546so5218728f8f.3 for ; Wed, 18 Oct 2023 03:22:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697624531; x=1698229331; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=+YPVxhrij/9yyiFDCmXjbqG79WA01Bk0XowWcY3BL1k=; b=u8MnSC4Akx15maRa8AfHyPDBL6WFX+JbB1iqRyNbXnfBJla+Dknx/hpbkzMShQg0ix JGDJEHj4OHD9ZKVKdIwrPSta8stYmw0R9hESjC/bV1nATMtp5JEu1Q8J6K5yZ8Gan7hG ghS+SCFJNIE1b1WaFj1wBTQ/98kXh3OW+J1ev3vn3QfKi28lFpTgxnLtYxxytAhmpuHy wx0rlDssLQvm7FE6FGxUelIavCrdPTIdC8YeqvvTGelFZlVvTzsT7dXRCzo0FHKQxCRB MWHWYQ0h3SEnCK9GoGOgseNoYDM/giAw/c4MOYBktLBsnWAGRMcO/1biX66Z3s45+QIA TsYg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697624531; x=1698229331; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+YPVxhrij/9yyiFDCmXjbqG79WA01Bk0XowWcY3BL1k=; b=u5OxA9gKwdmRQB9OkFX0F8ExrzjckXhWcm1sPu5LbAcXMS1XXxEbBSJOeeNATW5oe3 ZiBfMooNGF+HQyO2n8kXKhmk5yK0SihPkk/ag2+z9FKosgraZEQPPgsXY7DyBFW/8vLj 4AyeGbHvJQgL2bKChrI736SmIhfwMH0lYeaVmZ25kQEEmqMmP38dudlfLg0NFoXaXYn1 pi+fHetgvVygJFNga5i3VKVaHHYaQW0njUAVdroUFaTaiAJP7ql9R+hElMLOHaIWcckc /z6evPfz555+AngVyACHOCpOxeAovS2GAzaDvtCj9O4r9y9lVQwf6VRyg3bx7+wsPEcB gY0A== X-Gm-Message-State: AOJu0YyKcYeyBhY0jd2Ns/hTH5eOjK2pfAUWDJp83se4oM+i+SfEaS1R vMcFzfkNgGtA/SLAgewXecQUnQ== X-Received: by 2002:a5d:4e90:0:b0:32d:a4c4:f700 with SMTP id e16-20020a5d4e90000000b0032da4c4f700mr3953978wru.38.1697624531035; Wed, 18 Oct 2023 03:22:11 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id c5-20020adfef45000000b0032da4c98ab2sm1796413wrp.35.2023.10.18.03.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Oct 2023 03:22:10 -0700 (PDT) Date: Wed, 18 Oct 2023 13:22:06 +0300 From: Dan Carpenter To: Calvince Otieno Cc: gustavo@embeddedor.com, outreachy@lists.linux.dev, Greg Kroah-Hartman , Martyn Welch , Manohar Vanga , linux-kernel@vger.kernel.org, linux-staging@lists.linux.dev, Julia Lawall Subject: Re: [PATCH V2] staging: vme_user: replace strcpy with strscpy Message-ID: <8a1d6d6f-b650-4aad-9b31-07a0a8acf45c@kadam.mountain> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.8 required=5.0 tests=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 agentk.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 (agentk.vger.email [0.0.0.0]); Wed, 18 Oct 2023 03:22:24 -0700 (PDT) On Wed, Oct 18, 2023 at 11:53:00AM +0300, Calvince Otieno wrote: > Checkpatch suggests using strscpy() instead of strcpy(). > > The advantages of strscpy() are that it always adds a NUL terminator > and prevents read overflows if the source string is not properly > terminated. strcpy() also always adds a NUL terminator. With strcpy() both read overflows and write overflows are an issue but write overflows are sooooooo much more serious that we don't worry about read overflow. > One potential disadvantage is that it doesn't zero pad the > string like strcpy() does. strcpy() does not zero pad anything. You're resending patches too quickly. You should wait a day between resends. > > In this specific context, both strscpy and strcpy performs the same > operation without any functional difference. > > The reason for this equivalence is that the driver_name string "vme_fake" > is shorter than the size of the fake_bridge->name array which is defined > as 16 characters (struct vme_bridge {char name[VMENAMSIZ];...}). Thus, > there is no risk of buffer overflow in either case. VMENAMSIZ variable > holds a constant value of 16 (#define VMENAMSIZ 16) This paragraph is good and sufficient. > > The null-terminated "vme_fake" string > (static const char driver_name[] = "vme_fake";) can be safely copied into > fake_bridge->name using either strscpy or strcpy. > > While using strscpy() does not address any bugs, it is considered a better > practice and aligns with checkpatch recommendations. > > Signed-off-by: Calvince Otieno Okay. Good. Re-write the commit message and resend it tomorrow. regards, dan carpenter