Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1273904 > unrolled thread
| Started by | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| First post | 2015-11-20 10:50 +0100 |
| Last post | 2015-11-20 19:40 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] mtip32xx: use formatting capability of kthread_create_on_node Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-11-20 10:50 +0100
Re: [PATCH] mtip32xx: use formatting capability of kthread_create_on_node Jeff Moyer <jmoyer@redhat.com> - 2015-11-20 16:40 +0100
Re: [PATCH] mtip32xx: use formatting capability of kthread_create_on_node Jens Axboe <axboe@fb.com> - 2015-11-20 19:40 +0100
| From | Rasmus Villemoes <linux@rasmusvillemoes.dk> |
|---|---|
| Date | 2015-11-20 10:50 +0100 |
| Subject | [PATCH] mtip32xx: use formatting capability of kthread_create_on_node |
| Message-ID | <qwQum-5rq-13@gated-at.bofh.it> |
kthread_create_on_node takes format+args, so there's no need to do the
pretty-printing in advance. Moreover, "mtip_svc_thd_99" (including its
'\0') only just fits in 16 bytes, so if index could ever go above 99
we'd have a stack buffer overflow.
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
drivers/block/mtip32xx/mtip32xx.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index a28a562f7b7f..3457ac8c03e2 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3810,7 +3810,6 @@ static int mtip_block_initialize(struct driver_data *dd)
sector_t capacity;
unsigned int index = 0;
struct kobject *kobj;
- unsigned char thd_name[16];
if (dd->disk)
goto skip_create_disk; /* hw init done, before rebuild */
@@ -3958,10 +3957,9 @@ skip_create_disk:
}
start_service_thread:
- sprintf(thd_name, "mtip_svc_thd_%02d", index);
dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread,
- dd, dd->numa_node, "%s",
- thd_name);
+ dd, dd->numa_node,
+ "mtip_svc_thd_%02d", index);
if (IS_ERR(dd->mtip_svc_handler)) {
dev_err(&dd->pdev->dev, "service thread failed to start\n");
--
2.6.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Jeff Moyer <jmoyer@redhat.com> |
|---|---|
| Date | 2015-11-20 16:40 +0100 |
| Message-ID | <qwVX4-Bk-19@gated-at.bofh.it> |
| In reply to | #1273904 |
Rasmus Villemoes <linux@rasmusvillemoes.dk> writes:
> kthread_create_on_node takes format+args, so there's no need to do the
> pretty-printing in advance. Moreover, "mtip_svc_thd_99" (including its
> '\0') only just fits in 16 bytes, so if index could ever go above 99
> we'd have a stack buffer overflow.
I don't know of any systems with enough pci slots to expand index
beyond 99. However, the patch looks like a good cleanup to me.
Reviewed-by: Jeff Moyer <jmoyer@redhat.com>
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
> drivers/block/mtip32xx/mtip32xx.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index a28a562f7b7f..3457ac8c03e2 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -3810,7 +3810,6 @@ static int mtip_block_initialize(struct driver_data *dd)
> sector_t capacity;
> unsigned int index = 0;
> struct kobject *kobj;
> - unsigned char thd_name[16];
>
> if (dd->disk)
> goto skip_create_disk; /* hw init done, before rebuild */
> @@ -3958,10 +3957,9 @@ skip_create_disk:
> }
>
> start_service_thread:
> - sprintf(thd_name, "mtip_svc_thd_%02d", index);
> dd->mtip_svc_handler = kthread_create_on_node(mtip_service_thread,
> - dd, dd->numa_node, "%s",
> - thd_name);
> + dd, dd->numa_node,
> + "mtip_svc_thd_%02d", index);
>
> if (IS_ERR(dd->mtip_svc_handler)) {
> dev_err(&dd->pdev->dev, "service thread failed to start\n");
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Jens Axboe <axboe@fb.com> |
|---|---|
| Date | 2015-11-20 19:40 +0100 |
| Subject | Re: [PATCH] mtip32xx: use formatting capability of kthread_create_on_node |
| Message-ID | <qwYLg-2tX-9@gated-at.bofh.it> |
| In reply to | #1273904 |
On 11/20/2015 02:46 AM, Rasmus Villemoes wrote: > kthread_create_on_node takes format+args, so there's no need to do the > pretty-printing in advance. Moreover, "mtip_svc_thd_99" (including its > '\0') only just fits in 16 bytes, so if index could ever go above 99 > we'd have a stack buffer overflow. Applied, thanks. -- Jens Axboe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web