18 Jul, 2009

1 commit


17 Jul, 2009

3 commits


16 Jul, 2009

4 commits

  • When a slab cache uses SLAB_DESTROY_BY_RCU, we must be careful when allocating
    objects, since slab allocator could give a freed object still used by lockless
    readers.

    In particular, nf_conntrack RCU lookups rely on ct->tuplehash[xxx].hnnode.next
    being always valid (ie containing a valid 'nulls' value, or a valid pointer to next
    object in hash chain.)

    kmem_cache_zalloc() setups object with NULL values, but a NULL value is not valid
    for ct->tuplehash[xxx].hnnode.next.

    Fix is to call kmem_cache_alloc() and do the zeroing ourself.

    As spotted by Patrick, we also need to make sure lookup keys are committed to
    memory before setting refcount to 1, or a lockless reader could get a reference
    on the old version of the object. Its key re-check could then pass the barrier.

    Signed-off-by: Eric Dumazet
    Signed-off-by: Patrick McHardy

    Eric Dumazet
     
  • The first argument is the address family, the second one the hook
    number.

    Signed-off-by: Patrick McHardy

    Patrick McHardy
     
  • Add appropriate MODULE_ALIAS() to facilitate autoloading of can protocol drivers

    Signed-off-by: Lothar Wassmann
    Acked-by: Oliver Hartkopp
    Signed-off-by: David S. Miller

    Lothar Waßmann
     
  • Fix a use after free bug in can protocol drivers

    The release functions of the can protocol drivers lack a call to
    sock_orphan() which leads to referencing freed memory under certain
    circumstances.

    This patch fixes a bug reported here:
    https://lists.berlios.de/pipermail/socketcan-users/2009-July/000985.html

    Signed-off-by: Lothar Wassmann
    Acked-by: Oliver Hartkopp
    Signed-off-by: David S. Miller

    Lothar Waßmann
     

15 Jul, 2009

4 commits

  • Wireless extensions have the unfortunate problem that events
    are multicast netlink messages, and are not independent of
    pointer size. Thus, currently 32-bit tasks on 64-bit platforms
    cannot properly receive events and fail with all kinds of
    strange problems, for instance wpa_supplicant never notices
    disassociations, due to the way the 64-bit event looks (to a
    32-bit process), the fact that the address is all zeroes is
    lost, it thinks instead it is 00:00:00:00:01:00.

    The same problem existed with the ioctls, until David Miller
    fixed those some time ago in an heroic effort.

    A different problem caused by this is that we cannot send the
    ASSOCREQIE/ASSOCRESPIE events because sending them causes a
    32-bit wpa_supplicant on a 64-bit system to overwrite its
    internal information, which is worse than it not getting the
    information at all -- so we currently resort to sending a
    custom string event that it then parses. This, however, has a
    severe size limitation we are frequently hitting with modern
    access points; this limitation would can be lifted after this
    patch by sending the correct binary, not custom, event.

    A similar problem apparently happens for some other netlink
    users on x86_64 with 32-bit tasks due to the alignment for
    64-bit quantities.

    In order to fix these problems, I have implemented a way to
    send compat messages to tasks. When sending an event, we send
    the non-compat event data together with a compat event data in
    skb_shinfo(main_skb)->frag_list. Then, when the event is read
    from the socket, the netlink code makes sure to pass out only
    the skb that is compatible with the task. This approach was
    suggested by David Miller, my original approach required
    always sending two skbs but that had various small problems.

    To determine whether compat is needed or not, I have used the
    MSG_CMSG_COMPAT flag, and adjusted the call path for recv and
    recvfrom to include it, even if those calls do not have a cmsg
    parameter.

    I have not solved one small part of the problem, and I don't
    think it is necessary to: if a 32-bit application uses read()
    rather than any form of recvmsg() it will still get the wrong
    (64-bit) event. However, neither do applications actually do
    this, nor would it be a regression.

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

    Johannes Berg
     
  • The current function for sending events first allocates the
    event stream buffer, and then an skb to copy the event stream
    into. This can be done in one go. Also, the current function
    leaks kernel data to userspace in a 4 uninitialised bytes,
    initialise those explicitly. Finally also add a few useful
    comments, as opposed to the current comments.

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

    Johannes Berg
     
  • This makes wireless extensions netns aware. The
    tasklet sending the events is converted to a work
    struct so that we can rtnl_lock() in it.

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

    Johannes Berg
     
  • Fixes two bugs:
    - ToS/DiffServ inheritance was unintentionally activated when using impair fixed ToS values
    - ECN bit was lost during ToS/DiffServ inheritance

    Signed-off-by: Andreas Jaggi
    Signed-off-by: David S. Miller

    Andreas Jaggi
     

14 Jul, 2009

1 commit


13 Jul, 2009

11 commits

  • Remove redundant sched/ in net/Makefile.

    sched/ is contained in previous:
    obj-$(CONFIG_NET) += ethernet/ 802/ sched/ netlink/,
    so the later
    obj-$(CONFIG_NET_SCHED) += sched/
    isn't necessary.

    Signed-off-by: Changli Gao
    ----
    Makefile | 1 -
    1 file changed, 1 deletion(-)
    Signed-off-by: David S. Miller

    Changli Gao
     
  • - validate and forward GSO UDP/IPv6 packets from untrusted sources.
    - do software UFO if the outgoing device doesn't support UFO.

    Signed-off-by: Sridhar Samudrala
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     
  • - move ipv6_select_ident() inline function to ipv6.h and remove the unused
    skb argument

    Signed-off-by: Sridhar Samudrala
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     
  • - fix gso_size setting for ipv6 fragment to be a multiple of 8 bytes.

    Signed-off-by: Sridhar Samudrala
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     
  • - add HW checksum support for outgoing large UDP/IPv6 packets destined for
    a UFO enabled device.

    Signed-off-by: Sridhar Samudrala
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     
  • - validate and forward GSO UDP/IPv4 packets from untrusted sources.
    - do software UFO if the outgoing device doesn't support UFO.

    Signed-off-by: Sridhar Samudrala
    Acked-by: Herbert Xu
    Signed-off-by: David S. Miller

    Sridhar Samudrala
     
  • The function get_net_ns_by_pid(), to get a network
    namespace from a pid_t, will be required in cfg80211
    as well. Therefore, let's move it to net_namespace.c
    and export it. We can't make it a static inline in
    the !NETNS case because it needs to verify that the
    given pid even exists (and return -ESRCH).

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

    Johannes Berg
     
  • This makes generic netlink network namespace aware. No
    generic netlink families except for the controller family
    are made namespace aware, they need to be checked one by
    one and then set the family->netnsok member to true.

    A new function genlmsg_multicast_netns() is introduced to
    allow sending a multicast message in a given namespace,
    for example when it applies to an object that lives in
    that namespace, a new function genlmsg_multicast_allns()
    to send a message to all network namespaces (for objects
    that do not have an associated netns).

    The function genlmsg_multicast() is changed to multicast
    the message in just init_net, which is currently correct
    for all generic netlink families since they only work in
    init_net right now. Some will later want to work in all
    net namespaces because they do not care about the netns
    at all -- those will have to be converted to use one of
    the new functions genlmsg_multicast_allns() or
    genlmsg_multicast_netns() whenever they are made netns
    aware in some way.

    After this patch families can easily decide whether or
    not they should be available in all net namespaces. Many
    genl families us it for objects not related to networking
    and should therefore be available in all namespaces, but
    that will have to be done on a per family basis.

    Note that this doesn't touch on the checkpoint/restart
    problem where network namespaces could be used, genl
    families and multicast groups are numbered globally and
    I see no easy way of changing that, especially since it
    must be possible to multicast to all network namespaces
    for those families that do not care about netns.

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

    Johannes Berg
     
  • All we need to take care of is using proper RCU list
    add/del primitives and inserting a synchronize_rcu()
    at one place to make sure the exit notifiers are run
    after everybody has stopped iterating the list.

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

    Johannes Berg
     
  • For the network namespace work in generic netlink I need
    to be able to call this function under rcu_read_lock(),
    otherwise the locking becomes a nightmare and more locks
    would be needed. Instead, just embed a struct rcu_head
    (actually a struct listeners_rcu_head that also carries
    the pointer to the memory block) into the listeners
    memory so we can use call_rcu() instead of synchronising
    and then freeing. No rcu_barrier() is needed since this
    code cannot be modular.

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

    Johannes Berg
     
  • I added those myself in commits b4ff4f04 and 84659eb5,
    but I see no reason now why they should be exported,
    only generic netlink uses them which cannot be modular.

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

    Johannes Berg
     

12 Jul, 2009

3 commits

  • The sit module makes use of skb->dst in it's xmit function, so since
    93f154b594fe47 ("net: release dst entry in dev_hard_start_xmit()") sit
    tunnels are broken, because the flag IFF_XMIT_DST_RELEASE is not
    unset.

    This patch unsets that flag for sit devices to fix this
    regression.

    Signed-off-by: Sascha Hlusiak
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Sascha Hlusiak
     
  • After commit 2b85a34e911bf483c27cfdd124aeb1605145dc80
    (net: No more expensive sock_hold()/sock_put() on each tx)
    we do not take any more references on sk->sk_refcnt on outgoing packets.

    I forgot to delete two __sock_put() from ip_push_pending_frames()
    and ip6_push_pending_frames().

    Reported-by: Emil S Tantilov
    Signed-off-by: Eric Dumazet
    Tested-by: Emil S Tantilov
    Signed-off-by: David S. Miller

    Eric Dumazet
     
  • Some sockets use SLAB_DESTROY_BY_RCU, and our RCU code correctness
    depends on sk->sk_nulls_node.next being always valid. A NULL
    value is not allowed as it might fault a lockless reader.

    Current sk_prot_alloc() implementation doesnt respect this hypothesis,
    calling kmem_cache_alloc() with __GFP_ZERO. Just call memset() around
    the forbidden field.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Eric Dumazet
     

11 Jul, 2009

13 commits

  • In order to force drivers to advertise their interface
    types, don't just disallow creating new interfaces with
    unadvertised types but also disallow setting them UP.
    Additionally, add some validation on the operations the
    drivers support.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • We've named the registered devices 'drv' sometimes,
    thinking of "driver", which is not what it is, it's
    the internal representation of a wiphy, i.e. a
    device. Let's clean up the naming once and and use
    'rdev' aka 'registered device' everywhere.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • Over time, a lot of locking issues have crept into
    the smarts of cfg80211, so e.g. scan completion can
    race against a new scan, IBSS join can race against
    leaving an IBSS, etc.

    Introduce a new per-interface lock that protects
    most of the per-interface data that we need to keep
    track of, and sprinkle assertions about that lock
    everywhere. Some things now need to be offloaded to
    work structs so that we don't require being able to
    sleep in functions the drivers call. The exception
    to that are the MLME callbacks (rx_auth etc.) that
    currently only mac80211 calls because it was easier
    to do that there instead of in cfg80211, and future
    drivers implementing those calls will, if they ever
    exist, probably need to use a similar scheme like
    mac80211 anyway...

    In order to be able to handle _deauth and _disassoc
    properly, introduce a cookie passed to it that will
    determine locking requirements.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • sparse warns about a number of things, and one of them
    (use_mfp shadowed variable) actually is a bug, fix all
    of them.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • Currently we call that cfg80211_put_dev(), but that is
    misleading. With the new convention of using 'rdev' for
    registered_device variables, also call that function
    cfg80211_unlock_rdev().

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • The original code in mac80211 could send a deauth
    frame under certain circumstances even if nothing
    had ever requested an authentication. This has been
    fixed with the rework there, so cfg80211 can now
    warn again about spurious events to catch possible
    future drivers or mac80211 regressions.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • After the mac80211 mlme cleanup, we can require that
    the MLME functions in cfg80211 can sleep. This will
    simplify future work in cfg80211 a lot.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • We shouldn't be looking at the ssid_len for non-IBSS,
    and for IBSS we should also return an error on trying
    to leave an IBSS while not in or joining an IBSS.

    This fixes an issue where we wouldn't disconnect() on
    an interface being taken down since there's no SSID
    configured this way.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • The new key work for cfg80211 will only give us the WEP
    key for shared auth to do that authentication, and not
    via the regular key settings, so we need to be able to
    encrypt a single frame in software, and that without a
    key struct. Thus, refactor the WEP code to not require
    a key structure but use the key, len and idx directly.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • Sit tight. This shakes up the world as you know
    it. Let go of your spaghetti tongs, they will no
    longer be required, the horrible statemachine in
    net/mac80211/mlme.c is no more...

    With the cfg80211 SME mac80211 now has much less
    to keep track of, but, on the other hand, for FT
    it needs to be able to keep track of at least one
    authentication being in progress while associated.
    So convert from a single state machine to having
    small ones for all the different things we need to
    do. For real FT it will still need work wrt. PS,
    but this should be a good step.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • The ap_capab and last_probe struct members are unused.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • Since we don't really know that well in the kernel,
    let's let the SME control whether it wants to use
    reassociation or not, by allowing it to give the
    previous BSSID in the associate() parameters.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg
     
  • We've designed the /dev/rfkill API in a way that we
    can increase the event struct by adding members at
    the end, should it become necessary. To validate the
    events, userspace and the kernel need to have the
    proper event size to check for -- when reading from
    the other end they need to verify that it's at least
    version 1 of the event API, with the current struct
    size, so define a constant for that and make the
    code a little more 'future proof'.

    Not that I expect that we'll have to change the event
    size any time soon, but it's better to write the code
    in a way that lends itself to extending.

    Due to the current size of the event struct, the code
    is currently equivalent, but should the event struct
    ever need to be increased the new code might not need
    changing.

    Signed-off-by: Johannes Berg
    Signed-off-by: John W. Linville

    Johannes Berg