LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy
@ 2019-07-04 23:57 Joe Perches
  2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
                   ` (7 more replies)
  0 siblings, 8 replies; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: Dan Murphy, linux-leds, linux-media, linux-arm-kernel,
	linuxppc-dev, linux-nfs
  Cc: linux-input, linux-kernel, netdev

These are all likely copy/paste defects where the field size of the
'copied to' array is incorrect.

Each patch in this series is independent.

Joe Perches (8):
  Input: synaptics: Fix misuse of strlcpy
  leds: as3645a: Fix misuse of strlcpy
  media: m2m-deinterlace: Fix misuse of strscpy
  media: go7007: Fix misuse of strscpy
  net: ethernet: sun4i-emac: Fix misuse of strlcpy
  net: nixge: Fix misuse of strlcpy
  tty: hvcs: Fix odd use of strlcpy
  nfsd: Fix misuse of strlcpy

 drivers/input/mouse/synaptics.c             | 2 +-
 drivers/leds/leds-as3645a.c                 | 2 +-
 drivers/media/platform/m2m-deinterlace.c    | 2 +-
 drivers/media/usb/go7007/snd-go7007.c       | 2 +-
 drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++--
 drivers/net/ethernet/ni/nixge.c             | 2 +-
 drivers/tty/hvc/hvcs.c                      | 4 ++--
 fs/nfsd/nfs4idmap.c                         | 2 +-
 8 files changed, 10 insertions(+), 10 deletions(-)

-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
@ 2019-07-04 23:57 ` Joe Perches
  2019-07-14 18:29   ` Dmitry Torokhov
  2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dmitry Torokhov, linux-input

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/input/mouse/synaptics.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
index 1080c0c49815..00a0cf14f27f 100644
--- a/drivers/input/mouse/synaptics.c
+++ b/drivers/input/mouse/synaptics.c
@@ -705,7 +705,7 @@ static void synaptics_pt_create(struct psmouse *psmouse)
 
 	serio->id.type = SERIO_PS_PSTHRU;
 	strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
-	strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
+	strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->phys));
 	serio->write = synaptics_pt_write;
 	serio->start = synaptics_pt_start;
 	serio->stop = synaptics_pt_stop;
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 2/8] leds: as3645a: Fix misuse of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
  2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
@ 2019-07-04 23:57 ` " Joe Perches
  2019-07-05  7:33   ` Sakari Ailus
                     ` (2 more replies)
  2019-07-04 23:57 ` [PATCH 3/8] media: m2m-deinterlace: Fix misuse of strscpy Joe Perches
                   ` (5 subsequent siblings)
  7 siblings, 3 replies; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: Sakari Ailus, Jacek Anaszewski, Pavel Machek, Dan Murphy
  Cc: linux-leds, linux-kernel

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/leds/leds-as3645a.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
index 14ab6b0e4de9..050088dff8dd 100644
--- a/drivers/leds/leds-as3645a.c
+++ b/drivers/leds/leds-as3645a.c
@@ -668,7 +668,7 @@ static int as3645a_v4l2_setup(struct as3645a *flash)
 	};
 
 	strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name));
-	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfg.dev_name));
+	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfgind.dev_name));
 
 	flash->vf = v4l2_flash_init(
 		&flash->client->dev, flash->flash_node, &flash->fled, NULL,
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 3/8] media: m2m-deinterlace: Fix misuse of strscpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
  2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
  2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
@ 2019-07-04 23:57 ` Joe Perches
  2019-07-04 23:57 ` [PATCH 4/8] media: go7007: " Joe Perches
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Mauro Carvalho Chehab, linux-media

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/media/platform/m2m-deinterlace.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/platform/m2m-deinterlace.c b/drivers/media/platform/m2m-deinterlace.c
index beb7fd7442fb..dd573d23d0ce 100644
--- a/drivers/media/platform/m2m-deinterlace.c
+++ b/drivers/media/platform/m2m-deinterlace.c
@@ -436,7 +436,7 @@ static int vidioc_querycap(struct file *file, void *priv,
 {
 	strscpy(cap->driver, MEM2MEM_NAME, sizeof(cap->driver));
 	strscpy(cap->card, MEM2MEM_NAME, sizeof(cap->card));
-	strscpy(cap->bus_info, MEM2MEM_NAME, sizeof(cap->card));
+	strscpy(cap->bus_info, MEM2MEM_NAME, sizeof(cap->bus_info));
 	/*
 	 * This is only a mem-to-mem video device. The capture and output
 	 * device capability flags are left only for backward compatibility
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 4/8] media: go7007: Fix misuse of strscpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
                   ` (2 preceding siblings ...)
  2019-07-04 23:57 ` [PATCH 3/8] media: m2m-deinterlace: Fix misuse of strscpy Joe Perches
@ 2019-07-04 23:57 ` " Joe Perches
  2019-07-04 23:57 ` [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy Joe Perches
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: Mauro Carvalho Chehab, linux-media, linux-kernel

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/media/usb/go7007/snd-go7007.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/go7007/snd-go7007.c b/drivers/media/usb/go7007/snd-go7007.c
index 4a449c62fc32..b05fa227ffb2 100644
--- a/drivers/media/usb/go7007/snd-go7007.c
+++ b/drivers/media/usb/go7007/snd-go7007.c
@@ -253,7 +253,7 @@ int go7007_snd_init(struct go7007 *go)
 		return ret;
 	}
 	strscpy(gosnd->card->driver, "go7007", sizeof(gosnd->card->driver));
-	strscpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->driver));
+	strscpy(gosnd->card->shortname, go->name, sizeof(gosnd->card->shortname));
 	strscpy(gosnd->card->longname, gosnd->card->shortname,
 		sizeof(gosnd->card->longname));
 
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
                   ` (3 preceding siblings ...)
  2019-07-04 23:57 ` [PATCH 4/8] media: go7007: " Joe Perches
@ 2019-07-04 23:57 ` Joe Perches
  2019-07-08  2:22   ` David Miller
  2019-07-04 23:57 ` [PATCH 6/8] net: nixge: " Joe Perches
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: Maxime Ripard, Chen-Yu Tsai
  Cc: David S. Miller, netdev, linux-arm-kernel, linux-kernel

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/allwinner/sun4i-emac.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 9e06dff619c3..40a359dd90b4 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -224,8 +224,8 @@ static int emac_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 static void emac_get_drvinfo(struct net_device *dev,
 			      struct ethtool_drvinfo *info)
 {
-	strlcpy(info->driver, DRV_NAME, sizeof(DRV_NAME));
-	strlcpy(info->version, DRV_VERSION, sizeof(DRV_VERSION));
+	strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
+	strlcpy(info->version, DRV_VERSION, sizeof(info->version));
 	strlcpy(info->bus_info, dev_name(&dev->dev), sizeof(info->bus_info));
 }
 
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 6/8] net: nixge: Fix misuse of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
                   ` (4 preceding siblings ...)
  2019-07-04 23:57 ` [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy Joe Perches
@ 2019-07-04 23:57 ` " Joe Perches
  2019-07-08  2:23   ` David Miller
  2019-07-04 23:57 ` [PATCH 7/8] tty: hvcs: Fix odd use " Joe Perches
  2019-07-04 23:57 ` [PATCH 8/8] nfsd: Fix misuse " Joe Perches
  7 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: David S. Miller, netdev

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/net/ethernet/ni/nixge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c
index 96f7a9818294..0b384f97d2fd 100644
--- a/drivers/net/ethernet/ni/nixge.c
+++ b/drivers/net/ethernet/ni/nixge.c
@@ -990,7 +990,7 @@ static void nixge_ethtools_get_drvinfo(struct net_device *ndev,
 				       struct ethtool_drvinfo *ed)
 {
 	strlcpy(ed->driver, "nixge", sizeof(ed->driver));
-	strlcpy(ed->bus_info, "platform", sizeof(ed->driver));
+	strlcpy(ed->bus_info, "platform", sizeof(ed->bus_info));
 }
 
 static int nixge_ethtools_get_coalesce(struct net_device *ndev,
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 7/8] tty: hvcs: Fix odd use of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
                   ` (5 preceding siblings ...)
  2019-07-04 23:57 ` [PATCH 6/8] net: nixge: " Joe Perches
@ 2019-07-04 23:57 ` " Joe Perches
  2019-07-04 23:57 ` [PATCH 8/8] nfsd: Fix misuse " Joe Perches
  7 siblings, 0 replies; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: linux-kernel; +Cc: Greg Kroah-Hartman, Jiri Slaby, linuxppc-dev

Use the typical style of array, not the equivalent &array[0].

Signed-off-by: Joe Perches <joe@perches.com>
---
 drivers/tty/hvc/hvcs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c
index cb4db1b3ca3c..b6c1c1be06f9 100644
--- a/drivers/tty/hvc/hvcs.c
+++ b/drivers/tty/hvc/hvcs.c
@@ -871,8 +871,8 @@ static void hvcs_set_pi(struct hvcs_partner_info *pi, struct hvcs_struct *hvcsd)
 	hvcsd->p_partition_ID  = pi->partition_ID;
 
 	/* copy the null-term char too */
-	strlcpy(&hvcsd->p_location_code[0],
-			&pi->location_code[0], sizeof(hvcsd->p_location_code));
+	strlcpy(hvcsd->p_location_code, pi->location_code,
+		sizeof(hvcsd->p_location_code));
 }
 
 /*
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* [PATCH 8/8] nfsd: Fix misuse of strlcpy
  2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
                   ` (6 preceding siblings ...)
  2019-07-04 23:57 ` [PATCH 7/8] tty: hvcs: Fix odd use " Joe Perches
@ 2019-07-04 23:57 ` " Joe Perches
  2019-07-09  3:14   ` J. Bruce Fields
  7 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2019-07-04 23:57 UTC (permalink / raw)
  To: J. Bruce Fields, Chuck Lever; +Cc: linux-nfs, linux-kernel

Probable cut&paste typo - use the correct field size.

Signed-off-by: Joe Perches <joe@perches.com>
---
 fs/nfsd/nfs4idmap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
index 2961016097ac..d1f285245af8 100644
--- a/fs/nfsd/nfs4idmap.c
+++ b/fs/nfsd/nfs4idmap.c
@@ -83,7 +83,7 @@ ent_init(struct cache_head *cnew, struct cache_head *citm)
 	new->type = itm->type;
 
 	strlcpy(new->name, itm->name, sizeof(new->name));
-	strlcpy(new->authname, itm->authname, sizeof(new->name));
+	strlcpy(new->authname, itm->authname, sizeof(new->authname));
 }
 
 static void
-- 
2.15.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] leds: as3645a: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
@ 2019-07-05  7:33   ` Sakari Ailus
  2019-07-05 20:23   ` Pavel Machek
  2019-07-15 18:29   ` Jacek Anaszewski
  2 siblings, 0 replies; 18+ messages in thread
From: Sakari Ailus @ 2019-07-05  7:33 UTC (permalink / raw)
  To: Joe Perches
  Cc: Jacek Anaszewski, Pavel Machek, Dan Murphy, linux-leds, linux-kernel

On Thu, Jul 04, 2019 at 04:57:42PM -0700, Joe Perches wrote:
> Probable cut&paste typo - use the correct field size.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Thanks, Joe!

Acked-by: Sakari Ailus <sakari.ailus@linux.intel.com>

> ---
>  drivers/leds/leds-as3645a.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
> index 14ab6b0e4de9..050088dff8dd 100644
> --- a/drivers/leds/leds-as3645a.c
> +++ b/drivers/leds/leds-as3645a.c
> @@ -668,7 +668,7 @@ static int as3645a_v4l2_setup(struct as3645a *flash)
>  	};
>  
>  	strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name));
> -	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfg.dev_name));
> +	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfgind.dev_name));
>  
>  	flash->vf = v4l2_flash_init(
>  		&flash->client->dev, flash->flash_node, &flash->fled, NULL,

-- 
Kind regards,

Sakari Ailus

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] leds: as3645a: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
  2019-07-05  7:33   ` Sakari Ailus
@ 2019-07-05 20:23   ` Pavel Machek
  2019-07-15 18:29   ` Jacek Anaszewski
  2 siblings, 0 replies; 18+ messages in thread
From: Pavel Machek @ 2019-07-05 20:23 UTC (permalink / raw)
  To: Joe Perches
  Cc: Sakari Ailus, Jacek Anaszewski, Dan Murphy, linux-leds, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1023 bytes --]

On Thu 2019-07-04 16:57:42, Joe Perches wrote:
> Probable cut&paste typo - use the correct field size.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Ack.
									Pavel
> ---
>  drivers/leds/leds-as3645a.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
> index 14ab6b0e4de9..050088dff8dd 100644
> --- a/drivers/leds/leds-as3645a.c
> +++ b/drivers/leds/leds-as3645a.c
> @@ -668,7 +668,7 @@ static int as3645a_v4l2_setup(struct as3645a *flash)
>  	};
>  
>  	strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name));
> -	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfg.dev_name));
> +	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfgind.dev_name));
>  
>  	flash->vf = v4l2_flash_init(
>  		&flash->client->dev, flash->flash_node, &flash->fled, NULL,

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy Joe Perches
@ 2019-07-08  2:22   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2019-07-08  2:22 UTC (permalink / raw)
  To: joe; +Cc: maxime.ripard, wens, netdev, linux-arm-kernel, linux-kernel

From: Joe Perches <joe@perches.com>
Date: Thu,  4 Jul 2019 16:57:45 -0700

> Probable cut&paste typo - use the correct field size.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 6/8] net: nixge: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 6/8] net: nixge: " Joe Perches
@ 2019-07-08  2:23   ` David Miller
  0 siblings, 0 replies; 18+ messages in thread
From: David Miller @ 2019-07-08  2:23 UTC (permalink / raw)
  To: joe; +Cc: linux-kernel, netdev

From: Joe Perches <joe@perches.com>
Date: Thu,  4 Jul 2019 16:57:46 -0700

> Probable cut&paste typo - use the correct field size.
> 
> Signed-off-by: Joe Perches <joe@perches.com>

Applied.

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 8/8] nfsd: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 8/8] nfsd: Fix misuse " Joe Perches
@ 2019-07-09  3:14   ` J. Bruce Fields
  2019-07-09  5:40     ` Joe Perches
  0 siblings, 1 reply; 18+ messages in thread
From: J. Bruce Fields @ 2019-07-09  3:14 UTC (permalink / raw)
  To: Joe Perches; +Cc: Chuck Lever, linux-nfs, linux-kernel

On Thu, Jul 04, 2019 at 04:57:48PM -0700, Joe Perches wrote:
> Probable cut&paste typo - use the correct field size.

Huh, that's been there forever, I wonder why we haven't seen crashes?
Oh, I see, name and authname both have the same size.

Anyway, makes sense, thanks.  Will apply for 5.3.

(Unless someone else is getting this; I didn't get copied on the rest of
the series.)

--b.

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  fs/nfsd/nfs4idmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/nfsd/nfs4idmap.c b/fs/nfsd/nfs4idmap.c
> index 2961016097ac..d1f285245af8 100644
> --- a/fs/nfsd/nfs4idmap.c
> +++ b/fs/nfsd/nfs4idmap.c
> @@ -83,7 +83,7 @@ ent_init(struct cache_head *cnew, struct cache_head *citm)
>  	new->type = itm->type;
>  
>  	strlcpy(new->name, itm->name, sizeof(new->name));
> -	strlcpy(new->authname, itm->authname, sizeof(new->name));
> +	strlcpy(new->authname, itm->authname, sizeof(new->authname));
>  }
>  
>  static void
> -- 
> 2.15.0

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 8/8] nfsd: Fix misuse of strlcpy
  2019-07-09  3:14   ` J. Bruce Fields
@ 2019-07-09  5:40     ` Joe Perches
  2019-07-09 23:33       ` J. Bruce Fields
  0 siblings, 1 reply; 18+ messages in thread
From: Joe Perches @ 2019-07-09  5:40 UTC (permalink / raw)
  To: J. Bruce Fields; +Cc: Chuck Lever, linux-nfs, linux-kernel

On Mon, 2019-07-08 at 23:14 -0400, J. Bruce Fields wrote:
> On Thu, Jul 04, 2019 at 04:57:48PM -0700, Joe Perches wrote:
> > Probable cut&paste typo - use the correct field size.
> 
> Huh, that's been there forever, I wonder why we haven't seen crashes?
> Oh, I see, name and authname both have the same size.
> 
> Anyway, makes sense, thanks.  Will apply for 5.3.
> 
> (Unless someone else is getting this; I didn't get copied on the rest of
> the series.)

It's generally hard to cc everyone on treewide fixes like this.

There's no good mechanism I know of.
vger mailing lists reject emails with too many addressees.

Do you have an opinion on adding the stracpy macro which
could avoid many of these defects?

---
 include/linux/string.h | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/include/linux/string.h b/include/linux/string.h
index 4deb11f7976b..ef01bd6f19df 100644
--- a/include/linux/string.h
+++ b/include/linux/string.h
@@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
 /* Wraps calls to strscpy()/memset(), no arch specific code required */
 ssize_t strscpy_pad(char *dest, const char *src, size_t count);
 
+#define stracpy(to, from)					\
+({								\
+	size_t size = ARRAY_SIZE(to);				\
+	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
+								\
+	strscpy(to, from, size);				\
+})
+
+#define stracpy_pad(to, from)					\
+({								\
+	size_t size = ARRAY_SIZE(to);				\
+	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
+								\
+	strscpy_pad(to, from, size);				\
+})
+
 #ifndef __HAVE_ARCH_STRCAT
 extern char * strcat(char *, const char *);
 #endif




^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 8/8] nfsd: Fix misuse of strlcpy
  2019-07-09  5:40     ` Joe Perches
@ 2019-07-09 23:33       ` J. Bruce Fields
  0 siblings, 0 replies; 18+ messages in thread
From: J. Bruce Fields @ 2019-07-09 23:33 UTC (permalink / raw)
  To: Joe Perches; +Cc: Chuck Lever, linux-nfs, linux-kernel

On Mon, Jul 08, 2019 at 10:40:50PM -0700, Joe Perches wrote:
> On Mon, 2019-07-08 at 23:14 -0400, J. Bruce Fields wrote:
> > On Thu, Jul 04, 2019 at 04:57:48PM -0700, Joe Perches wrote:
> > > Probable cut&paste typo - use the correct field size.
> > 
> > Huh, that's been there forever, I wonder why we haven't seen crashes?
> > Oh, I see, name and authname both have the same size.
> > 
> > Anyway, makes sense, thanks.  Will apply for 5.3.
> > 
> > (Unless someone else is getting this; I didn't get copied on the rest of
> > the series.)
> 
> It's generally hard to cc everyone on treewide fixes like this.
> 
> There's no good mechanism I know of.
> vger mailing lists reject emails with too many addressees.

Yeah.  I guess what I don't understand is why this patch is part of a
series at all.  It makes me wonder if there's some dependency I missed
or if the 0/8 mail actually asked somebody else to apply it.

Whatever, I guess I'm being silly, it clearly stands alone.  Applying
for 5.3.

> Do you have an opinion on adding the stracpy macro which
> could avoid many of these defects?

I don't have an opinion.

--b.


> ---
>  include/linux/string.h | 16 ++++++++++++++++
>  1 file changed, 16 insertions(+)
> 
> diff --git a/include/linux/string.h b/include/linux/string.h
> index 4deb11f7976b..ef01bd6f19df 100644
> --- a/include/linux/string.h
> +++ b/include/linux/string.h
> @@ -35,6 +35,22 @@ ssize_t strscpy(char *, const char *, size_t);
>  /* Wraps calls to strscpy()/memset(), no arch specific code required */
>  ssize_t strscpy_pad(char *dest, const char *src, size_t count);
>  
> +#define stracpy(to, from)					\
> +({								\
> +	size_t size = ARRAY_SIZE(to);				\
> +	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
> +								\
> +	strscpy(to, from, size);				\
> +})
> +
> +#define stracpy_pad(to, from)					\
> +({								\
> +	size_t size = ARRAY_SIZE(to);				\
> +	BUILD_BUG_ON(!__same_type(typeof(*to), char));		\
> +								\
> +	strscpy_pad(to, from, size);				\
> +})
> +
>  #ifndef __HAVE_ARCH_STRCAT
>  extern char * strcat(char *, const char *);
>  #endif
> 
> 

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
@ 2019-07-14 18:29   ` Dmitry Torokhov
  0 siblings, 0 replies; 18+ messages in thread
From: Dmitry Torokhov @ 2019-07-14 18:29 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel, linux-input

On Thu, Jul 04, 2019 at 04:57:41PM -0700, Joe Perches wrote:
> Probable cut&paste typo - use the correct field size.

Applied, thank you.

Luckily both sizes (name and phys) are the same, so we need not to have
this in any of the stables.

> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/input/mouse/synaptics.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/input/mouse/synaptics.c b/drivers/input/mouse/synaptics.c
> index 1080c0c49815..00a0cf14f27f 100644
> --- a/drivers/input/mouse/synaptics.c
> +++ b/drivers/input/mouse/synaptics.c
> @@ -705,7 +705,7 @@ static void synaptics_pt_create(struct psmouse *psmouse)
>  
>  	serio->id.type = SERIO_PS_PSTHRU;
>  	strlcpy(serio->name, "Synaptics pass-through", sizeof(serio->name));
> -	strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->name));
> +	strlcpy(serio->phys, "synaptics-pt/serio0", sizeof(serio->phys));
>  	serio->write = synaptics_pt_write;
>  	serio->start = synaptics_pt_start;
>  	serio->stop = synaptics_pt_stop;
> -- 
> 2.15.0
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 18+ messages in thread

* Re: [PATCH 2/8] leds: as3645a: Fix misuse of strlcpy
  2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
  2019-07-05  7:33   ` Sakari Ailus
  2019-07-05 20:23   ` Pavel Machek
@ 2019-07-15 18:29   ` Jacek Anaszewski
  2 siblings, 0 replies; 18+ messages in thread
From: Jacek Anaszewski @ 2019-07-15 18:29 UTC (permalink / raw)
  To: Joe Perches, Sakari Ailus, Pavel Machek, Dan Murphy
  Cc: linux-leds, linux-kernel

Hi Joe,

Thank you for the patch.

On 7/5/19 1:57 AM, Joe Perches wrote:
> Probable cut&paste typo - use the correct field size.
> 
> Signed-off-by: Joe Perches <joe@perches.com>
> ---
>  drivers/leds/leds-as3645a.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-as3645a.c b/drivers/leds/leds-as3645a.c
> index 14ab6b0e4de9..050088dff8dd 100644
> --- a/drivers/leds/leds-as3645a.c
> +++ b/drivers/leds/leds-as3645a.c
> @@ -668,7 +668,7 @@ static int as3645a_v4l2_setup(struct as3645a *flash)
>  	};
>  
>  	strlcpy(cfg.dev_name, led->name, sizeof(cfg.dev_name));
> -	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfg.dev_name));
> +	strlcpy(cfgind.dev_name, flash->iled_cdev.name, sizeof(cfgind.dev_name));
>  
>  	flash->vf = v4l2_flash_init(
>  		&flash->client->dev, flash->flash_node, &flash->fled, NULL,
> 

Applied to for-5.4 branch of linux-leds.git.

-- 
Best regards,
Jacek Anaszewski

^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, back to index

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-04 23:57 [PATCH 0/8] treewide: correct misuses of strscpy/strlcpy Joe Perches
2019-07-04 23:57 ` [PATCH 1/8] Input: synaptics: Fix misuse of strlcpy Joe Perches
2019-07-14 18:29   ` Dmitry Torokhov
2019-07-04 23:57 ` [PATCH 2/8] leds: as3645a: " Joe Perches
2019-07-05  7:33   ` Sakari Ailus
2019-07-05 20:23   ` Pavel Machek
2019-07-15 18:29   ` Jacek Anaszewski
2019-07-04 23:57 ` [PATCH 3/8] media: m2m-deinterlace: Fix misuse of strscpy Joe Perches
2019-07-04 23:57 ` [PATCH 4/8] media: go7007: " Joe Perches
2019-07-04 23:57 ` [PATCH 5/8] net: ethernet: sun4i-emac: Fix misuse of strlcpy Joe Perches
2019-07-08  2:22   ` David Miller
2019-07-04 23:57 ` [PATCH 6/8] net: nixge: " Joe Perches
2019-07-08  2:23   ` David Miller
2019-07-04 23:57 ` [PATCH 7/8] tty: hvcs: Fix odd use " Joe Perches
2019-07-04 23:57 ` [PATCH 8/8] nfsd: Fix misuse " Joe Perches
2019-07-09  3:14   ` J. Bruce Fields
2019-07-09  5:40     ` Joe Perches
2019-07-09 23:33       ` J. Bruce Fields

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git
	git clone --mirror https://lore.kernel.org/lkml/8 lkml/git/8.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org
	public-inbox-index lkml

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git