All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
@ 2016-08-24 16:10 Robert LeBlanc
  2016-08-25  7:44 ` Shaun Tancheff
  2016-08-25 17:45 ` Jes Sorensen
  0 siblings, 2 replies; 4+ messages in thread
From: Robert LeBlanc @ 2016-08-24 16:10 UTC (permalink / raw)
  To: linux-raid; +Cc: dm-devel, robert

Linux allows for 32 character device names. When using the maximum size device name and also
storing "/dev/", devname needs to be 37 character long to store the complete device name.
i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"

Signed-Off: Robert LeBlanc<robert@leblancnet.us>
---
 mdopen.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mdopen.c b/mdopen.c
index f818fdf..5af344b 100644
--- a/mdopen.c
+++ b/mdopen.c
@@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
 	struct createinfo *ci = conf_get_create_info();
 	int parts;
 	char *cname;
-	char devname[20];
+	char devname[37];
 	char devnm[32];
 	char cbuf[400];
 	if (chosen == NULL)
-- 
2.9.3


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

* Re: [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
  2016-08-24 16:10 [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names Robert LeBlanc
@ 2016-08-25  7:44 ` Shaun Tancheff
  2016-08-25  7:52   ` [dm-devel] " Shaun Tancheff
  2016-08-25 17:45 ` Jes Sorensen
  1 sibling, 1 reply; 4+ messages in thread
From: Shaun Tancheff @ 2016-08-25  7:44 UTC (permalink / raw)
  To: Robert LeBlanc; +Cc: linux-raid, dm-devel

On Wed, Aug 24, 2016 at 11:10 AM, Robert LeBlanc <robert@leblancnet.us> wrote:
> Linux allows for 32 character device names. When using the maximum size device name and also
> storing "/dev/", devname needs to be 37 character long to store the complete device name.
> i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"
>
> Signed-Off: Robert LeBlanc<robert@leblancnet.us>
> ---
>  mdopen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mdopen.c b/mdopen.c
> index f818fdf..5af344b 100644
> --- a/mdopen.c
> +++ b/mdopen.c
> @@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
>         struct createinfo *ci = conf_get_create_info();
>         int parts;
>         char *cname;
> -       char devname[20];
> +       char devname[37];

I think you want 38 here.
   5 + 32 + '\0'.

>         char devnm[32];
>         char cbuf[400];
>         if (chosen == NULL)
> --
> 2.9.3
>

Also a sprintf() to snprintf() cleanup might not be a bad idea ..
-- 
Shaun Tancheff

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

* Re: [dm-devel] [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
  2016-08-25  7:44 ` Shaun Tancheff
@ 2016-08-25  7:52   ` Shaun Tancheff
  0 siblings, 0 replies; 4+ messages in thread
From: Shaun Tancheff @ 2016-08-25  7:52 UTC (permalink / raw)
  To: Robert LeBlanc; +Cc: linux-raid, dm-devel

On Thu, Aug 25, 2016 at 2:44 AM, Shaun Tancheff
<shaun.tancheff@seagate.com> wrote:
> On Wed, Aug 24, 2016 at 11:10 AM, Robert LeBlanc <robert@leblancnet.us> wrote:
>> Linux allows for 32 character device names. When using the maximum size device name and also
>> storing "/dev/", devname needs to be 37 character long to store the complete device name.
>> i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"
>>
>> Signed-Off: Robert LeBlanc<robert@leblancnet.us>
>> ---
>>  mdopen.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/mdopen.c b/mdopen.c
>> index f818fdf..5af344b 100644
>> --- a/mdopen.c
>> +++ b/mdopen.c
>> @@ -144,7 +144,7 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
>>         struct createinfo *ci = conf_get_create_info();
>>         int parts;
>>         char *cname;
>> -       char devname[20];
>> +       char devname[37];
>
> I think you want 38 here.
>    5 + 32 + '\0'.

>>         char devnm[32];

Ah sorry, that 32 was including the null already
implied by devnm.

Looks fine.

>>         char cbuf[400];
>>         if (chosen == NULL)
>> --
>> 2.9.3
>>
>
> Also a sprintf() to snprintf() cleanup might not be a bad idea ..
> --
> Shaun Tancheff



-- 
Shaun Tancheff

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

* Re: [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names.
  2016-08-24 16:10 [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names Robert LeBlanc
  2016-08-25  7:44 ` Shaun Tancheff
@ 2016-08-25 17:45 ` Jes Sorensen
  1 sibling, 0 replies; 4+ messages in thread
From: Jes Sorensen @ 2016-08-25 17:45 UTC (permalink / raw)
  To: Robert LeBlanc; +Cc: linux-raid, dm-devel

Robert LeBlanc <robert@leblancnet.us> writes:
> Linux allows for 32 character device names. When using the maximum size device name and also
> storing "/dev/", devname needs to be 37 character long to store the complete device name.
> i.e. "/dev/md_abcdefghijklmnopqrstuvwxyz12\0"
>
> Signed-Off: Robert LeBlanc<robert@leblancnet.us>
> ---
>  mdopen.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)

Looks good - I corrected your comment to fit into a proper editor width
of 80 characters, and also fixed up the SOB since it needs to say
Signed-off-by rather than signed-off.

Applied!
Jes

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

end of thread, other threads:[~2016-08-25 17:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-24 16:10 [PATCH v2] mdopen: Prevent overrunning the devname buffer when copying devnm into it for long md names Robert LeBlanc
2016-08-25  7:44 ` Shaun Tancheff
2016-08-25  7:52   ` [dm-devel] " Shaun Tancheff
2016-08-25 17:45 ` Jes Sorensen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.