Re: [PATCH 1/9] rtl8192*: display ESSIDs using %pE

2019-09-06 Thread Kees Cook
On Fri, Sep 06, 2019 at 12:38:29PM +0300, Andy Shevchenko wrote:
> On Thu, Sep 05, 2019 at 01:53:43PM -0700, Kees Cook wrote:
> > On Thu, Sep 05, 2019 at 03:44:25PM -0400, J. Bruce Fields wrote:
> > > From: "J. Bruce Fields" 
> > > 
> > > Everywhere else in the kernel ESSIDs are printed using %pE, and I can't
> > > see why there should be an exception here.
> > 
> > I would expand this rationale slightly: using "n" here makes no sense
> > because they are already NUL-terminated strings. The "n" modifier could
> > only be used with string_escape_mem() which takes a "length" argument.
> 
> SSID may have NUL in any location in the name.

Oops, you're totally right: I forgot the "*" part here. Ignore my
comment. :)

So, instead, this "upgrades" the escaping from "only NULL" to all the
unprintables.

> 
> > > - snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> > > + snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
> 
> > > - snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> > > + snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
> 
> -- 
> With Best Regards,
> Andy Shevchenko
> 
> 

-- 
Kees Cook


Re: [PATCH 1/9] rtl8192*: display ESSIDs using %pE

2019-09-06 Thread Andy Shevchenko
On Thu, Sep 05, 2019 at 01:53:43PM -0700, Kees Cook wrote:
> On Thu, Sep 05, 2019 at 03:44:25PM -0400, J. Bruce Fields wrote:
> > From: "J. Bruce Fields" 
> > 
> > Everywhere else in the kernel ESSIDs are printed using %pE, and I can't
> > see why there should be an exception here.
> 
> I would expand this rationale slightly: using "n" here makes no sense
> because they are already NUL-terminated strings. The "n" modifier could
> only be used with string_escape_mem() which takes a "length" argument.

SSID may have NUL in any location in the name.

> > -   snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> > +   snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);

> > -   snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> > +   snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);

-- 
With Best Regards,
Andy Shevchenko




Re: [PATCH 1/9] rtl8192*: display ESSIDs using %pE

2019-09-05 Thread Kees Cook
On Thu, Sep 05, 2019 at 03:44:25PM -0400, J. Bruce Fields wrote:
> From: "J. Bruce Fields" 
> 
> Everywhere else in the kernel ESSIDs are printed using %pE, and I can't
> see why there should be an exception here.

I would expand this rationale slightly: using "n" here makes no sense
because they are already NUL-terminated strings. The "n" modifier could
only be used with string_escape_mem() which takes a "length" argument.

Regardless:

Acked-by: Kees Cook 

-Kees

> 
> Signed-off-by: J. Bruce Fields 
> ---
>  drivers/staging/rtl8192e/rtllib.h  | 2 +-
>  drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/staging/rtl8192e/rtllib.h 
> b/drivers/staging/rtl8192e/rtllib.h
> index 2dd57e88276e..096254e422b3 100644
> --- a/drivers/staging/rtl8192e/rtllib.h
> +++ b/drivers/staging/rtl8192e/rtllib.h
> @@ -2132,7 +2132,7 @@ static inline const char *escape_essid(const char 
> *essid, u8 essid_len)
>   return escaped;
>   }
>  
> - snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> + snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
>   return escaped;
>  }
>  
> diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
> b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
> index d36963469015..3963a08b9eb2 100644
> --- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
> +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
> @@ -2426,7 +2426,7 @@ static inline const char *escape_essid(const char 
> *essid, u8 essid_len)
>   return escaped;
>   }
>  
> - snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
> + snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
>   return escaped;
>  }
>  
> -- 
> 2.21.0
> 

-- 
Kees Cook


[PATCH 1/9] rtl8192*: display ESSIDs using %pE

2019-09-05 Thread J. Bruce Fields
From: "J. Bruce Fields" 

Everywhere else in the kernel ESSIDs are printed using %pE, and I can't
see why there should be an exception here.

Signed-off-by: J. Bruce Fields 
---
 drivers/staging/rtl8192e/rtllib.h  | 2 +-
 drivers/staging/rtl8192u/ieee80211/ieee80211.h | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/rtl8192e/rtllib.h 
b/drivers/staging/rtl8192e/rtllib.h
index 2dd57e88276e..096254e422b3 100644
--- a/drivers/staging/rtl8192e/rtllib.h
+++ b/drivers/staging/rtl8192e/rtllib.h
@@ -2132,7 +2132,7 @@ static inline const char *escape_essid(const char *essid, 
u8 essid_len)
return escaped;
}
 
-   snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
+   snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
return escaped;
 }
 
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211.h 
b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
index d36963469015..3963a08b9eb2 100644
--- a/drivers/staging/rtl8192u/ieee80211/ieee80211.h
+++ b/drivers/staging/rtl8192u/ieee80211/ieee80211.h
@@ -2426,7 +2426,7 @@ static inline const char *escape_essid(const char *essid, 
u8 essid_len)
return escaped;
}
 
-   snprintf(escaped, sizeof(escaped), "%*pEn", essid_len, essid);
+   snprintf(escaped, sizeof(escaped), "%*pE", essid_len, essid);
return escaped;
 }
 
-- 
2.21.0