2015-07-24 23:36:12

by Kees Cook

[permalink] [raw]
Subject: [PATCH] ntb: avoid format string in dev_set_name

Avoid any chance of format string expansion when calling dev_set_name.

Signed-off-by: Kees Cook <[email protected]>
---
drivers/ntb/ntb.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c
index 23435f2a5486..2e2530743831 100644
--- a/drivers/ntb/ntb.c
+++ b/drivers/ntb/ntb.c
@@ -114,7 +114,7 @@ int ntb_register_device(struct ntb_dev *ntb)
ntb->dev.bus = &ntb_bus;
ntb->dev.parent = &ntb->pdev->dev;
ntb->dev.release = ntb_dev_release;
- dev_set_name(&ntb->dev, pci_name(ntb->pdev));
+ dev_set_name(&ntb->dev, "%s", pci_name(ntb->pdev));

ntb->ctx = NULL;
ntb->ctx_ops = NULL;
--
1.9.1


--
Kees Cook
Chrome OS Security


2015-07-27 19:05:13

by Jon Mason

[permalink] [raw]
Subject: Re: [PATCH] ntb: avoid format string in dev_set_name

On Fri, Jul 24, 2015 at 04:35:59PM -0700, Kees Cook wrote:
> Avoid any chance of format string expansion when calling dev_set_name.

Looks good to me. I'll pull it into my next release.

Thanks,
Jon

>
> Signed-off-by: Kees Cook <[email protected]>
> ---
> drivers/ntb/ntb.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/ntb/ntb.c b/drivers/ntb/ntb.c
> index 23435f2a5486..2e2530743831 100644
> --- a/drivers/ntb/ntb.c
> +++ b/drivers/ntb/ntb.c
> @@ -114,7 +114,7 @@ int ntb_register_device(struct ntb_dev *ntb)
> ntb->dev.bus = &ntb_bus;
> ntb->dev.parent = &ntb->pdev->dev;
> ntb->dev.release = ntb_dev_release;
> - dev_set_name(&ntb->dev, pci_name(ntb->pdev));
> + dev_set_name(&ntb->dev, "%s", pci_name(ntb->pdev));
>
> ntb->ctx = NULL;
> ntb->ctx_ops = NULL;
> --
> 1.9.1
>
>
> --
> Kees Cook
> Chrome OS Security