staging: add LTTng to build

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
staging: Add LTTng entry to MAINTAINERS file

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lttng lib: ring buffer: remove stale null-pointer

* Dan Carpenter <dan.carpenter@oracle.com> wrote:
[...]
> The patch c844b2f5cfea: "lttng lib: ring buffer" from Nov 28, 2011,
> leads to the following Smatch complaint:
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_frontend.c +1150
> +lib_ring_buffer_print_buffer_errors()
>          warn: variable dereferenced before check 'chan' (see line 1143)
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_frontend.c
>   1142  {
>   1143          const struct lib_ring_buffer_config *config =
> +chan->backend.config;
>
> +^^^^^^^^^^^^^^^^^^^^
> Dereference.
>
>   1144          unsigned long write_offset, cons_offset;
>   1145
>   1146          /*
>   1147           * Can be called in the error path of allocation when
>   1148           * trans_channel_data is not yet set.
>   1149           */
>   1150          if (!chan)
>                 ^^^^^^^^^
> Check.  At first glance the comment seems out of date, I think check can
> be removed safely.
>
>   1151                  return;
>   1152          /*

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lttng lib: ring buffer remove duplicate null pointer

* Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The patch c844b2f5cfea: "lttng lib: ring buffer" from Nov 28, 2011,
> leads to the following Smatch complaint:
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c +33
> +lib_ring_buffer_fault()
>          warn: variable dereferenced before check 'buf' (see line 26)
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c
>     25          struct lib_ring_buffer *buf = vma->vm_private_data;
>     26          struct channel *chan = buf->backend.chan;
>                                        ^^^^^^^^^^^^^^^^^
> Dereference.
>
>     27          const struct lib_ring_buffer_config *config = chan->backend.config;
>     28          pgoff_t pgoff = vmf->pgoff;
>     29          struct page **page;
>     30          void **virt;
>     31          unsigned long offset, sb_bindex;
>     32
>     33          if (!buf)
>                     ^^^^
> Check.
>
>     34                  return VM_FAULT_OOM;
>     35

This check is performed at mapping setup time in
lib_ring_buffer_mmap_buf() already, so we can safely remove this
duplicata.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lttng lib: ring buffer move null pointer check to open

* Dan Carpenter <dan.carpenter@oracle.com> wrote:
> The patch c844b2f5cfea: "lttng lib: ring buffer" from Nov 28, 2011,
> leads to the following Smatch complaint:
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c +86
> +lib_ring_buffer_mmap_buf()
>          warn: variable dereferenced before check 'buf' (see line 79)
>
> drivers/staging/lttng/lib/ringbuffer/ring_buffer_mmap.c
>     78          unsigned long length = vma->vm_end - vma->vm_start;
>     79          struct channel *chan = buf->backend.chan;
>                                        ^^^^^^^^^^^^^^^^^
> Dereference.
>
>     80          const struct lib_ring_buffer_config *config = chan->backend.config;
>     81          unsigned long mmap_buf_len;
>     82
>     83          if (config->output != RING_BUFFER_MMAP)
>     84                  return -EINVAL;
>     85
>     86          if (!buf)
>                     ^^^^
> Check.
>
>     87                  return -EBADF;
>     88

Let's move the NULL buf check to the file "open", where it belongs. The
"open" file operation is the actual interface between lib ring buffer
and the modules using it.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
lttng wrapper: add missing include to kallsyms wrapper

Needed to keep bissectability.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
staging: lttng: cleanup one-bit signed bitfields

* Dan Carpenter <dan.carpenter@oracle.com> wrote:
> Sparse complains that these signed bitfields look "dubious".  The
> problem is that instead of being either 0 or 1 like people would expect,
> signed one bit variables like this are either 0 or -1.  It doesn't cause
> a problem in this case but it's ugly so lets fix them.

* walter harms (wharms@bfs.de) wrote:
> hi,
> This patch looks ok to me but this design is ugly by itself.
> It should be replaced by an uchar uint whatever or use a
> real bool (obviously not preferred by this programmes).

bool :1, uchar :1 or uint :1 could make sense. uchar:1/bool:1 won't save
any space here, because the surrounding fields are either uint or
pointers, so alignment will just add padding.

I try to use int/uint whenever possible because x86 CPUs tend to get
less register false-dependencies when using instructions modifying the
whole register (generated by using int/uint types) rather than only part
of it (uchar/char/bool). I only use char/uchar/bool when there is a
clear wanted space gain.

The reason why I never use the bool type within a structure when I want
a compact representation is that bool takes a whole byte just to
represent one bit:

struct usebitfield {
    int a;
    unsigned int f:1, g:1, h:1, i:1, j:1;
    int b;
};

struct usebool {
    int a;
    bool f, g, h, i, j;
    int b;
};

struct useboolbf {
    int a;
    bool f:1, g:1, h:1, i:1, j:1;
    int b;
};

int main()
{
    printf("bitfield %d bytes, bool %d bytes, boolbitfield %d bytes\n",
            sizeof(struct usebitfield), sizeof(struct usebool),
            sizeof(struct useboolbf));
}

result:

bitfield 12 bytes, bool 16 bytes, boolbitfield 12 bytes

This is because each bool takes one byte, while the bitfields are put in
units of "unsigned int" (or bool for the 3rd struct). So in this
example, we need 5 bytes + 3 bytes alignment for the bool, but only 4
bytes to hold the "unsigned int" unit for the bitfields.

The choice between bool and bitfields must also take into account the
frequency of access to the variable, because bitfields require mask
operations to access the selected bit(s). You will notice that none of
these bitfields are accessed on the tracing fast-path: only in
slow-paths. Therefore, space gain is more important than speed here.

One might argue that I have so few of these fields here that it does not
make an actual difference to go for bitfield or bool. I am just trying
to choose types best suited for their intended purpose, ensuring they
are future-proof and will allow simply adding more fields using the same
type, as needed.

So I guess I'll go for uint :1.

Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
staging: lttng: Fix recent modifications to string_from_user operation

Include: a fix for a recently introduced change: obviously max_t should
be used instead of min_t here. Also, a likely should apply to the result
of the comparison, not the variable per se.

Signed-off-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
staging: lttng: TODO update: lttng reported to work fine on -rt now

The patch "lttng: Fix recent modifications to string_from_user
operation" has been confirmed to fix the corrupted trace problem
experienced on -rt kernel by the original bug reporter. Remove the
entry from the LTTng TODO list.

Reported-by: Yannick Brosseau <yannick.brosseau@gmail.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
staging: lttng: Update max symbol length to 256

The user-space tracer, along with the control tools, now support longer
event name strings (up to 256 chars, including \0).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
LTTng update to v2.0.1

Update LTTng driver (in LTSI tree) to v2.0.1 from
git://git.lttng.org/lttng-modules.git, the external module package on which
development has continued.

Changelog:

2012-03-29 LTTng modules 2.0.1
	* Fix: is_compat_task !CONFIG_COMPAT compile error on kernels >= 3.3

2012-03-20 LTTng modules 2.0.0
	* First STABLE version
	* Add version name

2012-03-20 LTTng modules 2.0.0-rc4
	* Update README and add version name place-holder

2012-03-16 LTTng modules 2.0.0-rc3
	* Fix clock offset 32-bit multiplication overflow
	* Fix : wrong assign of fd in state dump
	* License cleanup, ifdef namespace cleanup
	* Fix: ensure power of 2 check handles 64-bit size_t entirely

2012-03-02 LTTng modules 2.0.0-rc2
	* Fix: dmesg printout should not print metadata warnings
	* Fix: use transport name as channel name
	* Fix: Return -EINVAL instead of print warning if non power of 2 size/num_subbuf

2012-02-20 LTTng modules 2.0.0-rc1
	* Standardize version across toolchain
	* statedump: Use old macro name for kernel 2.6.38

2012-02-16 LTTng modules 2.0-pre15
	* Add timer instrumentation
	* fix: need to undef mainline define
	* fix: Include signal.h instead of irq.h for prototype match check
	* Add signal instrumentation

2012-02-16 LTTng modules 2.0-pre14
	* syscall tracing: sys_getcpu
	* Add sys_clone x86 instrumentation
	* statedump: fix include circular dep
	* Implement state dump

2012-02-09 LTTng modules 2.0-pre13
	* Update README
	* environment: write sysname, release, version, domain to metadata
	* Allow open /proc/lttng for read & write

2012-02-02 LTTng modules 2.0-pre12
	* Add x86 32/64 execve syscall instrumentation override
	* Remove unused defines
	* Add padding to ABI
	* Use LTTNG_KERNEL_SYM_NAME_LEN
	* Update version to 1.9.9
	* Add missing double-quotes to clock uuid
	* clock: read bootid as clock monotonic ID
	* Fix comment
	* Cleanup comment
	* clock: output clock description in metadata
	* Properly fix the timekeeping overflow detection
	* Fix init bug
	* rename lib-ring-buffer to lttng-lib-ring-buffer
	* Remove #warning
	* Mass rename: ltt_*/ltt-* to LTTNG_*/LTTNG-*
	* Update TODO
	* Update TODO
	* Remove debugfs file (keep only proc file)
	* Rename lttng-debugfs-abi files to lttng-abi

2011-12-13 LTTng modules 2.0-pre11
	* Fix OOPS caused by reference of config pointer
	* Gather detailed info from x86 64 32-bit compat syscall instrumentation
	* lttng lib: ring buffer move null pointer check to open
	* lttng lib: ring buffer remove duplicate null pointer
	* lttng lib: ring buffer: remove stale null-pointer
	* lttng wrapper: add missing include to kallsyms wrapper
	* lttng: cleanup one-bit signed bitfields
	* Add TODO file
	* Update symbol name length max size to 256
	* Fix last modifications to string_from_user operations
	* Document that depmod needs to be executed by hand
	* Fix strlen_user fault space reservation
	* Fix tp_copy_string_from_user handling of faults
	* Disable block layer tracing support for kernels < 2.6.38
	* lttng context: perf counter, fix 32-bit vs 64-bit field size bug
	* Update trace clock warning to match the current development plan
	* ringbuffer: make ring buffer printk less verbose
	* Makefile: do not run depmod manually

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
CC: Greg KH <gregkh@linuxfoundation.org>
CC: Tim Bird <tim.bird@am.sony.com>
CC: ltsi-dev@lists.linuxfoundation.org
LTTng staging update 2.0.1 to 2.0.4

Update LTTng in LTSI staging from lttng-modules 2.0.1 to 2.0.4.
(available at: git://git.lttng.org/lttng-modules.git)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
LTTng: fix module name: lttng-relay.ko => lttng-tracer.ko

It seems lttng-tools 2.0 expects lttng-tracer.ko instead of
lttng-relay.ko.

Signed-off-by: UCHINO Satoshi <satoshi.uchino@toshiba.co.jp>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
net: bus: add the AF_BUS socket address family

AF_BUS is a new socket address family that allows both unicast and
multicast I on a local machine with total ordering for messages
(every process on the same bus sees each message in the same order).

A process can create buses to which other processes can connect and
communicate with each other by sending messages. Processes' addresses are
automatically assigned by the bus on connect and are unique. Messages can
be sent either to process' unique address or to a bus multicast address.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
net: bus: Add AF_BUS documentation

AF_BUS is different to other POSIX BSD sockets address families so a
is good to have a documentation about its design, ABI and semantics.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
net: bus: add af_bus address and af_bus socket address definitions

An AF_BUS socket can have many addresses associated. This allows to send
multicast packets on different domains. An af_bus address is an unsigned
64-bit value that contains two fields: a 16-bit prefix and a 48-bit client
address.

Each bus has an associated path name that uniquely identifies the bus.
So, a socket address is composed of the bus path and the peer address.

Clients can send unicast packets to each other and multicast to different
prefixes but they can only connect(2) to a special socket that owns the
bus an is known as the bus master.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
security: Add Linux Security Modules hook for AF_BUS sockets

AF_BUS implements a security hook bus_connect() to be used by LSM
to enforce connectivity security policies.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
security: selinux: Add AF_BUS socket SELinux hooks

Add Security-Enhanced Linux (SELinux) hook for AF_BUS socket address family.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
netfilter: add NFPROTO_BUS hook constant for AF_BUS socket family

AF_BUS sockets add a netfilter NF_HOOK() on the packet sending path.
This allows packet to be mangled by registered netfilter hooks.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
scm: allow AF_BUS sockets to send ancillary data

UNIX domain sockets support passing file descriptors or process
credentials in the form of ancillary data.

Since AF_BUS sockets are used to communicate processes on a local
machine, they should also support passing control messages.
The core socket level control messages processing only allows sockets
whose family is PF_UNIX to send SCM_RIGHTS type messages. So, let's
also allow to PF_BUS sockets.

Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>