Linux wireless drivers development
 help / color / mirror / Atom feed
From: Denis Kenzior <denkenz@gmail.com>
To: Johannes Berg <johannes@sipsolutions.net>
Cc: linux-wireless@vger.kernel.org
Subject: Re: [PATCH v3 2/3] nl80211: Limit certain commands to interface owner
Date: Wed, 31 Jul 2019 05:30:25 -0500	[thread overview]
Message-ID: <f0374da3-bc78-d0d9-8af7-64391d5bb702@gmail.com> (raw)
In-Reply-To: <bcb31ffae5b916d319bd25a34432026df61fc6f0.camel@sipsolutions.net>

Hi Johannnes,

On 7/31/19 4:51 AM, Johannes Berg wrote:
> On Mon, 2019-07-01 at 10:33 -0500, Denis Kenzior wrote:
>> If the wdev object has been created (via NEW_INTERFACE) with
>> SOCKET_OWNER attribute set, then limit certain commands only to the
>> process that created that wdev.
>>
>> This can be used to make sure no other process on the system interferes
>> by sending unwanted scans, action frames or any other funny business.
>>
>> This patch introduces a new internal flag, and checks that flag in the
>> pre_doit hook.
> 
> So, looking at this ...
> 
> I can't say I'm convinced. You're tagging 35 out of about 106 commands,
> and even if a handful of those are new and were added after your patch,
> this doesn't really make sense.
> 
> NL80211_CMD_LEAVE_IBSS is tagged, but not NL80211_CMD_LEAVE_MESH?
> NL80211_CMD_NEW_STATION is tagged, but not NL80211_CMD_NEW_MPATH?
> NL80211_CMD_SET_KEY is tagged, but not NL80211_CMD_SET_PMK or
> NL80211_CMD_SET_PMKSA?
> NL80211_CMD_UPDATE_CONNECT_PARAMS is tagged, but not
> NL80211_CMD_UPDATE_OWE_INFO (though this could be patch crossing?)
> 
> NL80211_CMD_CONTROL_PORT_FRAME isn't tagged?

So for some of these I was planning to submit a patch to check that the 
request comes from the SOCKET_OWNER for the connection itself.  E.g. it 
makes no sense to accept CONTROL_PORT_FRAME from a process that didn't 
issue the CMD_CONNECT.  Same applies for some of the offload commands. 
But I can include these in this list as well if you prefer.

For others, it was pure ignorance as to what the commands do.  E.g. we 
haven't looked into Mesh at all.  So if you want to suggest which 
commands should be included, I'm happy to add these.

> 
> NL80211_CMD_SET_QOS_MAP isn't tagged?
> 
> It almost feels like you just did a "git grep NL80211_CMD_" on your
> code, and then dropped the flag on everything you were using.
> 
> And honestly, I think you need a better justification than just
> "unwanted scans, action frames or any other funny business".
> 

We have a limited resource that we are managing in userspace.  We can't 
just have any random process coming in and messing with that resource. 
So either the userspace daemon should do it or the kernel.  Right now it 
is just pure chaos...

And really, in the end, how is this different from SOCKET_OWNER for 
CMD_CONNECT?  It is optional in the end, so if you don't want to use it, 
don't?

> Also, how's this not just a workaround for some very specific setup
> issue you were seeing, where people trying out iwd didn't remove wpa_s
> properly (*)? I'm really not convinced that this buys us anything except
> in very limited development scenarios - and those are typically the
> exact scenarios where you _want_ to be able to do things like that (and
> honestly, I'd be pretty pissed off if I couldn't do an "iw wlan0 scan"
> just because some tool decided it wanted to have control over things).

I understand where you're coming from, but you're just one user who can 
disable this behavior anyway if you really cared.  For 99.9% of the 
users this is never going to be a problem.  And I'd rather cater to the 
99%...

> 
> (*) also, that would just happen to work for you now with iwd winning
> because you claim ownership and wpa_s doesn't, you'd still get the same
> complaints "iwd doesn't work" if/when wpa_s *does* start to claim
> ownership and you get locked out with a patch like this, so I don't feel
> you'd actually win much even in this case.
> 

This is in no way the motivation for this.  wpa_s or iwd winning is a 
distro/user configuration problem.  I don't care about that now. 
Besides, this was mostly taken care of by the SOCKET_OWNER set on 
CMD_CONNECT...

> 
> I'm trying to come up with places where we do something similar, defend
> one application running as root against another ... but can't really?
> Think about VPN - we don't stop anying from removing or adding IP
> addresses that the VPN application didn't intend to use, yet that can
> obviously break your connection. You could even run dhcp on it, even if
> for (most) VPN protocols that's rather useless.

File locking would be one example.  Systemd can and does all kinds of 
fun stuff (e.g. locking a process out from twiddling rfkill).  LSM 
modules can do just about everything.  I think there are plenty of examples.

But really, a lot of this works just because various processes play 
'nice' and stay out of each other's way.  Also, as you point out, most 
things aren't done because they don't make sense.

But with nl80211 this isn't the case.  Many processes would be tempted 
to start an operation or get some info out of nl80211 directly.  So this 
patch tries to narrow down what they can use, e.g. informational-only 
commands are fine.  Anything that can affect state is not fine.

> 
> Overall, I'm not really convinced. The design is rather unclear
> (randomly sprinkling magic dust on ~35% of commands), and it's also not
> really clear to me what this is intended to actually achieve.
> 

You may want to refer to the thread between Arend & Marcel (started by 
an earlier version of this patchset).

I really don't see how giving the userspace management daemon (which by 
definition has exclusive control) a way from locking out a random 
process from starting a potentially disruptive operation is 
'unconvincing.'  As a developer you will hate this of course, and that 
is to be expected.  But look at it from a user POV.

Regards,
-Denis

  reply	other threads:[~2019-07-31 10:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-01 15:33 [PATCH v3 1/3] nl80211: Update uapi for CMD_FRAME_WAIT_CANCEL Denis Kenzior
2019-07-01 15:33 ` [PATCH v3 2/3] nl80211: Limit certain commands to interface owner Denis Kenzior
2019-07-18  8:24   ` Arend Van Spriel
2019-07-22 11:32     ` Denis Kenzior
2019-07-31  9:51   ` Johannes Berg
2019-07-31 10:30     ` Denis Kenzior [this message]
2019-07-01 15:33 ` [PATCH v3 3/3] nl80211: Include wiphy address setup in NEW_WIPHY Denis Kenzior
2019-07-09 15:27 ` [PATCH v3 1/3] nl80211: Update uapi for CMD_FRAME_WAIT_CANCEL Denis Kenzior

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=f0374da3-bc78-d0d9-8af7-64391d5bb702@gmail.com \
    --to=denkenz@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox