01 Apr, 2018

1 commit

  • [ Upstream commit fa6a91e9b907231d2e38ea5ed89c537b3525df3d ]

    Free memory by calling put_device(), if afiucv_iucv_init is not
    successful.

    Signed-off-by: Arvind Yadav
    Reviewed-by: Cornelia Huck
    Signed-off-by: Ursula Braun
    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller
    Signed-off-by: Greg Kroah-Hartman

    Arvind Yadav
     

03 Jul, 2017

1 commit


25 Jun, 2017

2 commits

  • Verify that the caller-provided sockaddr structure is large enough to
    contain the sa_family field, before accessing it in bind() and connect()
    handlers of the AF_IUCV socket. Since neither syscall enforces a minimum
    size of the corresponding memory region, very short sockaddrs (zero or
    one byte long) result in operating on uninitialized memory while
    referencing .sa_family.

    Fixes: 52a82e23b9f2 ("af_iucv: Validate socket address length in iucv_sock_bind()")
    Signed-off-by: Mateusz Jurczyk
    [jwi: removed unneeded null-check for addr]
    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Mateusz Jurczyk
     
  • Use proper endianness conversion for an skb protocol assignment. Given
    that IUCV is only available on big endian systems (s390), this simply
    avoids an endianness warning reported by sparse.

    Signed-off-by: Hans Wippel
    Reviewed-by: Julian Wiedmann
    Reviewed-by: Ursula Braun
    Signed-off-by: Julian Wiedmann
    Signed-off-by: David S. Miller

    Hans Wippel
     

16 Jun, 2017

1 commit

  • It seems like a historic accident that these return unsigned char *,
    and in many places that means casts are required, more often than not.

    Make these functions return void * and remove all the casts across
    the tree, adding a (u8 *) cast only where the unsigned char pointer
    was used directly, all done with the following spatch:

    @@
    expression SKB, LEN;
    typedef u8;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    @@
    - *(fn(SKB, LEN))
    + *(u8 *)fn(SKB, LEN)

    @@
    expression E, SKB, LEN;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    type T;
    @@
    - E = ((T *)(fn(SKB, LEN)))
    + E = fn(SKB, LEN)

    @@
    expression SKB, LEN;
    identifier fn = { skb_push, __skb_push, skb_push_rcsum };
    @@
    - fn(SKB, LEN)[0]
    + *(u8 *)fn(SKB, LEN)

    Note that the last part there converts from push(...)[0] to the
    more idiomatic *(u8 *)push(...).

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

    Johannes Berg
     

10 Mar, 2017

1 commit

  • Lockdep issues a circular dependency warning when AFS issues an operation
    through AF_RXRPC from a context in which the VFS/VM holds the mmap_sem.

    The theory lockdep comes up with is as follows:

    (1) If the pagefault handler decides it needs to read pages from AFS, it
    calls AFS with mmap_sem held and AFS begins an AF_RXRPC call, but
    creating a call requires the socket lock:

    mmap_sem must be taken before sk_lock-AF_RXRPC

    (2) afs_open_socket() opens an AF_RXRPC socket and binds it. rxrpc_bind()
    binds the underlying UDP socket whilst holding its socket lock.
    inet_bind() takes its own socket lock:

    sk_lock-AF_RXRPC must be taken before sk_lock-AF_INET

    (3) Reading from a TCP socket into a userspace buffer might cause a fault
    and thus cause the kernel to take the mmap_sem, but the TCP socket is
    locked whilst doing this:

    sk_lock-AF_INET must be taken before mmap_sem

    However, lockdep's theory is wrong in this instance because it deals only
    with lock classes and not individual locks. The AF_INET lock in (2) isn't
    really equivalent to the AF_INET lock in (3) as the former deals with a
    socket entirely internal to the kernel that never sees userspace. This is
    a limitation in the design of lockdep.

    Fix the general case by:

    (1) Double up all the locking keys used in sockets so that one set are
    used if the socket is created by userspace and the other set is used
    if the socket is created by the kernel.

    (2) Store the kern parameter passed to sk_alloc() in a variable in the
    sock struct (sk_kern_sock). This informs sock_lock_init(),
    sock_init_data() and sk_clone_lock() as to the lock keys to be used.

    Note that the child created by sk_clone_lock() inherits the parent's
    kern setting.

    (3) Add a 'kern' parameter to ->accept() that is analogous to the one
    passed in to ->create() that distinguishes whether kernel_accept() or
    sys_accept4() was the caller and can be passed to sk_alloc().

    Note that a lot of accept functions merely dequeue an already
    allocated socket. I haven't touched these as the new socket already
    exists before we get the parameter.

    Note also that there are a couple of places where I've made the accepted
    socket unconditionally kernel-based:

    irda_accept()
    rds_rcp_accept_one()
    tcp_accept_from_sock()

    because they follow a sock_create_kern() and accept off of that.

    Whilst creating this, I noticed that lustre and ocfs don't create sockets
    through sock_create_kern() and thus they aren't marked as for-kernel,
    though they appear to be internal. I wonder if these should do that so
    that they use the new set of lock keys.

    Signed-off-by: David Howells
    Signed-off-by: David S. Miller

    David Howells
     

02 Mar, 2017

1 commit


11 Jan, 2017

1 commit

  • With commit e53743994e21
    ("af_iucv: use paged SKBs for big outbound messages"),
    we transmit paged skbs for both of AF_IUCV's transport modes
    (IUCV or HiperSockets).
    The qeth driver for Layer 3 HiperSockets currently doesn't
    support NETIF_F_SG, so these skbs would just be linearized again
    by the stack.
    Avoid that overhead by using paged skbs only for IUCV transport.

    cc stable, since this also circumvents a significant skb leak when
    sending large messages (where the skb then needs to be linearized).

    Signed-off-by: Julian Wiedmann
    Signed-off-by: Ursula Braun
    Cc: # v4.8+
    Fixes: e53743994e21 ("af_iucv: use paged SKBs for big outbound messages")
    Signed-off-by: David S. Miller

    Julian Wiedmann
     

12 Oct, 2016

2 commits

  • A packet filter might be installed for instance with setsockopt
    SO_ATTACH_FILTER. af_iucv currently queues skbs rejected by filter
    into the backlog queue. This does not make sense, since packets
    rejected by filter can be dropped immediately. This patch adds
    separate sk_filter return code checking, and dropping of packets
    if applicable.

    Signed-off-by: Ursula Braun
    Reported-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Ursula Braun
     
  • If a socket program has shut down the socket for sending, it can still
    receive an undetermined number of packets. The AF_IUCV protocol for
    HIPER transport requires sending of a WIN flag from time to time
    from the receiver to the sender, otherwise the peer cannot continue
    sending. That means sending of control flags must still work, even
    though the AF_IUCV socket is shutdown for sending data.
    sock_alloc_send_skb() returns with error EPIPE, if socket sk_shutdown
    is SEND_SHUTDOWN. Thus this patch temporarily removes the send
    shutdown attribute from the socket to enable transfer of control
    flags.

    Signed-off-by: Ursula Braun
    Signed-off-by: David S. Miller

    Ursula Braun
     

30 Jul, 2016

1 commit

  • Pull security subsystem updates from James Morris:
    "Highlights:

    - TPM core and driver updates/fixes
    - IPv6 security labeling (CALIPSO)
    - Lots of Apparmor fixes
    - Seccomp: remove 2-phase API, close hole where ptrace can change
    syscall #"

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (156 commits)
    apparmor: fix SECURITY_APPARMOR_HASH_DEFAULT parameter handling
    tpm: Add TPM 2.0 support to the Nuvoton i2c driver (NPCT6xx family)
    tpm: Factor out common startup code
    tpm: use devm_add_action_or_reset
    tpm2_i2c_nuvoton: add irq validity check
    tpm: read burstcount from TPM_STS in one 32-bit transaction
    tpm: fix byte-order for the value read by tpm2_get_tpm_pt
    tpm_tis_core: convert max timeouts from msec to jiffies
    apparmor: fix arg_size computation for when setprocattr is null terminated
    apparmor: fix oops, validate buffer size in apparmor_setprocattr()
    apparmor: do not expose kernel stack
    apparmor: fix module parameters can be changed after policy is locked
    apparmor: fix oops in profile_unpack() when policy_db is not present
    apparmor: don't check for vmalloc_addr if kvzalloc() failed
    apparmor: add missing id bounds check on dfa verification
    apparmor: allow SYS_CAP_RESOURCE to be sufficient to prlimit another task
    apparmor: use list_next_entry instead of list_entry_next
    apparmor: fix refcount race when finding a child profile
    apparmor: fix ref count leak when profile sha1 hash is read
    apparmor: check that xindex is in trans_table bounds
    ...

    Linus Torvalds
     

16 Jun, 2016

3 commits


07 Jun, 2016

1 commit


20 Jan, 2016

1 commit


15 Dec, 2015

2 commits

  • When the linear buffer of the received sk_buff is shorter than
    the header, use skb_linearize(). sk_buffs with short linear buffer
    happen on the sending side under high traffic, and some kernel
    configurations, when allocated buffer starts just before page
    boundary, and IUCV transport has to send it as two separate QDIO
    buffer elements, with fist element shorter than the header.

    Signed-off-by: Eugene Crosser
    Signed-off-by: Ursula Braun
    Signed-off-by: David S. Miller

    Eugene Crosser
     
  • Initialize storage for the future IUCV header that will be included
    in the transmitted packet. Some of the header fields are unused with
    HiperSockets transport, and will contain data left from some other
    functions.

    Signed-off-by: Eugene Crosser
    Signed-off-by: Ursula Braun
    Reviewed-by: Thomas Richter
    Signed-off-by: David S. Miller

    Eugene Crosser
     

04 Dec, 2015

1 commit


02 Dec, 2015

1 commit

  • This patch is a cleanup to make following patch easier to
    review.

    Goal is to move SOCK_ASYNC_NOSPACE and SOCK_ASYNC_WAITDATA
    from (struct socket)->flags to a (struct socket_wq)->flags
    to benefit from RCU protection in sock_wake_async()

    To ease backports, we rename both constants.

    Two new helpers, sk_set_bit(int nr, struct sock *sk)
    and sk_clear_bit(int net, struct sock *sk) are added so that
    following patch can change their implementation.

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

    Eric Dumazet
     

01 Dec, 2015

1 commit

  • The memory barrier in the helper wq_has_sleeper is needed by just
    about every user of waitqueue_active. This patch generalises it
    by making it take a wait_queue_head_t directly. The existing
    helper is renamed to skwq_has_sleeper.

    Signed-off-by: Herbert Xu
    Signed-off-by: David S. Miller

    Herbert Xu
     

22 Sep, 2015

1 commit

  • The iucv code uses arrays as arguments. Even though this does not
    really cause a problem, it could be misleading, since the compiler
    turns array arguments into just a pointer argument. To be more
    precise this patch changes the array arguments into pointers.

    Signed-off-by: Ursula Braun
    Signed-off-by: David S. Miller

    Ursula Braun
     

11 May, 2015

1 commit


03 Apr, 2015

1 commit

  • Conflicts:
    drivers/net/usb/asix_common.c
    drivers/net/usb/sr9800.c
    drivers/net/usb/usbnet.c
    include/linux/usb/usbnet.h
    net/ipv4/tcp_ipv4.c
    net/ipv6/tcp_ipv6.c

    The TCP conflicts were overlapping changes. In 'net' we added a
    READ_ONCE() to the socket cached RX route read, whilst in 'net-next'
    Eric Dumazet touched the surrounding code dealing with how mini
    sockets are handled.

    With USB, it's a case of the same bug fix first going into net-next
    and then I cherry picked it back into net.

    Signed-off-by: David S. Miller

    David S. Miller
     

01 Apr, 2015

1 commit

  • When sending over AF_IUCV socket, errno was incorrectly set to
    ENOMEM even when other values where appropriate, notably EAGAIN.
    With this patch, error indicator returned by sock_alloc_send_skb()
    is passed to the caller, rather than being overwritten with ENOMEM.

    Signed-off-by: Eugene Crosser
    Signed-off-by: Ursula Braun
    Signed-off-by: David S. Miller

    Eugene Crosser
     

03 Mar, 2015

1 commit

  • After TIPC doesn't depend on iocb argument in its internal
    implementations of sendmsg() and recvmsg() hooks defined in proto
    structure, no any user is using iocb argument in them at all now.
    Then we can drop the redundant iocb argument completely from kinds of
    implementations of both sendmsg() and recvmsg() in the entire
    networking stack.

    Cc: Christoph Hellwig
    Suggested-by: Al Viro
    Signed-off-by: Ying Xue
    Signed-off-by: David S. Miller

    Ying Xue
     

11 Dec, 2014

1 commit


24 Nov, 2014

1 commit


06 Nov, 2014

1 commit

  • This encapsulates all of the skb_copy_datagram_iovec() callers
    with call argument signature "skb, offset, msghdr->msg_iov, length".

    When we move to iov_iters in the networking, the iov_iter object will
    sit in the msghdr.

    Having a helper like this means there will be less places to touch
    during that transformation.

    Based upon descriptions and patch from Al Viro.

    Signed-off-by: David S. Miller

    David S. Miller
     

22 Jul, 2014

1 commit

  • An af_iucv stress test showed -EPIPE results for sendmsg()
    calls. They are caused by quiescing a path even though it has
    been already severed by peer. For IUCV transport shutdown()
    consists of 2 steps:
    (1) sending the shutdown message to peer
    (2) quiescing the iucv path
    If the iucv path between these 2 steps is severed due to peer
    closing the path, the quiesce step is no longer needed.

    Signed-off-by: Ursula Braun
    Signed-off-by: Frank Blaschka
    Reported-by: Philipp Hachtmann
    Signed-off-by: David S. Miller

    Ursula Braun
     

16 Jul, 2014

1 commit


31 May, 2014

2 commits

  • In case of transport HIPER a sock struct is allocated for an incoming
    connect request. If the backlog queue is full this socket is not
    needed, but is left in the list of af_iucv sockets. Final socket
    release posts console message "Attempt to release alive iucv socket".
    This patch makes sure the new created socket is cleaned up correctly
    if the backlog queue is full.

    Signed-off-by: Ursula Braun
    Signed-off-by: Frank Blaschka
    Reported-by: Philipp Hachtmann
    Signed-off-by: David S. Miller

    Ursula Braun
     
  • If a socket is bound to an address using before calling connect
    it is usual to leave it to the network system to choose an appropriate
    outgoing application name respective port address.
    af_iucv on VM uses a counter and uses simple numbers as unique identifiers.
    This behaviour was missing when af_iucv is used with HiperSockets.

    This patch contains a simple approach to harmonize af_iucv's behaviour.

    Signed-off-by: Philipp Hachtmann
    Signed-off-by: Frank Blaschka
    Signed-off-by: David S. Miller

    Philipp Hachtmann
     

15 May, 2014

1 commit

  • When sending data through IUCV a MESSAGE COMPLETE interrupt
    signals that sent data memory can be freed or reused again.
    With commit f9c41a62bba3f3f7ef3541b2a025e3371bcbba97
    "af_iucv: fix recvmsg by replacing skb_pull() function" the
    MESSAGE COMPLETE callback iucv_callback_txdone() identifies
    the wrong skb as being confirmed, which leads to data corruption.
    This patch fixes the skb mapping logic in iucv_callback_txdone().

    Signed-off-by: Ursula Braun
    Signed-off-by: Frank Blaschka
    Cc:
    Signed-off-by: David S. Miller

    Ursula Braun
     

12 Apr, 2014

1 commit

  • Several spots in the kernel perform a sequence like:

    skb_queue_tail(&sk->s_receive_queue, skb);
    sk->sk_data_ready(sk, skb->len);

    But at the moment we place the SKB onto the socket receive queue it
    can be consumed and freed up. So this skb->len access is potentially
    to freed up memory.

    Furthermore, the skb->len can be modified by the consumer so it is
    possible that the value isn't accurate.

    And finally, no actual implementation of this callback actually uses
    the length argument. And since nobody actually cared about it's
    value, lots of call sites pass arbitrary values in such as '0' and
    even '1'.

    So just remove the length argument from the callback, that way there
    is no confusion whatsoever and all of these use-after-free cases get
    fixed as a side effect.

    Based upon a patch by Eric Dumazet and his suggestion to audit this
    issue tree-wide.

    Signed-off-by: David S. Miller

    David S. Miller
     

20 Mar, 2014

1 commit

  • Commit f9c41a62bba3f3f7ef3541b2a025e3371bcbba97 introduced
    a problem for SOCK_STREAM sockets, when only part of the
    incoming iucv message is received by user space. In this
    case the remaining data of the iucv message is lost.
    This patch makes sure an incompletely received iucv message
    is queued back to the receive queue.

    Signed-off-by: Ursula Braun
    Signed-off-by: Frank Blaschka
    Reported-by: Hendrik Brueckner
    Signed-off-by: David S. Miller

    Ursula Braun
     

21 Nov, 2013

1 commit


29 May, 2013

1 commit

  • So far, only net_device * could be passed along with netdevice notifier
    event. This patch provides a possibility to pass custom structure
    able to provide info that event listener needs to know.

    Signed-off-by: Jiri Pirko

    v2->v3: fix typo on simeth
    shortened dev_getter
    shortened notifier_info struct name
    v1->v2: fix notifier_call parameter in call_netdevice_notifier()
    Signed-off-by: David S. Miller

    Jiri Pirko
     

23 Apr, 2013

1 commit

  • Conflicts:
    drivers/net/ethernet/emulex/benet/be_main.c
    drivers/net/ethernet/intel/igb/igb_main.c
    drivers/net/wireless/brcm80211/brcmsmac/mac80211_if.c
    include/net/scm.h
    net/batman-adv/routing.c
    net/ipv4/tcp_input.c

    The e{uid,gid} --> {uid,gid} credentials fix conflicted with the
    cleanup in net-next to now pass cred structs around.

    The be2net driver had a bug fix in 'net' that overlapped with the VLAN
    interface changes by Patrick McHardy in net-next.

    An IGB conflict existed because in 'net' the build_skb() support was
    reverted, and in 'net-next' there was a comment style fix within that
    code.

    Several batman-adv conflicts were resolved by making sure that all
    calls to batadv_is_my_mac() are changed to have a new bat_priv first
    argument.

    Eric Dumazet's TS ECR fix in TCP in 'net' conflicted with the F-RTO
    rewrite in 'net-next', mostly overlapping changes.

    Thanks to Stephen Rothwell and Antonio Quartulli for help with several
    of these merge resolutions.

    Signed-off-by: David S. Miller

    David S. Miller
     

09 Apr, 2013

1 commit

  • When receiving data messages, the "BUG_ON(skb->len < skb->data_len)" in
    the skb_pull() function triggers a kernel panic.

    Replace the skb_pull logic by a per skb offset as advised by
    Eric Dumazet.

    Signed-off-by: Ursula Braun
    Signed-off-by: Frank Blaschka
    Reviewed-by: Hendrik Brueckner
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Ursula Braun