Skip to contentSkip to conversation

s390/iucv: Fix vargs handling in iucv_alloc_device()

PATCH Superseded Alexandra Winter 4 participants 4 messages Aug 20, 2024 – Aug 24, 2024

Subsystems (4)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Alexandra Winter

author maintainer
#0 lore raw

PATCH v2 1/1 s390/iucv: Fix vargs handling in iucv_alloc_device()

iucv_alloc_device() gets a format string and a varying number of arguments. This is incorrectly forwarded by calling dev_set_name() with the format string and a va_list, while dev_set_name() expects also a varying number of arguments.

Symptoms:
Corrupted iucv device names, which can result in log messages like:
sysfs: cannot create duplicate filename '/devices/iucv/hvc_iucv1827699952'

Fixes 4452e8ef8c36 ("s390/iucv: Provide iucv_alloc_device() / iucv_release_device()")

---
Discussion of v1:

Vasily Gorbik asked me to send this version via the netdev mailing list.

---
 net/iucv/iucv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
net/iucv/iucv.c +3 -1
index 1e42e13ad24e..2e615641a4e5 100644
@@ -86,13 +86,15 @@ struct device *iucv_alloc_device(const struct attribute_group **attrs,
 {
 	struct device *dev;
 	va_list vargs;
+	char buf[20];
 	int rc;
 
 	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
 	if (!dev)
 		goto out_error;
 	va_start(vargs, fmt);
-	rc = dev_set_name(dev, fmt, vargs);
+	vsnprintf(buf, sizeof(buf), fmt, vargs);
+	rc = dev_set_name(dev, buf);
 	va_end(vargs);
 	if (rc)
 		goto out_error;
Signature · 1 line
2.39.3 (Apple Git-146)
Reviewed-by on v2 1/1
#1 lore raw
Quoted 9 lines · Alexandra Winter

iucv_alloc_device() gets a format string and a varying number of arguments. This is incorrectly forwarded by calling dev_set_name() with the format string and a va_list, while dev_set_name() expects also a varying number of arguments.

Symptoms:
Corrupted iucv device names, which can result in log messages like:
sysfs: cannot create duplicate filename '/devices/iucv/hvc_iucv1827699952'

Quoted 7 lines
Fixes 4452e8ef8c36 ("s390/iucv: Provide iucv_alloc_device() / iucv_release_device()")

---
Discussion of v1:

side note: that's nice that you have continued Vasily's series as your own v2

Quoted 15 lines

Vasily Gorbik asked me to send this version via the netdev mailing list.

---
  net/iucv/iucv.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
net/iucv/iucv.c +0 -0
index 1e42e13ad24e..2e615641a4e5 100644
@@ -86,13 +86,15 @@ struct device *iucv_alloc_device(const struct attribute_group **attrs,
  {
  	struct device *dev;
  	va_list vargs;

net/iucv/iucv.c struct device *iucv_alloc_device(const struct attribute_group **attrs, · line 97

Quoted 10 lines
net/iucv/iucv.c +3 -1
+	char buf[20];
  	int rc;
 
  	dev = kzalloc(sizeof(*dev), GFP_KERNEL);
  	if (!dev)
  		goto out_error;
  	va_start(vargs, fmt);
-	rc = dev_set_name(dev, fmt, vargs);
+	vsnprintf(buf, sizeof(buf), fmt, vargs);
+	rc = dev_set_name(dev, buf);

would be good to pass "%s" as fmt to dev_set_name()

otherwise this patch is good for me, so please add my:

Quoted 3 lines
net/iucv/iucv.c +0 -0
  	va_end(vargs);
  	if (rc)
  		goto out_error;
maintainer
#2 lore raw
Quoted 3 lines · On Tue, 20 Aug 2024 13:51:06 +0200 Przemek Kitszel wrote:

net/iucv/iucv.c struct device *iucv_alloc_device(const struct attribute_group **attrs, · line 97

Quoted 1 line
net/iucv/iucv.c +1 -0
+	rc = dev_set_name(dev, buf);  

would be good to pass "%s" as fmt to dev_set_name()

Sounds like a good idea

Signature · 1 line
pw-bot: cr
#3 lore raw
In reply to Alexandra Winter
Quoted 9 lines · Alexandra Winter

iucv_alloc_device() gets a format string and a varying number of arguments. This is incorrectly forwarded by calling dev_set_name() with the format string and a va_list, while dev_set_name() expects also a varying number of arguments.

Symptoms:
Corrupted iucv device names, which can result in log messages like:
sysfs: cannot create duplicate filename '/devices/iucv/hvc_iucv1827699952'

Quoted 5 lines
Fixes 4452e8ef8c36 ("s390/iucv: Provide iucv_alloc_device() / iucv_release_device()")

---

Hi,

This is the friendly patch-bot of Greg Kroah-Hartman. You have sent him a patch that has triggered this response. He used to manually respond to these common problems, but in order to save his sanity (he kept writing the same thing over and over, yet to different people), I was created. Hopefully you will not take offence and will fix the problem in your patch and resubmit it so that it can be accepted into the Linux kernel tree.

You are receiving this message because of the following common error(s) as indicated below:

- You have marked a patch with a "Fixes:" tag for a commit that is in an older released kernel, yet you do not have a cc: stable line in the signed-off-by area at all, which means that the patch will not be applied to any older kernel releases. To properly fix this, please follow the documented rules in the Documentation/process/stable-kernel-rules.rst file for how to resolve this.

If you wish to discuss this problem further, or you have questions about how to resolve this issue, please feel free to respond to this email and Greg will reply once he has dug out from the pending patches received from other developers.

thanks,

greg k-h's patch email bot