All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mac80211: Fix the buffer length in debugfs for smps
@ 2014-01-04 21:06 Chaitanya T K
  2014-01-06 14:48 ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Chaitanya T K @ 2014-01-04 21:06 UTC (permalink / raw)
  To: johannes, linux-wireless; +Cc: Chaitanya T K

This was blocking sending SMPS action frames 
through debugfs.

Signed-off-by: Chaitanya T K <chaitanya.mgit@gmail.com>
---
 net/mac80211/debugfs_netdev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/net/mac80211/debugfs_netdev.c b/net/mac80211/debugfs_netdev.c
index 04b5a14..1a8fa5f 100644
--- a/net/mac80211/debugfs_netdev.c
+++ b/net/mac80211/debugfs_netdev.c
@@ -265,7 +265,7 @@ static ssize_t ieee80211_if_parse_smps(struct ieee80211_sub_if_data *sdata,
 	enum ieee80211_smps_mode mode;
 
 	for (mode = 0; mode < IEEE80211_SMPS_NUM_MODES; mode++) {
-		if (strncmp(buf, smps_modes[mode], buflen) == 0) {
+		if (strncmp(buf, smps_modes[mode], buflen-1) == 0) {
 			int err = ieee80211_set_smps(sdata, mode);
 			if (!err)
 				return buflen;

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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-04 21:06 [PATCH] mac80211: Fix the buffer length in debugfs for smps Chaitanya T K
@ 2014-01-06 14:48 ` Johannes Berg
  2014-01-06 15:05   ` Krishna Chaitanya
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-01-06 14:48 UTC (permalink / raw)
  To: Chaitanya T K; +Cc: linux-wireless

On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
> This was blocking sending SMPS action frames 
> through debugfs.

I don't see any issue here, explain.

johannes


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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-06 14:48 ` Johannes Berg
@ 2014-01-06 15:05   ` Krishna Chaitanya
  2014-01-06 15:15     ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Krishna Chaitanya @ 2014-01-06 15:05 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Mon, Jan 6, 2014 at 8:18 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
>> This was blocking sending SMPS action frames
>> through debugfs.
>
> I don't see any issue here, explain.
>
> johannes
>
buflen includes the new line character as well, hence the comparison
strncmp fails for all combiantions.

echo "static" > ieee80211/phyX/netdev\:wlanX/smps
Then

buf=static\n
buflen=7

But the comparison is with "static" which doesn't include "\n"
hence the comparison fails.

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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-06 15:05   ` Krishna Chaitanya
@ 2014-01-06 15:15     ` Johannes Berg
  2014-01-06 15:32       ` Krishna Chaitanya
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-01-06 15:15 UTC (permalink / raw)
  To: Krishna Chaitanya; +Cc: linux-wireless

On Mon, 2014-01-06 at 20:35 +0530, Krishna Chaitanya wrote:
> On Mon, Jan 6, 2014 at 8:18 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> > On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
> >> This was blocking sending SMPS action frames
> >> through debugfs.
> >
> > I don't see any issue here, explain.
> >
> > johannes
> >
> buflen includes the new line character as well, hence the comparison
> strncmp fails for all combiantions.
> 
> echo "static" > ieee80211/phyX/netdev\:wlanX/smps
> Then
> 
> buf=static\n
> buflen=7
> 
> But the comparison is with "static" which doesn't include "\n"
> hence the comparison fails.

Err, ok, so you can just do "echo -n static", right?

And then your patch breaks the way it currently works, which is about
the worst you can do.

johannes



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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-06 15:15     ` Johannes Berg
@ 2014-01-06 15:32       ` Krishna Chaitanya
  2014-01-06 15:55         ` Johannes Berg
  0 siblings, 1 reply; 7+ messages in thread
From: Krishna Chaitanya @ 2014-01-06 15:32 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Mon, Jan 6, 2014 at 8:45 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Mon, 2014-01-06 at 20:35 +0530, Krishna Chaitanya wrote:
>> On Mon, Jan 6, 2014 at 8:18 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> > On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
>> >> This was blocking sending SMPS action frames
>> >> through debugfs.
>> >
>> > I don't see any issue here, explain.
>> >
>> > johannes
>> >
>> buflen includes the new line character as well, hence the comparison
>> strncmp fails for all combiantions.
>>
>> echo "static" > ieee80211/phyX/netdev\:wlanX/smps
>> Then
>>
>> buf=static\n
>> buflen=7
>>
>> But the comparison is with "static" which doesn't include "\n"
>> hence the comparison fails.
>
> Err, ok, so you can just do "echo -n static", right?
>
> And then your patch breaks the way it currently works, which is about
> the worst you can do.
>
Ok, if one works other fails.

So instead why cant we use strlen(local_string)
instead of using buflen(remote). That way we can make sure we only
compare the characters we need and leave out the extra ones.

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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-06 15:32       ` Krishna Chaitanya
@ 2014-01-06 15:55         ` Johannes Berg
  2014-01-06 16:46           ` Krishna Chaitanya
  0 siblings, 1 reply; 7+ messages in thread
From: Johannes Berg @ 2014-01-06 15:55 UTC (permalink / raw)
  To: Krishna Chaitanya; +Cc: linux-wireless

On Mon, 2014-01-06 at 21:02 +0530, Krishna Chaitanya wrote:
> On Mon, Jan 6, 2014 at 8:45 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> > On Mon, 2014-01-06 at 20:35 +0530, Krishna Chaitanya wrote:
> >> On Mon, Jan 6, 2014 at 8:18 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> >> > On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
> >> >> This was blocking sending SMPS action frames
> >> >> through debugfs.
> >> >
> >> > I don't see any issue here, explain.
> >> >
> >> > johannes
> >> >
> >> buflen includes the new line character as well, hence the comparison
> >> strncmp fails for all combiantions.
> >>
> >> echo "static" > ieee80211/phyX/netdev\:wlanX/smps
> >> Then
> >>
> >> buf=static\n
> >> buflen=7
> >>
> >> But the comparison is with "static" which doesn't include "\n"
> >> hence the comparison fails.
> >
> > Err, ok, so you can just do "echo -n static", right?
> >
> > And then your patch breaks the way it currently works, which is about
> > the worst you can do.
> >
> Ok, if one works other fails.
> 
> So instead why cant we use strlen(local_string)
> instead of using buflen(remote). That way we can make sure we only
> compare the characters we need and leave out the extra ones.

It wouldn't fix the problem and would introduce a buffer overflow bug.

johannes



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

* Re: [PATCH] mac80211: Fix the buffer length in debugfs for smps
  2014-01-06 15:55         ` Johannes Berg
@ 2014-01-06 16:46           ` Krishna Chaitanya
  0 siblings, 0 replies; 7+ messages in thread
From: Krishna Chaitanya @ 2014-01-06 16:46 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless

On Mon, Jan 6, 2014 at 9:25 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
> On Mon, 2014-01-06 at 21:02 +0530, Krishna Chaitanya wrote:
>> On Mon, Jan 6, 2014 at 8:45 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> > On Mon, 2014-01-06 at 20:35 +0530, Krishna Chaitanya wrote:
>> >> On Mon, Jan 6, 2014 at 8:18 PM, Johannes Berg <johannes@sipsolutions.net> wrote:
>> >> > On Sun, 2014-01-05 at 02:36 +0530, Chaitanya T K wrote:
>> >> >> This was blocking sending SMPS action frames
>> >> >> through debugfs.
>> >> >
>> >> > I don't see any issue here, explain.
>> >> >
>> >> > johannes
>> >> >
>> >> buflen includes the new line character as well, hence the comparison
>> >> strncmp fails for all combiantions.
>> >>
>> >> echo "static" > ieee80211/phyX/netdev\:wlanX/smps
>> >> Then
>> >>
>> >> buf=static\n
>> >> buflen=7
>> >>
>> >> But the comparison is with "static" which doesn't include "\n"
>> >> hence the comparison fails.
>> >
>> > Err, ok, so you can just do "echo -n static", right?
>> >
>> > And then your patch breaks the way it currently works, which is about
>> > the worst you can do.
>> >
>> Ok, if one works other fails.
>>
>> So instead why cant we use strlen(local_string)
>> instead of using buflen(remote). That way we can make sure we only
>> compare the characters we need and leave out the extra ones.
>
> It wouldn't fix the problem and would introduce a buffer overflow bug.
>
We can add some checks to make sure it doesn't overflow, but its not
worth it.

My intention is as most of the users are familiar with "echo" and
not "echo -n", its better to have a solution which works with "echo".

Also if we use buflen-1 and give "echo -n" it still works but problem is
it compares 1 less character.

Anyways either one is fine with me.

Thanks.

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

end of thread, other threads:[~2014-01-06 16:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-04 21:06 [PATCH] mac80211: Fix the buffer length in debugfs for smps Chaitanya T K
2014-01-06 14:48 ` Johannes Berg
2014-01-06 15:05   ` Krishna Chaitanya
2014-01-06 15:15     ` Johannes Berg
2014-01-06 15:32       ` Krishna Chaitanya
2014-01-06 15:55         ` Johannes Berg
2014-01-06 16:46           ` Krishna Chaitanya

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.