Message ID | 20230917154302.913956-1-bergh.jonathan@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp2357120vqi; Sun, 17 Sep 2023 17:14:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEu+0H08HmqjLgB9h7s+FXwnm2jrEQm9hQ5dU8DudNvMZT3qqZTaCd+KTRAhjaQBEBEqZ4O X-Received: by 2002:a05:6a20:b70a:b0:14c:a53c:498c with SMTP id fg10-20020a056a20b70a00b0014ca53c498cmr5810539pzb.10.1694996079227; Sun, 17 Sep 2023 17:14:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694996079; cv=none; d=google.com; s=arc-20160816; b=c7GVmL8qjyf40+D1oHn0GGs/T8RoMYsE1vJxgtHwo39ua2mrk/ADXE+gVrrRgJ+B2m xh2Ps8eMhEo5zPXWAn0oLD5T3YGhs/1sg6YeB9UgtLe4BNXzdqTkkreKYOJ506gkTBZR lnwEXt6y83JJ6LzLvss0X47GeQwkPMCkMA2sS3eJrqpVG23b5r4YAM2l9lRCxPuHkbpq atGPueCokwkc2Ghmj6sLclO5HWwpS67E9h+rCPI5MSaBv/cbhSxMK4MK2Ct0yETAnfSc l51Pu1asnPNH/vvOXe96fnkXwpEgf/PCsLZIF7hfhqfEPtmyA64m7sypbKfSftEBuBAn N3bw== 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=kyE2cahixYUhSxqHETVMaNUic+89+Aiv8SH8B+785uI=; fh=a/s45YuhTFF9HDl6pMrSzwKLljh7BT0Fj9EfJNxFsCc=; b=0eBOk5O101Lo4wOvi0bRys1DxcZ4jONM6GcuhywR/SFvzKeup/jISm5TENOJf0LKrF lPgTFuEq1VDNPr0gAaMTeA0clmh1kAkCPr3DVlIeXVNnpuhDu3L+JHXkTB+0ardo11YS 24C2mB3BHC6sQLB2iuarNPSie+9Lpx0A3yBjH+ys3s1cxpdr6gFj0yg8oHPsoONq5mie PriX4Yz8sBLvarFIeOBGlYEN3cMWXwI+E/xv5368NmiXVnNA/P1Rh8cWgu7S4I5h9VhA puduKif+4IhY5k+zAFLIo+S7PoXxpKeah4qp5yI9D1p2jGhDXdAhZLBa9+3mf3Mod5Sd GLWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QUMpuvdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id cu13-20020a056a00448d00b0069058764684si3914777pfb.367.2023.09.17.17.14.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 17:14:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=QUMpuvdf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id DF3758253FDF; Sun, 17 Sep 2023 08:45:52 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236607AbjIQPpH (ORCPT <rfc822;toshivichauhan@gmail.com> + 29 others); Sun, 17 Sep 2023 11:45:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53686 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234517AbjIQPoi (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sun, 17 Sep 2023 11:44:38 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6D92FF7 for <linux-kernel@vger.kernel.org>; Sun, 17 Sep 2023 08:44:32 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id 38308e7fff4ca-2bffd6c1460so9257941fa.3 for <linux-kernel@vger.kernel.org>; Sun, 17 Sep 2023 08:44:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1694965470; x=1695570270; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=kyE2cahixYUhSxqHETVMaNUic+89+Aiv8SH8B+785uI=; b=QUMpuvdfFfB8vggbGhcXQwTOtjK8mKZzYvkIOOGj2TpVWvEdDovO9T8YALO5QzZHl7 GeM4SJQQ8c4B+9DSSTxn0Y8duB2AnHvE3+qs46q8seJ9Jq6g4C/i2LTUj2iz3/FsbCiF fhZGvAQk7ASJ3km5LGKkau4h9bt1oDYp+pt1/8U60eR+GcqKgg98NkOG3nT0P+xbZTRN VUTi6T/4xBhz6dWaqUwplT2+kiu2DOk80SXhRhJQw7YbaX8xzONW7SJhN2pYRRsgddjU CV+OsuUYZC5N9Avu3T+0hod+ovsezceX56ZcpBuYpPGTf9uqwgo3WqobTEP5sOvDW8zc xAFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694965470; x=1695570270; 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=kyE2cahixYUhSxqHETVMaNUic+89+Aiv8SH8B+785uI=; b=E9Y1KNrlhcTA2deGLfVhQWd3agu/JG7O7SXArA4d5IjMT/dsk0zxbqr8iQAM/MTgQz +DPVPsJmlFnK/BfLQfxO+Q4midowc4i7CJVeF0cRAr4nYsuUfia36/veL61f/kZVJ+n0 7IEb9LD8SBc5Xhw+0VB+mBQJl1+9O83o2Ch9gexeWvy0pAzaKtrWUHg1r5rZIqSARzzd 4X3GnW4e35LFfhZLKsX12B1XLM/BWNzLRVziLWYl4Y3WZ8ybsAj8vnT1Ns12fUzJamj9 ZNZuuKD684kV1Wlv92vK7aHzO/gSmVyrA1gXpZywyXp11AVf8c+7bBR/UxJe8RmHU6F8 M0Fw== X-Gm-Message-State: AOJu0YxZF+IKzYZPpOwiVCn1hLsj1Kd41VLHeyaZx9yFboYRjVJpjaFk U7YKQsc8tvziJdZNyMxMkUK1rPs0ZfKNxpwN X-Received: by 2002:a2e:a7c9:0:b0:2bf:ff17:811e with SMTP id x9-20020a2ea7c9000000b002bfff17811emr2215422ljp.14.1694965469323; Sun, 17 Sep 2023 08:44:29 -0700 (PDT) Received: from HP-ENVY-Notebook.lan (81-229-94-10-no68.tbcn.telia.com. [81.229.94.10]) by smtp.googlemail.com with ESMTPSA id h19-20020a2e9ed3000000b002b836d8c839sm1668550ljk.40.2023.09.17.08.44.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 17 Sep 2023 08:44:28 -0700 (PDT) From: Jonathan Bergh <bergh.jonathan@gmail.com> To: gregkh@linuxfoundation.org Cc: linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org, Jonathan Bergh <bergh.jonathan@gmail.com> Subject: [PATCH] staging: vme_user: Replace strcpy with strscpy Date: Sun, 17 Sep 2023 17:43:02 +0200 Message-Id: <20230917154302.913956-1-bergh.jonathan@gmail.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, 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 lipwig.vger.email Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Sun, 17 Sep 2023 08:45:52 -0700 (PDT) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777332208804570361 X-GMAIL-MSGID: 1777332208804570361 |
Series |
staging: vme_user: Replace strcpy with strscpy
|
|
Commit Message
Jonathan Bergh
Sept. 17, 2023, 3:43 p.m. UTC
Replace strcpy with strscpy as preferred by checkpatch in vme_fake.c to
prevent warnings.
Signed-off-by: Jonathan Bergh <bergh.jonathan@gmail.com>
---
drivers/staging/vme_user/vme_fake.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On Sun, Sep 17, 2023 at 05:43:02PM +0200, Jonathan Bergh wrote: > Replace strcpy with strscpy as preferred by checkpatch in vme_fake.c to > prevent warnings. > > Signed-off-by: Jonathan Bergh <bergh.jonathan@gmail.com> > --- > drivers/staging/vme_user/vme_fake.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c > index 9bcb89a84d53..0cf5700e151f 100644 > --- a/drivers/staging/vme_user/vme_fake.c > +++ b/drivers/staging/vme_user/vme_fake.c > @@ -1093,7 +1093,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)); If it were this easy, we would have swept the tree and done so, right? Are you sure this is correct? If so, please document exactly why it is correct in the changelog text when you resend this. thanks, greg k-h
On Sun, Sep 17, 2023 at 06:24:35PM +0200, Greg KH wrote: > On Sun, Sep 17, 2023 at 05:43:02PM +0200, Jonathan Bergh wrote: > > Replace strcpy with strscpy as preferred by checkpatch in vme_fake.c to > > prevent warnings. > > > > Signed-off-by: Jonathan Bergh <bergh.jonathan@gmail.com> > > --- > > drivers/staging/vme_user/vme_fake.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c > > index 9bcb89a84d53..0cf5700e151f 100644 > > --- a/drivers/staging/vme_user/vme_fake.c > > +++ b/drivers/staging/vme_user/vme_fake.c > > @@ -1093,7 +1093,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)); > Hi, thanks a lot for the review + comment. > If it were this easy, we would have swept the tree and done so, right? > Are you sure this is correct? If so, please document exactly why it is > correct in the changelog text when you resend this. Thought it better to discuss before sending an updated patch that might be wrong. I think it is correct since driver_name: * In: vme_fake.c: static const char driver_name[] = "vme_fake": will always fit into vme_bridge->name: * In: vme_bridge.h: ... #define VMENAMSIZ 16 ... struct vme_bridge { ... char name[VMENAMSIZ]; ... } but I could have missed something. This is in the module __init method and i dont see that name pointer being reassigned before the strcpy call (which was changed). Maybe its not worth changing, but (if it is correct) it would get rid of the checkpatch warning and convert to the "preferred" API? > > thanks, > > greg k-h FWIW Wouldnt it always be better to use the "safe" option since it at worst its going to truncate the destination string rather than write off the end of the array? thanks in advance cheers Jonathan
diff --git a/drivers/staging/vme_user/vme_fake.c b/drivers/staging/vme_user/vme_fake.c index 9bcb89a84d53..0cf5700e151f 100644 --- a/drivers/staging/vme_user/vme_fake.c +++ b/drivers/staging/vme_user/vme_fake.c @@ -1093,7 +1093,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)); /* Add master windows to list */ INIT_LIST_HEAD(&fake_bridge->master_resources);