1. 23 7月, 2014 1 次提交
  2. 17 5月, 2014 1 次提交
  3. 12 4月, 2014 1 次提交
    • D
      net: Fix use after free by removing length arg from sk_data_ready callbacks. · 676d2369
      David S. Miller 提交于
      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: NDavid S. Miller <davem@davemloft.net>
      676d2369
  4. 04 3月, 2014 1 次提交
  5. 27 2月, 2014 5 次提交
    • D
      af_rxrpc: Request an ACK for every alternate DATA packet · e8388eb1
      David Howells 提交于
      Set the RxRPC header flag to request an ACK packet for every odd-numbered DATA
      packet unless it's the last one (which implicitly requests an ACK anyway).
      This is similar to how librx appears to work.
      
      If we don't do this, we'll send out a full window of packets and then just sit
      there until the other side gets bored and sends an ACK to indicate that it's
      been idle for a while and has received no new packets.
      
      Requesting a lot of ACKs shouldn't be a problem as ACKs should be merged when
      possible.
      
      As AF_RXRPC currently works, it will schedule an ACK to be generated upon
      receipt of a DATA packet with the ACK-request packet set - and in the time
      taken to schedule this in a work queue, several other packets are likely to
      arrive and then all get ACK'd together.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      e8388eb1
    • D
      af_rxrpc: Expose more RxRPC parameters via sysctls · 817913d8
      David Howells 提交于
      Expose RxRPC parameters via sysctls to control the Rx window size, the Rx MTU
      maximum size and the number of packets that can be glued into a jumbo packet.
      
      More info added to Documentation/networking/rxrpc.txt.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      817913d8
    • D
      af_rxrpc: Improve ACK production · 9823f39a
      David Howells 提交于
      Improve ACK production by the following means:
      
       (1) Don't send an ACK_REQUESTED ack immediately even if the RXRPC_MORE_PACKETS
           flag isn't set on a data packet that has also has RXRPC_REQUEST_ACK set.
      
           MORE_PACKETS just means that the sender just emptied its Tx data buffer.
           More data will be forthcoming unless RXRPC_LAST_PACKET is also flagged.
      
           It is possible to see runs of DATA packets with MORE_PACKETS unset that
           aren't waiting for an ACK.
      
           It is therefore better to wait a small instant to see if we can combine an
           ACK for several packets.
      
       (2) Don't send an ACK_IDLE ack immediately unless we're responding to the
           terminal data packet of a call.
      
           Whilst sending an ACK_IDLE mid-call serves to let the other side know
           that we won't be asking it to resend certain Tx buffers and that it can
           discard them, spamming it with loads of acks just because we've
           temporarily run out of data just distracts it.
      
       (3) Put the ACK_IDLE ack generation timeout up to half a second rather than a
           single jiffy.  Just because we haven't been given more data immediately
           doesn't mean that more isn't forthcoming.  The other side may be busily
           finding the data to send to us.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      9823f39a
    • D
      af_rxrpc: Add sysctls for configuring RxRPC parameters · 5873c083
      David Howells 提交于
      Add sysctls for configuring RxRPC protocol handling, specifically controls on
      delays before ack generation, the delay before resending a packet, the maximum
      lifetime of a call and the expiration times of calls, connections and
      transports that haven't been recently used.
      
      More info added in Documentation/networking/rxrpc.txt.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      5873c083
    • D
      af_rxrpc: Fix UDP MTU calculation from ICMP_FRAG_NEEDED · 6c9a2d32
      David Howells 提交于
      AF_RXRPC sends UDP packets with the "Don't Fragment" bit set in an attempt to
      determine the maximum packet size between the local socket and the peer by
      invoking the generation of ICMP_FRAG_NEEDED packets.
      
      Once a packet is sent with the "Don't Fragment" bit set, it is then
      inconvenient to break it up as that requires recalculating all the rxrpc serial
      and sequence numbers and reencrypting all the fragments, so we switch off the
      "Don't Fragment" service temporarily and send the bounced packet again.  Future
      packets then use the new MTU.
      
      That's all fine.  The problem lies in rxrpc_UDP_error_report() where the code
      that deals with ICMP_FRAG_NEEDED packets lives.  Packets of this type have a
      field (ee_info) to indicate the maximum packet size at the reporting node - but
      sometimes ee_info isn't filled in and is just left as 0 and the code must allow
      for this.
      
      When ee_info is 0, the code should take the MTU size we're currently using and
      reduce it for the next packet we want to send.  However, it takes ee_info
      (which is known to be 0) and tries to reduce that instead.
      
      This was discovered by Coverity.
      Reported-by: NDave Jones <davej@redhat.com>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      6c9a2d32
  6. 08 2月, 2014 2 次提交
  7. 26 1月, 2014 3 次提交
    • T
      af_rxrpc: Handle frames delivered from another VM · 1ea42735
      Tim Smith 提交于
      On input, CHECKSUM_PARTIAL should be treated the same way as
      CHECKSUM_UNNECESSARY. See include/linux/skbuff.h
      Signed-off-by: NTim Smith <tim@electronghost.co.uk>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      1ea42735
    • T
      af_rxrpc: Avoid setting up double-free on checksum error · 24a9981e
      Tim Smith 提交于
      skb_kill_datagram() does not dequeue the skb when MSG_PEEK is unset.
      This leaves a free'd skb on the queue, resulting a double-free later.
      
      Without this, the following oops can occur:
      
      BUG: unable to handle kernel NULL pointer dereference at 0000000000000008
      IP: [<ffffffff8154fcf7>] skb_dequeue+0x47/0x70
      PGD 0
      Oops: 0002 [#1] SMP
      Modules linked in: af_rxrpc ...
      CPU: 0 PID: 1191 Comm: listen Not tainted 3.12.0+ #4
      Hardware name: Bochs Bochs, BIOS Bochs 01/01/2011
      task: ffff8801183536b0 ti: ffff880035c92000 task.ti: ffff880035c92000
      RIP: 0010:[<ffffffff8154fcf7>] skb_dequeue+0x47/0x70
      RSP: 0018:ffff880035c93db8  EFLAGS: 00010097
      RAX: 0000000000000246 RBX: ffff8800d2754b00 RCX: 0000000000000000
      RDX: 0000000000000000 RSI: 0000000000000202 RDI: ffff8800d254c084
      RBP: ffff880035c93dd0 R08: ffff880035c93cf0 R09: ffff8800d968f270
      R10: 0000000000000000 R11: 0000000000000293 R12: ffff8800d254c070
      R13: ffff8800d254c084 R14: ffff8800cd861240 R15: ffff880119b39720
      FS:  00007f37a969d740(0000) GS:ffff88011fc00000(0000) knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 000000008005003b
      CR2: 0000000000000008 CR3: 00000000d4413000 CR4: 00000000000006f0
      Stack:
       ffff8800d254c000 ffff8800d254c070 ffff8800d254c2c0 ffff880035c93df8
       ffffffffa041a5b8 ffff8800cd844c80 ffffffffa04385a0 ffff8800cd844cb0
       ffff880035c93e18 ffffffff81546cef ffff8800d45fea00 0000000000000008
      Call Trace:
       [<ffffffffa041a5b8>] rxrpc_release+0x128/0x2e0 [af_rxrpc]
       [<ffffffff81546cef>] sock_release+0x1f/0x80
       [<ffffffff81546d62>] sock_close+0x12/0x20
       [<ffffffff811aaba1>] __fput+0xe1/0x230
       [<ffffffff811aad3e>] ____fput+0xe/0x10
       [<ffffffff810862cc>] task_work_run+0xbc/0xe0
       [<ffffffff8106a3be>] do_exit+0x2be/0xa10
       [<ffffffff8116dc47>] ? do_munmap+0x297/0x3b0
       [<ffffffff8106ab8f>] do_group_exit+0x3f/0xa0
       [<ffffffff8106ac04>] SyS_exit_group+0x14/0x20
       [<ffffffff8166b069>] system_call_fastpath+0x16/0x1b
      Signed-off-by: NTim Smith <tim@electronghost.co.uk>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      24a9981e
    • A
      RxRPC: do not unlock unheld spinlock in rxrpc_connect_exclusive() · 8f22ba61
      Alexey Khoroshilov 提交于
      If rx->conn is not NULL, rxrpc_connect_exclusive() does not
      acquire the transport's client lock, but it still releases it.
      
      The patch adds locking of the spinlock to this path.
      
      Found by Linux Driver Verification project (linuxtesting.org).
      Signed-off-by: NAlexey Khoroshilov <khoroshilov@ispras.ru>
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      8f22ba61
  8. 22 1月, 2014 1 次提交
  9. 19 1月, 2014 1 次提交
  10. 21 11月, 2013 1 次提交
    • H
      net: rework recvmsg handler msg_name and msg_namelen logic · f3d33426
      Hannes Frederic Sowa 提交于
      This patch now always passes msg->msg_namelen as 0. recvmsg handlers must
      set msg_namelen to the proper size <= sizeof(struct sockaddr_storage)
      to return msg_name to the user.
      
      This prevents numerous uninitialized memory leaks we had in the
      recvmsg handlers and makes it harder for new code to accidentally leak
      uninitialized memory.
      
      Optimize for the case recvfrom is called with NULL as address. We don't
      need to copy the address at all, so set it to NULL before invoking the
      recvmsg handler. We can do so, because all the recvmsg handlers must
      cope with the case a plain read() is called on them. read() also sets
      msg_name to NULL.
      
      Also document these changes in include/linux/net.h as suggested by David
      Miller.
      
      Changes since RFC:
      
      Set msg->msg_name = NULL if user specified a NULL in msg_name but had a
      non-null msg_namelen in verify_iovec/verify_compat_iovec. This doesn't
      affect sendto as it would bail out earlier while trying to copy-in the
      address. It also more naturally reflects the logic by the callers of
      verify_iovec.
      
      With this change in place I could remove "
      if (!uaddr || msg_sys->msg_namelen == 0)
      	msg->msg_name = NULL
      ".
      
      This change does not alter the user visible error logic as we ignore
      msg_namelen as long as msg_name is NULL.
      
      Also remove two unnecessary curly brackets in ___sys_recvmsg and change
      comments to netdev style.
      
      Cc: David Miller <davem@davemloft.net>
      Suggested-by: NEric Dumazet <eric.dumazet@gmail.com>
      Signed-off-by: NHannes Frederic Sowa <hannes@stressinduktion.org>
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      f3d33426
  11. 20 10月, 2013 1 次提交
  12. 19 2月, 2013 2 次提交
  13. 12 1月, 2013 1 次提交
  14. 10 1月, 2013 1 次提交
  15. 08 10月, 2012 1 次提交
    • D
      KEYS: Add payload preparsing opportunity prior to key instantiate or update · cf7f601c
      David Howells 提交于
      Give the key type the opportunity to preparse the payload prior to the
      instantiation and update routines being called.  This is done with the
      provision of two new key type operations:
      
      	int (*preparse)(struct key_preparsed_payload *prep);
      	void (*free_preparse)(struct key_preparsed_payload *prep);
      
      If the first operation is present, then it is called before key creation (in
      the add/update case) or before the key semaphore is taken (in the update and
      instantiate cases).  The second operation is called to clean up if the first
      was called.
      
      preparse() is given the opportunity to fill in the following structure:
      
      	struct key_preparsed_payload {
      		char		*description;
      		void		*type_data[2];
      		void		*payload;
      		const void	*data;
      		size_t		datalen;
      		size_t		quotalen;
      	};
      
      Before the preparser is called, the first three fields will have been cleared,
      the payload pointer and size will be stored in data and datalen and the default
      quota size from the key_type struct will be stored into quotalen.
      
      The preparser may parse the payload in any way it likes and may store data in
      the type_data[] and payload fields for use by the instantiate() and update()
      ops.
      
      The preparser may also propose a description for the key by attaching it as a
      string to the description field.  This can be used by passing a NULL or ""
      description to the add_key() system call or the key_create_or_update()
      function.  This cannot work with request_key() as that required the description
      to tell the upcall about the key to be created.
      
      This, for example permits keys that store PGP public keys to generate their own
      name from the user ID and public key fingerprint in the key.
      
      The instantiate() and update() operations are then modified to look like this:
      
      	int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
      	int (*update)(struct key *key, struct key_preparsed_payload *prep);
      
      and the new payload data is passed in *prep, whether or not it was preparsed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      Signed-off-by: NRusty Russell <rusty@rustcorp.com.au>
      cf7f601c
  16. 14 9月, 2012 1 次提交
  17. 13 9月, 2012 1 次提交
    • D
      KEYS: Add payload preparsing opportunity prior to key instantiate or update · d4f65b5d
      David Howells 提交于
      Give the key type the opportunity to preparse the payload prior to the
      instantiation and update routines being called.  This is done with the
      provision of two new key type operations:
      
      	int (*preparse)(struct key_preparsed_payload *prep);
      	void (*free_preparse)(struct key_preparsed_payload *prep);
      
      If the first operation is present, then it is called before key creation (in
      the add/update case) or before the key semaphore is taken (in the update and
      instantiate cases).  The second operation is called to clean up if the first
      was called.
      
      preparse() is given the opportunity to fill in the following structure:
      
      	struct key_preparsed_payload {
      		char		*description;
      		void		*type_data[2];
      		void		*payload;
      		const void	*data;
      		size_t		datalen;
      		size_t		quotalen;
      	};
      
      Before the preparser is called, the first three fields will have been cleared,
      the payload pointer and size will be stored in data and datalen and the default
      quota size from the key_type struct will be stored into quotalen.
      
      The preparser may parse the payload in any way it likes and may store data in
      the type_data[] and payload fields for use by the instantiate() and update()
      ops.
      
      The preparser may also propose a description for the key by attaching it as a
      string to the description field.  This can be used by passing a NULL or ""
      description to the add_key() system call or the key_create_or_update()
      function.  This cannot work with request_key() as that required the description
      to tell the upcall about the key to be created.
      
      This, for example permits keys that store PGP public keys to generate their own
      name from the user ID and public key fingerprint in the key.
      
      The instantiate() and update() operations are then modified to look like this:
      
      	int (*instantiate)(struct key *key, struct key_preparsed_payload *prep);
      	int (*update)(struct key *key, struct key_preparsed_payload *prep);
      
      and the new payload data is passed in *prep, whether or not it was preparsed.
      Signed-off-by: NDavid Howells <dhowells@redhat.com>
      d4f65b5d
  18. 11 7月, 2012 1 次提交
  19. 10 7月, 2012 1 次提交
  20. 11 6月, 2012 1 次提交
    • D
      ipv4: Kill ip_rt_frag_needed(). · 46517008
      David S. Miller 提交于
      There is zero point to this function.
      
      It's only real substance is to perform an extremely outdated BSD4.2
      ICMP check, which we can safely remove.  If you really have a MTU
      limited link being routed by a BSD4.2 derived system, here's a nickel
      go buy yourself a real router.
      
      The other actions of ip_rt_frag_needed(), checking and conditionally
      updating the peer, are done by the per-protocol handlers of the ICMP
      event.
      
      TCP, UDP, et al. have a handler which will receive this event and
      transmit it back into the associated route via dst_ops->update_pmtu().
      
      This simplification is important, because it eliminates the one place
      where we do not have a proper route context in which to make an
      inetpeer lookup.
      Signed-off-by: NDavid S. Miller <davem@davemloft.net>
      46517008
  21. 16 4月, 2012 1 次提交
  22. 15 2月, 2012 1 次提交
  23. 20 12月, 2011 1 次提交
  24. 22 11月, 2011 1 次提交
  25. 01 11月, 2011 1 次提交
  26. 20 5月, 2011 5 次提交
  27. 04 5月, 2011 1 次提交
  28. 13 3月, 2011 1 次提交