06 Oct, 2019

1 commit


31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license version 2 as
    published by the free software foundation this program is
    distributed in the hope that it will be useful but without any
    warranty without even the implied warranty of merchantability or
    fitness for a particular purpose see the gnu general public license
    for more details

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 655 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Kate Stewart
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070034.575739538@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

28 Apr, 2019

3 commits

  • Add options to strictly validate messages and dump messages,
    sometimes perhaps validating dump messages non-strictly may
    be required, so add an option for that as well.

    Since none of this can really be applied to existing commands,
    set the options everwhere using the following spatch:

    @@
    identifier ops;
    expression X;
    @@
    struct genl_ops ops[] = {
    ...,
    {
    .cmd = X,
    + .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP,
    ...
    },
    ...
    };

    For new commands one should just not copy the .validate 'opt-out'
    flags and thus get strict validation.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • We currently have two levels of strict validation:

    1) liberal (default)
    - undefined (type >= max) & NLA_UNSPEC attributes accepted
    - attribute length >= expected accepted
    - garbage at end of message accepted
    2) strict (opt-in)
    - NLA_UNSPEC attributes accepted
    - attribute length >= expected accepted

    Split out parsing strictness into four different options:
    * TRAILING - check that there's no trailing data after parsing
    attributes (in message or nested)
    * MAXTYPE - reject attrs > max known type
    * UNSPEC - reject attributes with NLA_UNSPEC policy entries
    * STRICT_ATTRS - strictly validate attribute size

    The default for future things should be *everything*.
    The current *_strict() is a combination of TRAILING and MAXTYPE,
    and is renamed to _deprecated_strict().
    The current regular parsing has none of this, and is renamed to
    *_parse_deprecated().

    Additionally it allows us to selectively set one of the new flags
    even on old policies. Notably, the UNSPEC flag could be useful in
    this case, since it can be arranged (by filling in the policy) to
    not be an incompatible userspace ABI change, but would then going
    forward prevent forgetting attribute entries. Similar can apply
    to the POLICY flag.

    We end up with the following renames:
    * nla_parse -> nla_parse_deprecated
    * nla_parse_strict -> nla_parse_deprecated_strict
    * nlmsg_parse -> nlmsg_parse_deprecated
    * nlmsg_parse_strict -> nlmsg_parse_deprecated_strict
    * nla_parse_nested -> nla_parse_nested_deprecated
    * nla_validate_nested -> nla_validate_nested_deprecated

    Using spatch, of course:
    @@
    expression TB, MAX, HEAD, LEN, POL, EXT;
    @@
    -nla_parse(TB, MAX, HEAD, LEN, POL, EXT)
    +nla_parse_deprecated(TB, MAX, HEAD, LEN, POL, EXT)

    @@
    expression NLH, HDRLEN, TB, MAX, POL, EXT;
    @@
    -nlmsg_parse(NLH, HDRLEN, TB, MAX, POL, EXT)
    +nlmsg_parse_deprecated(NLH, HDRLEN, TB, MAX, POL, EXT)

    @@
    expression NLH, HDRLEN, TB, MAX, POL, EXT;
    @@
    -nlmsg_parse_strict(NLH, HDRLEN, TB, MAX, POL, EXT)
    +nlmsg_parse_deprecated_strict(NLH, HDRLEN, TB, MAX, POL, EXT)

    @@
    expression TB, MAX, NLA, POL, EXT;
    @@
    -nla_parse_nested(TB, MAX, NLA, POL, EXT)
    +nla_parse_nested_deprecated(TB, MAX, NLA, POL, EXT)

    @@
    expression START, MAX, POL, EXT;
    @@
    -nla_validate_nested(START, MAX, POL, EXT)
    +nla_validate_nested_deprecated(START, MAX, POL, EXT)

    @@
    expression NLH, HDRLEN, MAX, POL, EXT;
    @@
    -nlmsg_validate(NLH, HDRLEN, MAX, POL, EXT)
    +nlmsg_validate_deprecated(NLH, HDRLEN, MAX, POL, EXT)

    For this patch, don't actually add the strict, non-renamed versions
    yet so that it breaks compile if I get it wrong.

    Also, while at it, make nla_validate and nla_parse go down to a
    common __nla_validate_parse() function to avoid code duplication.

    Ultimately, this allows us to have very strict validation for every
    new caller of nla_parse()/nlmsg_parse() etc as re-introduced in the
    next patch, while existing things will continue to work as is.

    In effect then, this adds fully strict validation for any new command.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Even if the NLA_F_NESTED flag was introduced more than 11 years ago, most
    netlink based interfaces (including recently added ones) are still not
    setting it in kernel generated messages. Without the flag, message parsers
    not aware of attribute semantics (e.g. wireshark dissector or libmnl's
    mnl_nlmsg_fprintf()) cannot recognize nested attributes and won't display
    the structure of their contents.

    Unfortunately we cannot just add the flag everywhere as there may be
    userspace applications which check nlattr::nla_type directly rather than
    through a helper masking out the flags. Therefore the patch renames
    nla_nest_start() to nla_nest_start_noflag() and introduces nla_nest_start()
    as a wrapper adding NLA_F_NESTED. The calls which add NLA_F_NESTED manually
    are rewritten to use nla_nest_start().

    Except for changes in include/net/netlink.h, the patch was generated using
    this semantic patch:

    @@ expression E1, E2; @@
    -nla_nest_start(E1, E2)
    +nla_nest_start_noflag(E1, E2)

    @@ expression E1, E2; @@
    -nla_nest_start_noflag(E1, E2 | NLA_F_NESTED)
    +nla_nest_start(E1, E2)

    Signed-off-by: Michal Kubecek
    Acked-by: Jiri Pirko
    Acked-by: David Ahern
    Signed-off-by: David S. Miller

    Michal Kubecek
     

22 Mar, 2019

1 commit

  • Since maxattr is common, the policy can't really differ sanely,
    so make it common as well.

    The only user that did in fact manage to make a non-common policy
    is taskstats, which has to be really careful about it (since it's
    still using a common maxattr!). This is no longer supported, but
    we can fake it using pre_doit.

    This reduces the size of e.g. nl80211.o (which has lots of commands):

    text data bss dec hex filename
    398745 14323 2240 415308 6564c net/wireless/nl80211.o (before)
    397913 14331 2240 414484 65314 net/wireless/nl80211.o (after)
    --------------------------------
    -832 +8 0 -824

    Which is obviously just 8 bytes for each command, and an added 8
    bytes for the new policy pointer. I'm not sure why the ops list is
    counted as .text though.

    Most of the code transformations were done using the following spatch:
    @ops@
    identifier OPS;
    expression POLICY;
    @@
    struct genl_ops OPS[] = {
    ...,
    {
    - .policy = POLICY,
    },
    ...
    };

    @@
    identifier ops.OPS;
    expression ops.POLICY;
    identifier fam;
    expression M;
    @@
    struct genl_family fam = {
    .ops = OPS,
    .maxattr = M,
    + .policy = POLICY,
    ...
    };

    This also gets rid of devlink_nl_cmd_region_read_dumpit() accessing
    the cb->data as ops, which we want to change in a later genl patch.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

14 Apr, 2017

2 commits

  • This is an add-on to the previous patch that passes the extended ACK
    structure where it's already available by existing genl_info or extack
    function arguments.

    This was done with this spatch (with some manual adjustment of
    indentation):

    @@
    expression A, B, C, D, E;
    identifier fn, info;
    @@
    fn(..., struct genl_info *info, ...) {
    ...
    -nlmsg_parse(A, B, C, D, E, NULL)
    +nlmsg_parse(A, B, C, D, E, info->extack)
    ...
    }

    @@
    expression A, B, C, D, E;
    identifier fn, info;
    @@
    fn(..., struct genl_info *info, ...) {
    extack)
    ...>
    }

    @@
    expression A, B, C, D, E;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    @@
    expression A, B, C, D, E;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    @@
    expression A, B, C, D, E;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {
    ...
    -nlmsg_parse(A, B, C, D, E, NULL)
    +nlmsg_parse(A, B, C, D, E, extack)
    ...
    }

    @@
    expression A, B, C, D;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    @@
    expression A, B, C, D;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    @@
    expression A, B, C, D;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    @@
    expression A, B, C;
    identifier fn, extack;
    @@
    fn(..., struct netlink_ext_ack *extack, ...) {

    }

    Signed-off-by: Johannes Berg
    Reviewed-by: Jiri Pirko
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Pass the new extended ACK reporting struct to all of the generic
    netlink parsing functions. For now, pass NULL in almost all callers
    (except for some in the core.)

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

28 Oct, 2016

4 commits

  • Now genl_register_family() is the only thing (other than the
    users themselves, perhaps, but I didn't find any doing that)
    writing to the family struct.

    In all families that I found, genl_register_family() is only
    called from __init functions (some indirectly, in which case
    I've add __init annotations to clarifly things), so all can
    actually be marked __ro_after_init.

    This protects the data structure from accidental corruption.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Instead of providing macros/inline functions to initialize
    the families, make all users initialize them statically and
    get rid of the macros.

    This reduces the kernel code size by about 1.6k on x86-64
    (with allyesconfig).

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • Static family IDs have never really been used, the only
    use case was the workaround I introduced for those users
    that assumed their family ID was also their multicast
    group ID.

    Additionally, because static family IDs would never be
    reserved by the generic netlink code, using a relatively
    low ID would only work for built-in families that can be
    registered immediately after generic netlink is started,
    which is basically only the control family (apart from
    the workaround code, which I also had to add code for so
    it would reserve those IDs)

    Thus, anything other than GENL_ID_GENERATE is flawed and
    luckily not used except in the cases I mentioned. Move
    those workarounds into a few lines of code, and then get
    rid of GENL_ID_GENERATE entirely, making it more robust.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     
  • This helper function allows family implementations to access
    their family's attrbuf. This gets rid of the attrbuf usage
    in families, and also adds locking validation, since it's not
    valid to use the attrbuf with parallel_ops or outside of the
    dumpit callback.

    Signed-off-by: Johannes Berg
    Signed-off-by: David S. Miller

    Johannes Berg
     

08 Jul, 2016

1 commit

  • This patch adds netns support for 802.15.4 subsystem. Most parts are
    copy&pasted from wireless subsystem, it has the identically userspace
    API.

    Cc: Nicolas Dichtel
    Reviewed-by: Stefan Schmidt
    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     

30 May, 2016

1 commit


27 Apr, 2016

1 commit

  • …etooth/bluetooth-next

    Johan Hedberg says:

    ====================
    pull request: bluetooth-next 2016-04-26

    Here's another set of Bluetooth & 802.15.4 patches for the 4.7 kernel:

    - Cleanups & refactoring of ieee802154 & 6lowpan code
    - Security related additions to ieee802154 and mrf24j40 driver
    - Memory corruption fix to Bluetooth 6lowpan code
    - Race condition fix in vhci driver
    - Enhancements to the atusb 802.15.4 driver

    Please let me know if there are any issues pulling. Thanks.
    ====================

    Signed-off-by: David S. Miller <davem@davemloft.net>

    David S. Miller
     

26 Apr, 2016

1 commit


24 Apr, 2016

1 commit


13 Apr, 2016

1 commit

  • The generation of autoconfigured IPv6 link-local addresses starts with a
    notification on interface up.

    To handle autoconfiguration according to RFC 4944 requires pan id and
    short address to generate an autoconfigured link-local address. This
    patch will avoid changing of these link-layer address configuration
    while lowpan interface is up.

    Reviewed-by: Stefan Schmidt
    Signed-off-by: Alexander Aring
    Acked-by: Jukka Rissanen
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     

03 Oct, 2015

1 commit


30 Sep, 2015

2 commits

  • This patch adds support for accessing mac802154 llsec implementation
    over nl802154. I added for a new Kconfig entry to provide this
    functionality CONFIG_IEEE802154_NL802154_EXPERIMENTAL. This interface is
    still in development. It provides to change security parameters and
    add/del/dump entries of security tables. Later we can add also a get to
    get an entry by unique identifier.

    Cc: Phoebe Buckheister
    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch uses the nla_get_le64 function instead of doing a force
    converting to le64.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     

29 Aug, 2015

1 commit

  • So far we handled boolean input by forcing them with !! and assigning
    them into a bool. This allowed userspace to send values > 1 which were
    used as 1. We should be stricter here and return -EINVAL for all but
    0 or 1.

    Signed-off-by: Stefan Schmidt
    Acked-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Stefan Schmidt
     

11 Aug, 2015

1 commit

  • This patch introduce a new mib entry which isn't part of 802.15.4 but
    useful as default behaviour to set the ack request bit or not if we
    don't know if the ack request bit should set. This is currently used for
    stacks like IEEE 802.15.4 6LoWPAN.

    Reviewed-by: Stefan Schmidt
    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     

04 Jun, 2015

1 commit

  • This patch will export the supported commands by the devices
    to the userspace. This will be useful to check if HardMAC
    drivers can support a specific command or not.

    Signed-off-by: Varka Bhadram
    Acked-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Varka Bhadram
     

28 May, 2015

2 commits


27 May, 2015

2 commits


19 May, 2015

8 commits

  • This patch add support to nl802154 to dump all phy capabilities which is
    inside the wpan_phy_supported struct. Also we introduce a new method to
    dumping supported channels. The new method will offer a easier interface
    and has lesser netlink traffic.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch adds capability flags for supported interface types.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch introduce a flag property for the wpan phy structure.
    The current flag settings in ieee802154_hw are accessable in mac802154
    layer only which is okay for flags which indicates MAC handling which
    are done by phy. For real PHY layer settings like cca mode, transmit
    power, cca energy detection level.

    The difference between these flags are that the MAC handling flags are
    only handled in mac802154/HardMac layer e.g. on an interface up. The phy
    settings are direct netlink calls from nl802154 into the driver layer
    and the nl802154 need to have a chance to check if the driver supports
    this handling before sending to the next layer.

    We also check now on PHY flags while dumping and setting pib attributes.
    In comparing with MIB attributes the 802.15.4 gives us an default value
    which we assume when a transceiver implement less functionality. In case
    of MIB settings the nl802154 layer doesn't need to check on the
    ieee802154_hw flags then.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch adds support for phy supported handling for all other already
    existing handling 802.15.4 functionality. We assume now a fully 802.15.4
    complaint transceiver at phy allocation. If a transceiver can support
    802.15.4 default values only, then the values should be overwirtten by
    values the transceiver supports. If the transceiver doesn't set the
    according hardware flags, we assume the 802.15.4 defaults now which
    cannot be changed.

    Signed-off-by: Alexander Aring
    Suggested-by: Phoebe Buckheister
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch introduce the wpan_phy_supported struct for wpan_phy. There
    is currently no way to check if a transceiver can handle IEEE 802.15.4
    complaint values. With this struct we can check before if the
    transceiver supports these values before sending to driver layer.

    Signed-off-by: Alexander Aring
    Suggested-by: Phoebe Buckheister
    Acked-by: Varka Bhadram
    Cc: Alan Ott
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch change the transmit power from s8 to s32. This prepares to store a
    mbm value instead dbm inside the transmit power variable. The old
    interface keep the a s8 dbm value, which should be backward compatibility
    when assign s8 to s32.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch moves the value validation out of softmac layer. We need
    to be sure now that this value is accepted by the transceiver/mac802154 or
    "possible" hardmac drivers before calling rdev-ops.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     
  • This patch cleanups the -EINVAL cases by combining them in one
    condition.

    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Alexander Aring
     

01 May, 2015

1 commit

  • This code is based on commit 6bab2e19c5ffd
    ("cfg80211: pass name_assign_type to rdev_add_virtual_intf()")

    This will expose in sysfs whether the ifname of a IEEE-802.15.4
    device is set by userspace or generated by the kernel.
    We are using two types of name_assign_types
    o NET_NAME_ENUM: Default interface name provided by kernel
    o NET_NAME_USER: Interface name provided by user.

    Signed-off-by: Varka Bhadram
    Signed-off-by: Alexander Aring
    Signed-off-by: Marcel Holtmann

    Varka Bhadram
     

18 Jan, 2015

1 commit

  • Contrary to common expectations for an "int" return, these functions
    return only a positive value -- if used correctly they cannot even
    return 0 because the message header will necessarily be in the skb.

    This makes the very common pattern of

    if (genlmsg_end(...) < 0) { ... }

    be a whole bunch of dead code. Many places also simply do

    return nlmsg_end(...);

    and the caller is expected to deal with it.

    This also commonly (at least for me) causes errors, because it is very
    common to write

    if (my_function(...))
    /* error condition */

    and if my_function() does "return nlmsg_end()" this is of course wrong.

    Additionally, there's not a single place in the kernel that actually
    needs the message length returned, and if anyone needs it later then
    it'll be very easy to just use skb->len there.

    Remove this, and make the functions void. This removes a bunch of dead
    code as described above. The patch adds lines because I did

    - return nlmsg_end(...);
    + nlmsg_end(...);
    + return 0;

    I could have preserved all the function's return values by returning
    skb->len, but instead I've audited all the places calling the affected
    functions and found that none cared. A few places actually compared
    the return value with < 0 with no change in behaviour, so I opted for the more
    efficient version.

    One instance of the error I've made numerous times now is also present
    in net/phonet/pn_netlink.c in the route_dumpit() function - it didn't
    check for
    Signed-off-by: David S. Miller

    Johannes Berg
     

19 Dec, 2014

2 commits