mptcp: make mptcp_alloc_mpcb static

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: is_meta_sk() function pointers optimization

Removed the verification of is_meta_sk() (where possible) that separated MPTCP
meta socket code from ordinary TCP workflow by setting function pointers in
struct tcp_sock to the appropriate value (MPTCP or TCP), according to the
current socket - if it is meta socket or not.

Signed-off-by: Cristina Ciocan <cristina.ciocan@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Fix Bug #43 #27: Initialize mptcp-reqsk earlier

mtreq->mpcb is used in mptcp_reqsk_destructor to decide, whether we are
handling a new subflow or a new MPTCP-connection. Depending on this we
either remove the request-sock from the collide_tuple or the
collide_tk-list.

As mpcb was initialized so late, it might be NULL, thus trying to remove
the req-sock from the collide_tk, which is actually garbage, possibly
corrupting the list, leading to bug
https://github.com/multipath-tcp/mptcp/issues/27.

Fixes: 560443b12b731 (Don't use get_random_bytes)
Fixes: Bug #27 (https://github.com/multipath-tcp/mptcp/issues/27)
Fixes: Bug #43 (https://github.com/multipath-tcp/mptcp/issues/43)
Reported-by: chenjianqing <https://github.com/cjqing0925>
Reported-by: <liuyun_piaoye@163.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
Merge branch 'mptcp_trunk' into mptcp_v0.89
Renamed mptcp_update_tw_socks for consistency

In struct tcp_sock we have a function pointer (*time_wait) to which
mptcp_update_tw_socks was assigned when the current socket was the meta socket.
For consistency, we changed the name of mptcp_update_tw_socks in mptcp_time_wait
and the former mptcp_time_wait was changed to mptcp_init_tw_sock.

Signed-off-by: Cristina Ciocan <cristina.ciocan@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Fix Bug #42: Do not reschedule tsq on closed socket

This socket anyway cannot send data anymore. Otherwise, if the sk_free
will indeed free the socket, we will bug in mptcp_sock_destruct as the
cb_list is not empty.

Reported-by: dykelin (https://github.com/dykelin)
Fixes: Bug #42 (https://github.com/multipath-tcp/mptcp/issues/42)
Fixes: be54ab36580a9 (Fix tsq-deferred)
Tested-by: dykelin (https://github.com/dykelin)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Correct support of TCP-keepalive cont'd

This patch fixes and complements ba1582e13 (mptcp: Correct support of
TCP-Keepalive).

Fixes:
 - correctly disable using keepalive timer at the subflow level
 - avoid calling inet_csk_reqsk_queue_drop when new subflows are
   established that will stop the keepalive timer at the meta.

Fixes: ba1582e13 (mptcp: Correct support of TCP-Keepalive)
Signed-off-by: Gregory Detal <gregory.detal@uclouvain.be>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Fix Bug #45: Split segment when probing for window opening

There is a bug, when the window closes down to sub-MTU size and no
outstanding data is sent.

In this case, the probe-timer does the window probing. But, as the
subflow's window is too small for a MSS, the check in
mptcp_is_available() will prevent selecting a subflow for transmission.

Additionally, in mptcp_write_wakeup we need to split the segment based
on the minimum available window (meta or sub).

This fixes the bug https://github.com/multipath-tcp/mptcp/issues/45

Fixes: 916fcc1585a10 (Fix: Check send-window at the subflow-level)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Change ack-sock selection

Up to now, we selected the ack sock by tracking the data sequence. Our
goal was to actually use the subflow who was the last time active.

Now, we have a very good estimation of "last active", given by
keepalive_time_elapsed(). So, we should rather use this.

This patch uses keepalive_time_elapsed() to select the ack-sock among
those who were most recently active. Among those within the time of a
meta-RTO (thus reasonably recent), we take the one with the lowest RTT.

If there is no such subflow that is has been so recently active, we just
take the most recent active one.

Depends-on: 0ee43475b2cb0 (Cleanup: Create separate function for subflow-ack-selection)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: mptcp_inherit_sk should take into account cgroups

180d8cd942ce (foundations of per-cgroup memory pressure controlling.)
introduced cgroup memory-control for sockets. It modifies the cloning of
sockets so that the increase of the per-cpu counter takes this also on
a per-cgroup level.

We need to do the same in mptcp_inherit_sk.

Fixes: 180d8cd942ce (foundations of per-cgroup memory pressure controlling.)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Optimize socket timestamping

Let's just do the same as in 08e29af3a9096 (net: optimize socket
timestamping)

Depends-on: 08e29af3a9096 (net: optimize socket timestamping)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: Build-Fix

Sorry... Should at least have built before committing.

Fixes: 333c4d90f1edda (mptcp: Optimize socket timestamping)
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
mptcp: remove data_ack and data_seq from tcp_out_options

We can access the source directly in mptcp_options_write, no need to
carry them through tcp_out_options.

Signed-off-by: Octavian Purdila <octavian.purdila@intel.com>
Signed-off-by: Christoph Paasch <christoph.paasch@uclouvain.be>
scsi: fix our current target reap infrastructure

commit e63ed0d7a98014fdfc2cfeb3f6dada313dcabb59 upstream.

This patch eliminates the reap_ref and replaces it with a proper kref.
On last put of this kref, the target is removed from visibility in
sysfs.  The final call to scsi_target_reap() for the device is done from
__scsi_remove_device() and only if the device was made visible.  This
ensures that the target disappears as soon as the last device is gone
rather than waiting until final release of the device (which is often
too long).

Reviewed-by: Alan Stern <stern@rowland.harvard.edu>
Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
SCSI: dual scan thread bug fix

commit f2495e228fce9f9cec84367547813cbb0d6db15a upstream.

In the highly unusual case where two threads are running concurrently through
the scanning code scanning the same target, we run into the situation where
one may allocate the target while the other is still using it.  In this case,
because the reap checks for STARGET_CREATED and kills the target without
reference counting, the second thread will do the wrong thing on reap.

Fix this by reference counting even creates and doing the STARGET_CREATED
check in the final put.

Tested-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
SCSI: megaraid: missing bounds check in mimd_to_kioc()

commit 3de2260140417759c669d391613d583baf03b0cf upstream.

pthru32->dataxferlen comes from the user so we need to check that it's
not too large so we don't overflow the buffer.

Reported-by: Nico Golde <nico@ngolde.de>
Reported-by: Fabian Yamaguchi <fabs@goesec.de>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Sumit Saxena <sumit.saxena@lsi.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
KVM: x86: remove WARN_ON from get_kernel_ns()

commit b351c39cc9e0151cee9b8d52a1e714928faabb38 upstream.

Function and callers can be preempted.

https://bugzilla.kernel.org/show_bug.cgi?id=73721

Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
tools lib traceevent: Fix memory leak in pretty_print()

commit de04f8657de9d3351a2d5880f1f7080b23b798cf upstream.

Commit 12e55569a244 "tools lib traceevent: Use helper trace-seq in print
functions like kernel does" added a extra trace_seq helper to process
string arguments like the kernel does it. But the difference between the
kernel and the userspace library is that the kernel's trace_seq structure
has a static allocated buffer. The userspace one has a dynamically
allocated one. It requires a trace_seq_destroy(), otherwise it produces
a nasty memory leak.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/20140422192330.6bb09bf8@gandalf.local.home
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
pid: get pid_t ppid of task in init_pid_ns

commit ad36d28293936b03d6b7996e9d6aadfd73c0eb08 upstream.

Added the functions task_ppid_nr_ns() and task_ppid_nr() to abstract the lookup
of the PPID (real_parent's pid_t) of a process, including rcu locking, in the
arbitrary and init_pid_ns.
This provides an alternative to sys_getppid(), which is relative to the child
process' pid namespace.

(informed by ebiederman's 6c621b7e)
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
audit: convert PPIDs to the inital PID namespace.

commit c92cdeb45eea38515e82187f48c2e4f435fb4e25 upstream.

sys_getppid() returns the parent pid of the current process in its own pid
namespace.  Since audit filters are based in the init pid namespace, a process
could avoid a filter or trigger an unintended one by being in an alternate pid
namespace or log meaningless information.

Switch to task_ppid_nr() for PPIDs to anchor all audit filters in the
init_pid_ns.

(informed by ebiederman's 6c621b7e)
Cc: Eric W. Biederman <ebiederm@xmission.com>
Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>