10 Jun, 2016

1 commit

  • Socket option PACKET_FANOUT_DATA takes a struct sock_fprog as argument
    if PACKET_FANOUT has mode PACKET_FANOUT_CBPF. This structure contains
    a pointer into user memory. If userland is 32-bit and kernel is 64-bit
    the two disagree about the layout of struct sock_fprog.

    Add compat setsockopt support to convert a 32-bit compat_sock_fprog to
    a 64-bit sock_fprog. This is analogous to compat_sock_fprog support for
    SO_REUSEPORT added in commit 1957598840f4 ("soreuseport: add compat
    case for setsockopt SO_ATTACH_REUSEPORT_CBPF").

    Reported-by: Daniel Borkmann
    Signed-off-by: Willem de Bruijn
    Acked-by: Daniel Borkmann
    Signed-off-by: David S. Miller

    Willem de Bruijn
     

07 Jun, 2016

1 commit


09 Apr, 2015

1 commit


24 Mar, 2015

1 commit


21 Mar, 2015

2 commits

  • Conflicts:
    drivers/net/ethernet/emulex/benet/be_main.c
    net/core/sysctl_net_core.c
    net/ipv4/inet_diag.c

    The be_main.c conflict resolution was really tricky. The conflict
    hunks generated by GIT were very unhelpful, to say the least. It
    split functions in half and moved them around, when the real actual
    conflict only existed solely inside of one function, that being
    be_map_pci_bars().

    So instead, to resolve this, I checked out be_main.c from the top
    of net-next, then I applied the be_main.c changes from 'net' since
    the last time I merged. And this worked beautifully.

    The inet_diag.c and sysctl_net_core.c conflicts were simple
    overlapping changes, and were easily to resolve.

    Signed-off-by: David S. Miller

    David S. Miller
     
  • Commit db31c55a6fb2 (net: clamp ->msg_namelen instead of returning an
    error) introduced the clamping of msg_namelen when the unsigned value
    was larger than sizeof(struct sockaddr_storage). This caused a
    msg_namelen of -1 to be valid. The native code was subsequently fixed by
    commit dbb490b96584 (net: socket: error on a negative msg_namelen).

    In addition, the native code sets msg_namelen to 0 when msg_name is
    NULL. This was done in commit (6a2a2b3ae075 net:socket: set msg_namelen
    to 0 if msg_name is passed as NULL in msghdr struct from userland) and
    subsequently updated by 08adb7dabd48 (fold verify_iovec() into
    copy_msghdr_from_user()).

    This patch brings the get_compat_msghdr() in line with
    copy_msghdr_from_user().

    Fixes: db31c55a6fb2 (net: clamp ->msg_namelen instead of returning an error)
    Cc: David S. Miller
    Cc: Dan Carpenter
    Signed-off-by: Catalin Marinas
    Signed-off-by: David S. Miller

    Catalin Marinas
     

04 Mar, 2015

1 commit


24 Feb, 2015

1 commit

  • With commit a7526eb5d06b (net: Unbreak compat_sys_{send,recv}msg), the
    MSG_CMSG_COMPAT flag is blocked at the compat syscall entry points,
    changing the kernel compat behaviour from the one before the commit it
    was trying to fix (1be374a0518a, net: Block MSG_CMSG_COMPAT in
    send(m)msg and recv(m)msg).

    On 32-bit kernels (!CONFIG_COMPAT), MSG_CMSG_COMPAT is 0 and the native
    32-bit sys_sendmsg() allows flag 0x80000000 to be set (it is ignored by
    the kernel). However, on a 64-bit kernel, the compat ABI is different
    with commit a7526eb5d06b.

    This patch changes the compat_sys_{send,recv}msg behaviour to the one
    prior to commit 1be374a0518a.

    The problem was found running 32-bit LTP (sendmsg01) binary on an arm64
    kernel. Arguably, LTP should not pass 0xffffffff as flags to sendmsg()
    but the general rule is not to break user ABI (even when the user
    behaviour is not entirely sane).

    Fixes: a7526eb5d06b (net: Unbreak compat_sys_{send,recv}msg)
    Cc: Andy Lutomirski
    Cc: David S. Miller
    Signed-off-by: Catalin Marinas
    Signed-off-by: David S. Miller

    Catalin Marinas
     

23 Feb, 2015

1 commit


10 Dec, 2014

1 commit

  • Note that the code _using_ ->msg_iter at that point will be very
    unhappy with anything other than unshifted iovec-backed iov_iter.
    We still need to convert users to proper primitives.

    Signed-off-by: Al Viro

    Al Viro
     

20 Nov, 2014

3 commits

  • ... and do the same on the compat side of things.

    Signed-off-by: Al Viro

    Al Viro
     
  • use {compat_,}rw_copy_check_uvector(). As the result, we are
    guaranteed that all iovecs seen in ->msg_iov by ->sendmsg()
    and ->recvmsg() will pass access_ok().

    Signed-off-by: Al Viro

    Al Viro
     
  • Kernel-side struct msghdr is (currently) using the same layout as
    userland one, but it's not a one-to-one copy - even without considering
    32bit compat issues, we have msg_iov, msg_name and msg_control copied
    to kernel[1]. It's fairly localized, so we get away with a few functions
    where that knowledge is needed (and we could shrink that set even
    more). Pretty much everything deals with the kernel-side variant and
    the few places that want userland one just use a bunch of force-casts
    to paper over the differences.

    The thing is, kernel-side definition of struct msghdr is *not* exposed
    in include/uapi - libc doesn't see it, etc. So we can add struct user_msghdr,
    with proper annotations and let the few places that ever deal with those
    beasts use it for userland pointers. Saner typechecking aside, that will
    allow to change the layout of kernel-side msghdr - e.g. replace
    msg_iov/msg_iovlen there with struct iov_iter, getting rid of the need
    to modify the iovec as we copy data to/from it, etc.

    We could introduce kernel_msghdr instead, but that would create much more
    noise - the absolute majority of the instances would need to have the
    type switched to kernel_msghdr and definition of struct msghdr in
    include/linux/socket.h is not going to be seen by userland anyway.

    This commit just introduces user_msghdr and switches the few places that
    are dealing with userland-side msghdr to it.

    [1] actually, it's even trickier than that - we copy msg_control for
    sendmsg, but keep the userland address on recvmsg.

    Signed-off-by: Al Viro

    Al Viro
     

30 Jul, 2014

1 commit

  • Sasha's report:
    > While fuzzing with trinity inside a KVM tools guest running the latest -next
    > kernel with the KASAN patchset, I've stumbled on the following spew:
    >
    > [ 4448.949424] ==================================================================
    > [ 4448.951737] AddressSanitizer: user-memory-access on address 0
    > [ 4448.952988] Read of size 2 by thread T19638:
    > [ 4448.954510] CPU: 28 PID: 19638 Comm: trinity-c76 Not tainted 3.16.0-rc4-next-20140711-sasha-00046-g07d3099-dirty #813
    > [ 4448.956823] ffff88046d86ca40 0000000000000000 ffff880082f37e78 ffff880082f37a40
    > [ 4448.958233] ffffffffb6e47068 ffff880082f37a68 ffff880082f37a58 ffffffffb242708d
    > [ 4448.959552] 0000000000000000 ffff880082f37a88 ffffffffb24255b1 0000000000000000
    > [ 4448.961266] Call Trace:
    > [ 4448.963158] dump_stack (lib/dump_stack.c:52)
    > [ 4448.964244] kasan_report_user_access (mm/kasan/report.c:184)
    > [ 4448.965507] __asan_load2 (mm/kasan/kasan.c:352)
    > [ 4448.966482] ? netlink_sendmsg (net/netlink/af_netlink.c:2339)
    > [ 4448.967541] netlink_sendmsg (net/netlink/af_netlink.c:2339)
    > [ 4448.968537] ? get_parent_ip (kernel/sched/core.c:2555)
    > [ 4448.970103] sock_sendmsg (net/socket.c:654)
    > [ 4448.971584] ? might_fault (mm/memory.c:3741)
    > [ 4448.972526] ? might_fault (./arch/x86/include/asm/current.h:14 mm/memory.c:3740)
    > [ 4448.973596] ? verify_iovec (net/core/iovec.c:64)
    > [ 4448.974522] ___sys_sendmsg (net/socket.c:2096)
    > [ 4448.975797] ? put_lock_stats.isra.13 (./arch/x86/include/asm/preempt.h:98 kernel/locking/lockdep.c:254)
    > [ 4448.977030] ? lock_release_holdtime (kernel/locking/lockdep.c:273)
    > [ 4448.978197] ? lock_release_non_nested (kernel/locking/lockdep.c:3434 (discriminator 1))
    > [ 4448.979346] ? check_chain_key (kernel/locking/lockdep.c:2188)
    > [ 4448.980535] __sys_sendmmsg (net/socket.c:2181)
    > [ 4448.981592] ? trace_hardirqs_on_caller (kernel/locking/lockdep.c:2600)
    > [ 4448.982773] ? trace_hardirqs_on (kernel/locking/lockdep.c:2607)
    > [ 4448.984458] ? syscall_trace_enter (arch/x86/kernel/ptrace.c:1500 (discriminator 2))
    > [ 4448.985621] ? trace_hardirqs_on_caller (kernel/locking/lockdep.c:2600)
    > [ 4448.986754] SyS_sendmmsg (net/socket.c:2201)
    > [ 4448.987708] tracesys (arch/x86/kernel/entry_64.S:542)
    > [ 4448.988929] ==================================================================

    This reports means that we've come to netlink_sendmsg() with msg->msg_name == NULL and msg->msg_namelen > 0.

    After this report there was no usual "Unable to handle kernel NULL pointer dereference"
    and this gave me a clue that address 0 is mapped and contains valid socket address structure in it.

    This bug was introduced in f3d3342602f8bcbf37d7c46641cb9bca7618eb1c
    (net: rework recvmsg handler msg_name and msg_namelen logic).
    Commit message states that:
    "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."
    But in fact this affects sendto when address 0 is mapped and contains
    socket address structure in it. In such case copy-in address will succeed,
    verify_iovec() function will successfully exit with msg->msg_namelen > 0
    and msg->msg_name == NULL.

    This patch fixes it by setting msg_namelen to 0 if msg_name == NULL.

    Cc: Hannes Frederic Sowa
    Cc: Eric Dumazet
    Cc:
    Reported-by: Sasha Levin
    Signed-off-by: Andrey Ryabinin
    Acked-by: Hannes Frederic Sowa
    Signed-off-by: David S. Miller

    Andrey Ryabinin
     

06 Mar, 2014

2 commits


31 Jan, 2014

1 commit

  • The x32 case for the recvmsg() timout handling is broken:

    asmlinkage long compat_sys_recvmmsg(int fd, struct compat_mmsghdr __user *mmsg,
    unsigned int vlen, unsigned int flags,
    struct compat_timespec __user *timeout)
    {
    int datagrams;
    struct timespec ktspec;

    if (flags & MSG_CMSG_COMPAT)
    return -EINVAL;

    if (COMPAT_USE_64BIT_TIME)
    return __sys_recvmmsg(fd, (struct mmsghdr __user *)mmsg, vlen,
    flags | MSG_CMSG_COMPAT,
    (struct timespec *) timeout);
    ...

    The timeout pointer parameter is provided by userland (hence the __user
    annotation) but for x32 syscalls it's simply cast to a kernel pointer
    and is passed to __sys_recvmmsg which will eventually directly
    dereference it for both reading and writing. Other callers to
    __sys_recvmmsg properly copy from userland to the kernel first.

    The bug was introduced by commit ee4fa23c4bfc ("compat: Use
    COMPAT_USE_64BIT_TIME in net/compat.c") and should affect all kernels
    since 3.4 (and perhaps vendor kernels if they backported x32 support
    along with this code).

    Note that CONFIG_X86_X32_ABI gets enabled at build time and only if
    CONFIG_X86_X32 is enabled and ld can build x32 executables.

    Other uses of COMPAT_USE_64BIT_TIME seem fine.

    This addresses CVE-2014-0038.

    Signed-off-by: PaX Team
    Signed-off-by: H. Peter Anvin
    Cc: # v3.4+
    Signed-off-by: Linus Torvalds

    PaX Team
     

30 Nov, 2013

1 commit

  • If kmsg->msg_namelen > sizeof(struct sockaddr_storage) then in the
    original code that would lead to memory corruption in the kernel if you
    had audit configured. If you didn't have audit configured it was
    harmless.

    There are some programs such as beta versions of Ruby which use too
    large of a buffer and returning an error code breaks them. We should
    clamp the ->msg_namelen value instead.

    Fixes: 1661bf364ae9 ("net: heap overflow in __audit_sockaddr()")
    Reported-by: Eric Wong
    Signed-off-by: Dan Carpenter
    Tested-by: Eric Wong
    Acked-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Dan Carpenter
     

21 Nov, 2013

1 commit


04 Oct, 2013

1 commit

  • We need to cap ->msg_namelen or it leads to a buffer overflow when we
    to the memcpy() in __audit_sockaddr(). It requires CAP_AUDIT_CONTROL to
    exploit this bug.

    The call tree is:
    ___sys_recvmsg()
    move_addr_to_user()
    audit_sockaddr()
    __audit_sockaddr()

    Reported-by: Jüri Aedla
    Signed-off-by: Dan Carpenter
    Signed-off-by: David S. Miller

    Dan Carpenter
     

07 Jun, 2013

1 commit

  • I broke them in this commit:

    commit 1be374a0518a288147c6a7398792583200a67261
    Author: Andy Lutomirski
    Date: Wed May 22 14:07:44 2013 -0700

    net: Block MSG_CMSG_COMPAT in send(m)msg and recv(m)msg

    This patch adds __sys_sendmsg and __sys_sendmsg as common helpers that accept
    MSG_CMSG_COMPAT and blocks MSG_CMSG_COMPAT at the syscall entrypoints. It
    also reverts some unnecessary checks in sys_socketcall.

    Apparently I was suffering from underscore blindness the first time around.

    Signed-off-by: Andy Lutomirski
    Tested-by: Eric Dumazet
    Signed-off-by: David S. Miller

    Andy Lutomirski
     

27 Sep, 2012

1 commit


23 Jul, 2012

1 commit

  • In net/compat.c::put_cmsg_compat() we may assign 'data' the address of
    either the 'ctv' or 'cts' local variables inside the 'if
    (!COMPAT_USE_64BIT_TIME)' branch.

    Those variables go out of scope at the end of the 'if' statement, so
    when we use 'data' further down in 'copy_to_user(CMSG_COMPAT_DATA(cm),
    data, cmlen - sizeof(struct compat_cmsghdr))' there's no telling what
    it may be refering to - not good.

    Fix the problem by simply giving 'ctv' and 'cts' function scope.

    Signed-off-by: Jesper Juhl
    Signed-off-by: David S. Miller

    Jesper Juhl
     

22 May, 2012

1 commit

  • Pull security subsystem updates from James Morris:
    "New notable features:
    - The seccomp work from Will Drewry
    - PR_{GET,SET}_NO_NEW_PRIVS from Andy Lutomirski
    - Longer security labels for Smack from Casey Schaufler
    - Additional ptrace restriction modes for Yama by Kees Cook"

    Fix up trivial context conflicts in arch/x86/Kconfig and include/linux/filter.h

    * 'next' of git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security: (65 commits)
    apparmor: fix long path failure due to disconnected path
    apparmor: fix profile lookup for unconfined
    ima: fix filename hint to reflect script interpreter name
    KEYS: Don't check for NULL key pointer in key_validate()
    Smack: allow for significantly longer Smack labels v4
    gfp flags for security_inode_alloc()?
    Smack: recursive tramsmute
    Yama: replace capable() with ns_capable()
    TOMOYO: Accept manager programs which do not start with / .
    KEYS: Add invalidation support
    KEYS: Do LRU discard in full keyrings
    KEYS: Permit in-place link replacement in keyring list
    KEYS: Perform RCU synchronisation on keys prior to key destruction
    KEYS: Announce key type (un)registration
    KEYS: Reorganise keys Makefile
    KEYS: Move the key config into security/keys/Kconfig
    KEYS: Use the compat keyctl() syscall wrapper on Sparc64 for Sparc32 compat
    Yama: remove an unused variable
    samples/seccomp: fix dependencies on arch macros
    Yama: add additional ptrace scopes
    ...

    Linus Torvalds
     

16 Apr, 2012

1 commit


14 Apr, 2012

1 commit

  • Any other users of bpf_*_filter that take a struct sock_fprog from
    userspace will need to be able to also accept a compat_sock_fprog
    if the arch supports compat calls. This change allows the existing
    compat_sock_fprog be shared.

    Signed-off-by: Will Drewry
    Acked-by: Serge Hallyn
    Acked-by: Eric Dumazet
    Acked-by: Eric Paris

    v18: tasered by the apostrophe police
    v14: rebase/nochanges
    v13: rebase on to 88ebdda6159ffc15699f204c33feb3e431bf9bdc
    v12: rebase on to linux-next
    v11: introduction
    Signed-off-by: James Morris

    Will Drewry
     

30 Mar, 2012

1 commit

  • Pull x32 support for x86-64 from Ingo Molnar:
    "This tree introduces the X32 binary format and execution mode for x86:
    32-bit data space binaries using 64-bit instructions and 64-bit kernel
    syscalls.

    This allows applications whose working set fits into a 32 bits address
    space to make use of 64-bit instructions while using a 32-bit address
    space with shorter pointers, more compressed data structures, etc."

    Fix up trivial context conflicts in arch/x86/{Kconfig,vdso/vma.c}

    * 'x86-x32-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: (71 commits)
    x32: Fix alignment fail in struct compat_siginfo
    x32: Fix stupid ia32/x32 inversion in the siginfo format
    x32: Add ptrace for x32
    x32: Switch to a 64-bit clock_t
    x32: Provide separate is_ia32_task() and is_x32_task() predicates
    x86, mtrr: Use explicit sizing and padding for the 64-bit ioctls
    x86/x32: Fix the binutils auto-detect
    x32: Warn and disable rather than error if binutils too old
    x32: Only clear TIF_X32 flag once
    x32: Make sure TS_COMPAT is cleared for x32 tasks
    fs: Remove missed ->fds_bits from cessation use of fd_set structs internally
    fs: Fix close_on_exec pointer in alloc_fdtable
    x32: Drop non-__vdso weak symbols from the x32 VDSO
    x32: Fix coding style violations in the x32 VDSO code
    x32: Add x32 VDSO support
    x32: Allow x32 to be configured
    x32: If configured, add x32 system calls to system call tables
    x32: Handle process creation
    x32: Signal-related system calls
    x86: Add #ifdef CONFIG_COMPAT to
    ...

    Linus Torvalds
     

12 Mar, 2012

1 commit

  • The following 4 functions:
    move_addr_to_kernel
    move_addr_to_user
    verify_iovec
    verify_compat_iovec
    are always effectively called with a sockaddr_storage.

    Make this explicit by changing their signature.

    This removes a large number of casts from sockaddr_storage to sockaddr.

    Signed-off-by: Maciej Żenczykowski
    Signed-off-by: David S. Miller

    Maciej Żenczykowski
     

21 Feb, 2012

1 commit


01 Nov, 2011

1 commit


06 May, 2011

1 commit

  • This patch adds a multiple message send syscall and is the send
    version of the existing recvmmsg syscall. This is heavily
    based on the patch by Arnaldo that added recvmmsg.

    I wrote a microbenchmark to test the performance gains of using
    this new syscall:

    http://ozlabs.org/~anton/junkcode/sendmmsg_test.c

    The test was run on a ppc64 box with a 10 Gbit network card. The
    benchmark can send both UDP and RAW ethernet packets.

    64B UDP

    batch pkts/sec
    1 804570
    2 872800 (+ 8 %)
    4 916556 (+14 %)
    8 939712 (+17 %)
    16 952688 (+18 %)
    32 956448 (+19 %)
    64 964800 (+20 %)

    64B raw socket

    batch pkts/sec
    1 1201449
    2 1350028 (+12 %)
    4 1461416 (+22 %)
    8 1513080 (+26 %)
    16 1541216 (+28 %)
    32 1553440 (+29 %)
    64 1557888 (+30 %)

    We see a 20% improvement in throughput on UDP send and 30%
    on raw socket send.

    [ Add sparc syscall entries. -DaveM ]

    Signed-off-by: Anton Blanchard
    Signed-off-by: David S. Miller

    Anton Blanchard
     

29 Oct, 2010

1 commit

  • This helps protect us from overflow issues down in the
    individual protocol sendmsg/recvmsg handlers. Once
    we hit INT_MAX we truncate out the rest of the iovec
    by setting the iov_len members to zero.

    This works because:

    1) For SOCK_STREAM and SOCK_SEQPACKET sockets, partial
    writes are allowed and the application will just continue
    with another write to send the rest of the data.

    2) For datagram oriented sockets, where there must be a
    one-to-one correspondance between write() calls and
    packets on the wire, INT_MAX is going to be far larger
    than the packet size limit the protocol is going to
    check for and signal with -EMSGSIZE.

    Based upon a patch by Linus Torvalds.

    Signed-off-by: David S. Miller

    David S. Miller
     

04 Jun, 2010

1 commit

  • From: Eric Dumazet
    Date: Thu, 3 Jun 2010 04:29:41 +0000
    Subject: [PATCH 2/3] net: net/socket.c and net/compat.c cleanups

    cleanup patch, to match modern coding style.

    Signed-off-by: Eric Dumazet
    Signed-off-by: David S. Miller
    ---
    net/compat.c | 47 ++++++++---------
    net/socket.c | 165 ++++++++++++++++++++++++++++------------------------------
    2 files changed, 102 insertions(+), 110 deletions(-)

    diff --git a/net/compat.c b/net/compat.c
    index 1cf7590..63d260e 100644
    --- a/net/compat.c
    +++ b/net/compat.c
    @@ -81,7 +81,7 @@ int verify_compat_iovec(struct msghdr *kern_msg, struct iovec *kern_iov,
    int tot_len;

    if (kern_msg->msg_namelen) {
    - if (mode==VERIFY_READ) {
    + if (mode == VERIFY_READ) {
    int err = move_addr_to_kernel(kern_msg->msg_name,
    kern_msg->msg_namelen,
    kern_address);
    @@ -354,7 +354,7 @@ static int do_set_attach_filter(struct socket *sock, int level, int optname,
    static int do_set_sock_timeout(struct socket *sock, int level,
    int optname, char __user *optval, unsigned int optlen)
    {
    - struct compat_timeval __user *up = (struct compat_timeval __user *) optval;
    + struct compat_timeval __user *up = (struct compat_timeval __user *)optval;
    struct timeval ktime;
    mm_segment_t old_fs;
    int err;
    @@ -367,7 +367,7 @@ static int do_set_sock_timeout(struct socket *sock, int level,
    return -EFAULT;
    old_fs = get_fs();
    set_fs(KERNEL_DS);
    - err = sock_setsockopt(sock, level, optname, (char *) &ktime, sizeof(ktime));
    + err = sock_setsockopt(sock, level, optname, (char *)&ktime, sizeof(ktime));
    set_fs(old_fs);

    return err;
    @@ -389,11 +389,10 @@ asmlinkage long compat_sys_setsockopt(int fd, int level, int optname,
    char __user *optval, unsigned int optlen)
    {
    int err;
    - struct socket *sock;
    + struct socket *sock = sockfd_lookup(fd, &err);

    - if ((sock = sockfd_lookup(fd, &err))!=NULL)
    - {
    - err = security_socket_setsockopt(sock,level,optname);
    + if (sock) {
    + err = security_socket_setsockopt(sock, level, optname);
    if (err) {
    sockfd_put(sock);
    return err;
    @@ -453,7 +452,7 @@ static int compat_sock_getsockopt(struct socket *sock, int level, int optname,
    int compat_sock_get_timestamp(struct sock *sk, struct timeval __user *userstamp)
    {
    struct compat_timeval __user *ctv =
    - (struct compat_timeval __user*) userstamp;
    + (struct compat_timeval __user *) userstamp;
    int err = -ENOENT;
    struct timeval tv;

    @@ -477,7 +476,7 @@ EXPORT_SYMBOL(compat_sock_get_timestamp);
    int compat_sock_get_timestampns(struct sock *sk, struct timespec __user *userstamp)
    {
    struct compat_timespec __user *ctv =
    - (struct compat_timespec __user*) userstamp;
    + (struct compat_timespec __user *) userstamp;
    int err = -ENOENT;
    struct timespec ts;

    @@ -502,12 +501,10 @@ asmlinkage long compat_sys_getsockopt(int fd, int level, int optname,
    char __user *optval, int __user *optlen)
    {
    int err;
    - struct socket *sock;
    + struct socket *sock = sockfd_lookup(fd, &err);

    - if ((sock = sockfd_lookup(fd, &err))!=NULL)
    - {
    - err = security_socket_getsockopt(sock, level,
    - optname);
    + if (sock) {
    + err = security_socket_getsockopt(sock, level, optname);
    if (err) {
    sockfd_put(sock);
    return err;
    @@ -557,7 +554,7 @@ struct compat_group_filter {

    int compat_mc_setsockopt(struct sock *sock, int level, int optname,
    char __user *optval, unsigned int optlen,
    - int (*setsockopt)(struct sock *,int,int,char __user *,unsigned int))
    + int (*setsockopt)(struct sock *, int, int, char __user *, unsigned int))
    {
    char __user *koptval = optval;
    int koptlen = optlen;
    @@ -640,12 +637,11 @@ int compat_mc_setsockopt(struct sock *sock, int level, int optname,
    }
    return setsockopt(sock, level, optname, koptval, koptlen);
    }
    -
    EXPORT_SYMBOL(compat_mc_setsockopt);

    int compat_mc_getsockopt(struct sock *sock, int level, int optname,
    char __user *optval, int __user *optlen,
    - int (*getsockopt)(struct sock *,int,int,char __user *,int __user *))
    + int (*getsockopt)(struct sock *, int, int, char __user *, int __user *))
    {
    struct compat_group_filter __user *gf32 = (void *)optval;
    struct group_filter __user *kgf;
    @@ -681,7 +677,7 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
    __put_user(interface, &kgf->gf_interface) ||
    __put_user(fmode, &kgf->gf_fmode) ||
    __put_user(numsrc, &kgf->gf_numsrc) ||
    - copy_in_user(&kgf->gf_group,&gf32->gf_group,sizeof(kgf->gf_group)))
    + copy_in_user(&kgf->gf_group, &gf32->gf_group, sizeof(kgf->gf_group)))
    return -EFAULT;

    err = getsockopt(sock, level, optname, (char __user *)kgf, koptlen);
    @@ -714,21 +710,22 @@ int compat_mc_getsockopt(struct sock *sock, int level, int optname,
    copylen = numsrc * sizeof(gf32->gf_slist[0]);
    if (copylen > klen)
    copylen = klen;
    - if (copy_in_user(gf32->gf_slist, kgf->gf_slist, copylen))
    + if (copy_in_user(gf32->gf_slist, kgf->gf_slist, copylen))
    return -EFAULT;
    }
    return err;
    }
    -
    EXPORT_SYMBOL(compat_mc_getsockopt);

    /* Argument list sizes for compat_sys_socketcall */
    #define AL(x) ((x) * sizeof(u32))
    -static unsigned char nas[20]={AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
    - AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
    - AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
    - AL(4),AL(5)};
    +static unsigned char nas[20] = {
    + AL(0), AL(3), AL(3), AL(3), AL(2), AL(3),
    + AL(3), AL(3), AL(4), AL(4), AL(4), AL(6),
    + AL(6), AL(2), AL(5), AL(5), AL(3), AL(3),
    + AL(4), AL(5)
    +};
    #undef AL

    asmlinkage long compat_sys_sendmsg(int fd, struct compat_msghdr __user *msg, unsigned flags)
    @@ -827,7 +824,7 @@ asmlinkage long compat_sys_socketcall(int call, u32 __user *args)
    compat_ptr(a[4]), compat_ptr(a[5]));
    break;
    case SYS_SHUTDOWN:
    - ret = sys_shutdown(a0,a1);
    + ret = sys_shutdown(a0, a1);
    break;
    case SYS_SETSOCKOPT:
    ret = compat_sys_setsockopt(a0, a1, a[2],
    diff --git a/net/socket.c b/net/socket.c
    index 367d547..b63c051 100644
    --- a/net/socket.c
    +++ b/net/socket.c
    @@ -124,7 +124,7 @@ static int sock_fasync(int fd, struct file *filp, int on);
    static ssize_t sock_sendpage(struct file *file, struct page *page,
    int offset, size_t size, loff_t *ppos, int more);
    static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
    - struct pipe_inode_info *pipe, size_t len,
    + struct pipe_inode_info *pipe, size_t len,
    unsigned int flags);

    /*
    @@ -162,7 +162,7 @@ static const struct net_proto_family *net_families[NPROTO] __read_mostly;
    * Statistics counters of the socket lists
    */

    -static DEFINE_PER_CPU(int, sockets_in_use) = 0;
    +static DEFINE_PER_CPU(int, sockets_in_use);

    /*
    * Support routines.
    @@ -309,9 +309,9 @@ static int init_inodecache(void)
    }

    static const struct super_operations sockfs_ops = {
    - .alloc_inode = sock_alloc_inode,
    - .destroy_inode =sock_destroy_inode,
    - .statfs = simple_statfs,
    + .alloc_inode = sock_alloc_inode,
    + .destroy_inode = sock_destroy_inode,
    + .statfs = simple_statfs,
    };

    static int sockfs_get_sb(struct file_system_type *fs_type,
    @@ -411,6 +411,7 @@ int sock_map_fd(struct socket *sock, int flags)

    return fd;
    }
    +EXPORT_SYMBOL(sock_map_fd);

    static struct socket *sock_from_file(struct file *file, int *err)
    {
    @@ -422,7 +423,7 @@ static struct socket *sock_from_file(struct file *file, int *err)
    }

    /**
    - * sockfd_lookup - Go from a file number to its socket slot
    + * sockfd_lookup - Go from a file number to its socket slot
    * @fd: file handle
    * @err: pointer to an error code return
    *
    @@ -450,6 +451,7 @@ struct socket *sockfd_lookup(int fd, int *err)
    fput(file);
    return sock;
    }
    +EXPORT_SYMBOL(sockfd_lookup);

    static struct socket *sockfd_lookup_light(int fd, int *err, int *fput_needed)
    {
    @@ -540,6 +542,7 @@ void sock_release(struct socket *sock)
    }
    sock->file = NULL;
    }
    +EXPORT_SYMBOL(sock_release);

    int sock_tx_timestamp(struct msghdr *msg, struct sock *sk,
    union skb_shared_tx *shtx)
    @@ -586,6 +589,7 @@ int sock_sendmsg(struct socket *sock, struct msghdr *msg, size_t size)
    ret = wait_on_sync_kiocb(&iocb);
    return ret;
    }
    +EXPORT_SYMBOL(sock_sendmsg);

    int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
    struct kvec *vec, size_t num, size_t size)
    @@ -604,6 +608,7 @@ int kernel_sendmsg(struct socket *sock, struct msghdr *msg,
    set_fs(oldfs);
    return result;
    }
    +EXPORT_SYMBOL(kernel_sendmsg);

    static int ktime2ts(ktime_t kt, struct timespec *ts)
    {
    @@ -664,7 +669,6 @@ void __sock_recv_timestamp(struct msghdr *msg, struct sock *sk,
    put_cmsg(msg, SOL_SOCKET,
    SCM_TIMESTAMPING, sizeof(ts), &ts);
    }
    -
    EXPORT_SYMBOL_GPL(__sock_recv_timestamp);

    inline void sock_recv_drops(struct msghdr *msg, struct sock *sk, struct sk_buff *skb)
    @@ -720,6 +724,7 @@ int sock_recvmsg(struct socket *sock, struct msghdr *msg,
    ret = wait_on_sync_kiocb(&iocb);
    return ret;
    }
    +EXPORT_SYMBOL(sock_recvmsg);

    static int sock_recvmsg_nosec(struct socket *sock, struct msghdr *msg,
    size_t size, int flags)
    @@ -752,6 +757,7 @@ int kernel_recvmsg(struct socket *sock, struct msghdr *msg,
    set_fs(oldfs);
    return result;
    }
    +EXPORT_SYMBOL(kernel_recvmsg);

    static void sock_aio_dtor(struct kiocb *iocb)
    {
    @@ -774,7 +780,7 @@ static ssize_t sock_sendpage(struct file *file, struct page *page,
    }

    static ssize_t sock_splice_read(struct file *file, loff_t *ppos,
    - struct pipe_inode_info *pipe, size_t len,
    + struct pipe_inode_info *pipe, size_t len,
    unsigned int flags)
    {
    struct socket *sock = file->private_data;
    @@ -887,7 +893,7 @@ static ssize_t sock_aio_write(struct kiocb *iocb, const struct iovec *iov,
    */

    static DEFINE_MUTEX(br_ioctl_mutex);
    -static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg) = NULL;
    +static int (*br_ioctl_hook) (struct net *, unsigned int cmd, void __user *arg);

    void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *))
    {
    @@ -895,7 +901,6 @@ void brioctl_set(int (*hook) (struct net *, unsigned int, void __user *))
    br_ioctl_hook = hook;
    mutex_unlock(&br_ioctl_mutex);
    }
    -
    EXPORT_SYMBOL(brioctl_set);

    static DEFINE_MUTEX(vlan_ioctl_mutex);
    @@ -907,7 +912,6 @@ void vlan_ioctl_set(int (*hook) (struct net *, void __user *))
    vlan_ioctl_hook = hook;
    mutex_unlock(&vlan_ioctl_mutex);
    }
    -
    EXPORT_SYMBOL(vlan_ioctl_set);

    static DEFINE_MUTEX(dlci_ioctl_mutex);
    @@ -919,7 +923,6 @@ void dlci_ioctl_set(int (*hook) (unsigned int, void __user *))
    dlci_ioctl_hook = hook;
    mutex_unlock(&dlci_ioctl_mutex);
    }
    -
    EXPORT_SYMBOL(dlci_ioctl_set);

    static long sock_do_ioctl(struct net *net, struct socket *sock,
    @@ -1047,6 +1050,7 @@ out_release:
    sock = NULL;
    goto out;
    }
    +EXPORT_SYMBOL(sock_create_lite);

    /* No kernel lock held - perfect */
    static unsigned int sock_poll(struct file *file, poll_table *wait)
    @@ -1147,6 +1151,7 @@ call_kill:
    rcu_read_unlock();
    return 0;
    }
    +EXPORT_SYMBOL(sock_wake_async);

    static int __sock_create(struct net *net, int family, int type, int protocol,
    struct socket **res, int kern)
    @@ -1265,11 +1270,13 @@ int sock_create(int family, int type, int protocol, struct socket **res)
    {
    return __sock_create(current->nsproxy->net_ns, family, type, protocol, res, 0);
    }
    +EXPORT_SYMBOL(sock_create);

    int sock_create_kern(int family, int type, int protocol, struct socket **res)
    {
    return __sock_create(&init_net, family, type, protocol, res, 1);
    }
    +EXPORT_SYMBOL(sock_create_kern);

    SYSCALL_DEFINE3(socket, int, family, int, type, int, protocol)
    {
    @@ -1474,7 +1481,8 @@ SYSCALL_DEFINE4(accept4, int, fd, struct sockaddr __user *, upeer_sockaddr,
    goto out;

    err = -ENFILE;
    - if (!(newsock = sock_alloc()))
    + newsock = sock_alloc();
    + if (!newsock)
    goto out_put;

    newsock->type = sock->type;
    @@ -1861,8 +1869,7 @@ SYSCALL_DEFINE3(sendmsg, int, fd, struct msghdr __user *, msg, unsigned, flags)
    if (MSG_CMSG_COMPAT & flags) {
    if (get_compat_msghdr(&msg_sys, msg_compat))
    return -EFAULT;
    - }
    - else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr)))
    + } else if (copy_from_user(&msg_sys, msg, sizeof(struct msghdr)))
    return -EFAULT;

    sock = sockfd_lookup_light(fd, &err, &fput_needed);
    @@ -1964,8 +1971,7 @@ static int __sys_recvmsg(struct socket *sock, struct msghdr __user *msg,
    if (MSG_CMSG_COMPAT & flags) {
    if (get_compat_msghdr(msg_sys, msg_compat))
    return -EFAULT;
    - }
    - else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
    + } else if (copy_from_user(msg_sys, msg, sizeof(struct msghdr)))
    return -EFAULT;

    err = -EMSGSIZE;
    @@ -2191,10 +2197,10 @@ SYSCALL_DEFINE5(recvmmsg, int, fd, struct mmsghdr __user *, mmsg,
    /* Argument list sizes for sys_socketcall */
    #define AL(x) ((x) * sizeof(unsigned long))
    static const unsigned char nargs[20] = {
    - AL(0),AL(3),AL(3),AL(3),AL(2),AL(3),
    - AL(3),AL(3),AL(4),AL(4),AL(4),AL(6),
    - AL(6),AL(2),AL(5),AL(5),AL(3),AL(3),
    - AL(4),AL(5)
    + AL(0), AL(3), AL(3), AL(3), AL(2), AL(3),
    + AL(3), AL(3), AL(4), AL(4), AL(4), AL(6),
    + AL(6), AL(2), AL(5), AL(5), AL(3), AL(3),
    + AL(4), AL(5)
    };

    #undef AL
    @@ -2340,6 +2346,7 @@ int sock_register(const struct net_proto_family *ops)
    printk(KERN_INFO "NET: Registered protocol family %d\n", ops->family);
    return err;
    }
    +EXPORT_SYMBOL(sock_register);

    /**
    * sock_unregister - remove a protocol handler
    @@ -2366,6 +2373,7 @@ void sock_unregister(int family)

    printk(KERN_INFO "NET: Unregistered protocol family %d\n", family);
    }
    +EXPORT_SYMBOL(sock_unregister);

    static int __init sock_init(void)
    {
    @@ -2490,13 +2498,13 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32)
    ifc.ifc_req = NULL;
    uifc = compat_alloc_user_space(sizeof(struct ifconf));
    } else {
    - size_t len =((ifc32.ifc_len / sizeof (struct compat_ifreq)) + 1) *
    - sizeof (struct ifreq);
    + size_t len = ((ifc32.ifc_len / sizeof(struct compat_ifreq)) + 1) *
    + sizeof(struct ifreq);
    uifc = compat_alloc_user_space(sizeof(struct ifconf) + len);
    ifc.ifc_len = len;
    ifr = ifc.ifc_req = (void __user *)(uifc + 1);
    ifr32 = compat_ptr(ifc32.ifcbuf);
    - for (i = 0; i < ifc32.ifc_len; i += sizeof (struct compat_ifreq)) {
    + for (i = 0; i < ifc32.ifc_len; i += sizeof(struct compat_ifreq)) {
    if (copy_in_user(ifr, ifr32, sizeof(struct compat_ifreq)))
    return -EFAULT;
    ifr++;
    @@ -2516,9 +2524,9 @@ static int dev_ifconf(struct net *net, struct compat_ifconf __user *uifc32)
    ifr = ifc.ifc_req;
    ifr32 = compat_ptr(ifc32.ifcbuf);
    for (i = 0, j = 0;
    - i + sizeof (struct compat_ifreq) < ifc.ifc_len;
    - i += sizeof (struct compat_ifreq), j += sizeof (struct ifreq)) {
    - if (copy_in_user(ifr32, ifr, sizeof (struct compat_ifreq)))
    + i + sizeof(struct compat_ifreq) < ifc.ifc_len;
    + i += sizeof(struct compat_ifreq), j += sizeof(struct ifreq)) {
    + if (copy_in_user(ifr32, ifr, sizeof(struct compat_ifreq)))
    return -EFAULT;
    ifr32++;
    ifr++;
    @@ -2567,7 +2575,7 @@ static int compat_siocwandev(struct net *net, struct compat_ifreq __user *uifr32
    compat_uptr_t uptr32;
    struct ifreq __user *uifr;

    - uifr = compat_alloc_user_space(sizeof (*uifr));
    + uifr = compat_alloc_user_space(sizeof(*uifr));
    if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq)))
    return -EFAULT;

    @@ -2601,9 +2609,9 @@ static int bond_ioctl(struct net *net, unsigned int cmd,
    return -EFAULT;

    old_fs = get_fs();
    - set_fs (KERNEL_DS);
    + set_fs(KERNEL_DS);
    err = dev_ioctl(net, cmd, &kifr);
    - set_fs (old_fs);
    + set_fs(old_fs);

    return err;
    case SIOCBONDSLAVEINFOQUERY:
    @@ -2710,9 +2718,9 @@ static int compat_sioc_ifmap(struct net *net, unsigned int cmd,
    return -EFAULT;

    old_fs = get_fs();
    - set_fs (KERNEL_DS);
    + set_fs(KERNEL_DS);
    err = dev_ioctl(net, cmd, (void __user *)&ifr);
    - set_fs (old_fs);
    + set_fs(old_fs);

    if (cmd == SIOCGIFMAP && !err) {
    err = copy_to_user(uifr32, &ifr, sizeof(ifr.ifr_name));
    @@ -2734,7 +2742,7 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif
    compat_uptr_t uptr32;
    struct ifreq __user *uifr;

    - uifr = compat_alloc_user_space(sizeof (*uifr));
    + uifr = compat_alloc_user_space(sizeof(*uifr));
    if (copy_in_user(uifr, uifr32, sizeof(struct compat_ifreq)))
    return -EFAULT;

    @@ -2750,20 +2758,20 @@ static int compat_siocshwtstamp(struct net *net, struct compat_ifreq __user *uif
    }

    struct rtentry32 {
    - u32 rt_pad1;
    + u32 rt_pad1;
    struct sockaddr rt_dst; /* target address */
    struct sockaddr rt_gateway; /* gateway addr (RTF_GATEWAY) */
    struct sockaddr rt_genmask; /* target network mask (IP) */
    - unsigned short rt_flags;
    - short rt_pad2;
    - u32 rt_pad3;
    - unsigned char rt_tos;
    - unsigned char rt_class;
    - short rt_pad4;
    - short rt_metric; /* +1 for binary compatibility! */
    + unsigned short rt_flags;
    + short rt_pad2;
    + u32 rt_pad3;
    + unsigned char rt_tos;
    + unsigned char rt_class;
    + short rt_pad4;
    + short rt_metric; /* +1 for binary compatibility! */
    /* char * */ u32 rt_dev; /* forcing the device at add */
    - u32 rt_mtu; /* per route MTU/Window */
    - u32 rt_window; /* Window clamping */
    + u32 rt_mtu; /* per route MTU/Window */
    + u32 rt_window; /* Window clamping */
    unsigned short rt_irtt; /* Initial RTT */
    };

    @@ -2793,29 +2801,29 @@ static int routing_ioctl(struct net *net, struct socket *sock,

    if (sock && sock->sk && sock->sk->sk_family == AF_INET6) { /* ipv6 */
    struct in6_rtmsg32 __user *ur6 = argp;
    - ret = copy_from_user (&r6.rtmsg_dst, &(ur6->rtmsg_dst),
    + ret = copy_from_user(&r6.rtmsg_dst, &(ur6->rtmsg_dst),
    3 * sizeof(struct in6_addr));
    - ret |= __get_user (r6.rtmsg_type, &(ur6->rtmsg_type));
    - ret |= __get_user (r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
    - ret |= __get_user (r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
    - ret |= __get_user (r6.rtmsg_metric, &(ur6->rtmsg_metric));
    - ret |= __get_user (r6.rtmsg_info, &(ur6->rtmsg_info));
    - ret |= __get_user (r6.rtmsg_flags, &(ur6->rtmsg_flags));
    - ret |= __get_user (r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));
    + ret |= __get_user(r6.rtmsg_type, &(ur6->rtmsg_type));
    + ret |= __get_user(r6.rtmsg_dst_len, &(ur6->rtmsg_dst_len));
    + ret |= __get_user(r6.rtmsg_src_len, &(ur6->rtmsg_src_len));
    + ret |= __get_user(r6.rtmsg_metric, &(ur6->rtmsg_metric));
    + ret |= __get_user(r6.rtmsg_info, &(ur6->rtmsg_info));
    + ret |= __get_user(r6.rtmsg_flags, &(ur6->rtmsg_flags));
    + ret |= __get_user(r6.rtmsg_ifindex, &(ur6->rtmsg_ifindex));

    r = (void *) &r6;
    } else { /* ipv4 */
    struct rtentry32 __user *ur4 = argp;
    - ret = copy_from_user (&r4.rt_dst, &(ur4->rt_dst),
    + ret = copy_from_user(&r4.rt_dst, &(ur4->rt_dst),
    3 * sizeof(struct sockaddr));
    - ret |= __get_user (r4.rt_flags, &(ur4->rt_flags));
    - ret |= __get_user (r4.rt_metric, &(ur4->rt_metric));
    - ret |= __get_user (r4.rt_mtu, &(ur4->rt_mtu));
    - ret |= __get_user (r4.rt_window, &(ur4->rt_window));
    - ret |= __get_user (r4.rt_irtt, &(ur4->rt_irtt));
    - ret |= __get_user (rtdev, &(ur4->rt_dev));
    + ret |= __get_user(r4.rt_flags, &(ur4->rt_flags));
    + ret |= __get_user(r4.rt_metric, &(ur4->rt_metric));
    + ret |= __get_user(r4.rt_mtu, &(ur4->rt_mtu));
    + ret |= __get_user(r4.rt_window, &(ur4->rt_window));
    + ret |= __get_user(r4.rt_irtt, &(ur4->rt_irtt));
    + ret |= __get_user(rtdev, &(ur4->rt_dev));
    if (rtdev) {
    - ret |= copy_from_user (devname, compat_ptr(rtdev), 15);
    + ret |= copy_from_user(devname, compat_ptr(rtdev), 15);
    r4.rt_dev = devname; devname[15] = 0;
    } else
    r4.rt_dev = NULL;
    @@ -2828,9 +2836,9 @@ static int routing_ioctl(struct net *net, struct socket *sock,
    goto out;
    }

    - set_fs (KERNEL_DS);
    + set_fs(KERNEL_DS);
    ret = sock_do_ioctl(net, sock, cmd, (unsigned long) r);
    - set_fs (old_fs);
    + set_fs(old_fs);

    out:
    return ret;
    @@ -2993,11 +3001,13 @@ int kernel_bind(struct socket *sock, struct sockaddr *addr, int addrlen)
    {
    return sock->ops->bind(sock, addr, addrlen);
    }
    +EXPORT_SYMBOL(kernel_bind);

    int kernel_listen(struct socket *sock, int backlog)
    {
    return sock->ops->listen(sock, backlog);
    }
    +EXPORT_SYMBOL(kernel_listen);

    int kernel_accept(struct socket *sock, struct socket **newsock, int flags)
    {
    @@ -3022,24 +3032,28 @@ int kernel_accept(struct socket *sock, struct socket **newsock, int flags)
    done:
    return err;
    }
    +EXPORT_SYMBOL(kernel_accept);

    int kernel_connect(struct socket *sock, struct sockaddr *addr, int addrlen,
    int flags)
    {
    return sock->ops->connect(sock, addr, addrlen, flags);
    }
    +EXPORT_SYMBOL(kernel_connect);

    int kernel_getsockname(struct socket *sock, struct sockaddr *addr,
    int *addrlen)
    {
    return sock->ops->getname(sock, addr, addrlen, 0);
    }
    +EXPORT_SYMBOL(kernel_getsockname);

    int kernel_getpeername(struct socket *sock, struct sockaddr *addr,
    int *addrlen)
    {
    return sock->ops->getname(sock, addr, addrlen, 1);
    }
    +EXPORT_SYMBOL(kernel_getpeername);

    int kernel_getsockopt(struct socket *sock, int level, int optname,
    char *optval, int *optlen)
    @@ -3056,6 +3070,7 @@ int kernel_getsockopt(struct socket *sock, int level, int optname,
    set_fs(oldfs);
    return err;
    }
    +EXPORT_SYMBOL(kernel_getsockopt);

    int kernel_setsockopt(struct socket *sock, int level, int optname,
    char *optval, unsigned int optlen)
    @@ -3072,6 +3087,7 @@ int kernel_setsockopt(struct socket *sock, int level, int optname,
    set_fs(oldfs);
    return err;
    }
    +EXPORT_SYMBOL(kernel_setsockopt);

    int kernel_sendpage(struct socket *sock, struct page *page, int offset,
    size_t size, int flags)
    @@ -3083,6 +3099,7 @@ int kernel_sendpage(struct socket *sock, struct page *page, int offset,

    return sock_no_sendpage(sock, page, offset, size, flags);
    }
    +EXPORT_SYMBOL(kernel_sendpage);

    int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg)
    {
    @@ -3095,33 +3112,11 @@ int kernel_sock_ioctl(struct socket *sock, int cmd, unsigned long arg)

    return err;
    }
    +EXPORT_SYMBOL(kernel_sock_ioctl);

    int kernel_sock_shutdown(struct socket *sock, enum sock_shutdown_cmd how)
    {
    return sock->ops->shutdown(sock, how);
    }
    -
    -EXPORT_SYMBOL(sock_create);
    -EXPORT_SYMBOL(sock_create_kern);
    -EXPORT_SYMBOL(sock_create_lite);
    -EXPORT_SYMBOL(sock_map_fd);
    -EXPORT_SYMBOL(sock_recvmsg);
    -EXPORT_SYMBOL(sock_register);
    -EXPORT_SYMBOL(sock_release);
    -EXPORT_SYMBOL(sock_sendmsg);
    -EXPORT_SYMBOL(sock_unregister);
    -EXPORT_SYMBOL(sock_wake_async);
    -EXPORT_SYMBOL(sockfd_lookup);
    -EXPORT_SYMBOL(kernel_sendmsg);
    -EXPORT_SYMBOL(kernel_recvmsg);
    -EXPORT_SYMBOL(kernel_bind);
    -EXPORT_SYMBOL(kernel_listen);
    -EXPORT_SYMBOL(kernel_accept);
    -EXPORT_SYMBOL(kernel_connect);
    -EXPORT_SYMBOL(kernel_getsockname);
    -EXPORT_SYMBOL(kernel_getpeername);
    -EXPORT_SYMBOL(kernel_getsockopt);
    -EXPORT_SYMBOL(kernel_setsockopt);
    -EXPORT_SYMBOL(kernel_sendpage);
    -EXPORT_SYMBOL(kernel_sock_ioctl);
    EXPORT_SYMBOL(kernel_sock_shutdown);
    +
    --
    1.7.0.4

    Eric Dumazet
     

03 Jun, 2010

1 commit


30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

12 Dec, 2009

2 commits


02 Dec, 2009

1 commit


29 Oct, 2009

1 commit


13 Oct, 2009

1 commit

  • Meaning receive multiple messages, reducing the number of syscalls and
    net stack entry/exit operations.

    Next patches will introduce mechanisms where protocols that want to
    optimize this operation will provide an unlocked_recvmsg operation.

    This takes into account comments made by:

    . Paul Moore: sock_recvmsg is called only for the first datagram,
    sock_recvmsg_nosec is used for the rest.

    . Caitlin Bestler: recvmmsg now has a struct timespec timeout, that
    works in the same fashion as the ppoll one.

    If the underlying protocol returns a datagram with MSG_OOB set, this
    will make recvmmsg return right away with as many datagrams (+ the OOB
    one) it has received so far.

    . Rémi Denis-Courmont & Steven Whitehouse: If we receive N < vlen
    datagrams and then recvmsg returns an error, recvmmsg will return
    the successfully received datagrams, store the error and return it
    in the next call.

    This paves the way for a subsequent optimization, sk_prot->unlocked_recvmsg,
    where we will be able to acquire the lock only at batch start and end, not at
    every underlying recvmsg call.

    Signed-off-by: Arnaldo Carvalho de Melo
    Signed-off-by: David S. Miller

    Arnaldo Carvalho de Melo