Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Jan 2011 18:25:58 +0000 (10:25 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 13 Jan 2011 18:25:58 +0000 (10:25 -0800)
* git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6: (46 commits)
  hwrng: via_rng - Fix memory scribbling on some CPUs
  crypto: padlock - Move padlock.h into include/crypto
  hwrng: via_rng - Fix asm constraints
  crypto: n2 - use __devexit not __exit in n2_unregister_algs
  crypto: mark crypto workqueues CPU_INTENSIVE
  crypto: mv_cesa - dont return PTR_ERR() of wrong pointer
  crypto: ripemd - Set module author and update email address
  crypto: omap-sham - backlog handling fix
  crypto: gf128mul - Remove experimental tag
  crypto: af_alg - fix af_alg memory_allocated data type
  crypto: aesni-intel - Fixed build with binutils 2.16
  crypto: af_alg - Make sure sk_security is initialized on accept()ed sockets
  net: Add missing lockdep class names for af_alg
  include: Install linux/if_alg.h for user-space crypto API
  crypto: omap-aes - checkpatch --file warning fixes
  crypto: omap-aes - initialize aes module once per request
  crypto: omap-aes - unnecessary code removed
  crypto: omap-aes - error handling implementation improved
  crypto: omap-aes - redundant locking is removed
  crypto: omap-aes - DMA initialization fixes for OMAP off mode
  ...

1  2 
crypto/pcrypt.c
drivers/crypto/n2_core.c
drivers/crypto/padlock-aes.c
include/linux/Kbuild
include/linux/socket.h
net/core/sock.c

diff --combined crypto/pcrypt.c
@@@ -455,7 -455,8 +455,8 @@@ static int pcrypt_init_padata(struct pa
  
        get_online_cpus();
  
-       pcrypt->wq = create_workqueue(name);
+       pcrypt->wq = alloc_workqueue(name,
+                                    WQ_MEM_RECLAIM | WQ_CPU_INTENSIVE, 1);
        if (!pcrypt->wq)
                goto err;
  
@@@ -504,6 -505,7 +505,6 @@@ err
  
  static void pcrypt_fini_padata(struct padata_pcrypt *pcrypt)
  {
 -      kobject_put(&pcrypt->pinst->kobj);
        free_cpumask_var(pcrypt->cb_cpumask->mask);
        kfree(pcrypt->cb_cpumask);
  
diff --combined drivers/crypto/n2_core.c
@@@ -1542,7 -1542,7 +1542,7 @@@ out
        return err;
  }
  
- static void __exit n2_unregister_algs(void)
+ static void __devexit n2_unregister_algs(void)
  {
        mutex_lock(&spu_lock);
        if (!--algs_registered)
@@@ -1832,7 -1832,7 +1832,7 @@@ static int __devinit get_irq_props(stru
                return -ENODEV;
  
        ino = mdesc_get_property(mdesc, node, "ino", &ino_len);
 -      if (!intr)
 +      if (!ino)
                return -ENODEV;
  
        if (intr_len != ino_len)
@@@ -9,6 -9,7 +9,7 @@@
  
  #include <crypto/algapi.h>
  #include <crypto/aes.h>
+ #include <crypto/padlock.h>
  #include <linux/module.h>
  #include <linux/init.h>
  #include <linux/types.h>
@@@ -21,7 -22,6 +22,6 @@@
  #include <asm/byteorder.h>
  #include <asm/processor.h>
  #include <asm/i387.h>
- #include "padlock.h"
  
  /*
   * Number of data blocks actually fetched for each xcrypt insn.
@@@ -286,7 -286,7 +286,7 @@@ static inline u8 *padlock_xcrypt_cbc(co
        if (initial)
                asm volatile (".byte 0xf3,0x0f,0xa7,0xd0"       /* rep xcryptcbc */
                              : "+S" (input), "+D" (output), "+a" (iv)
 -                            : "d" (control_word), "b" (key), "c" (count));
 +                            : "d" (control_word), "b" (key), "c" (initial));
  
        asm volatile (".byte 0xf3,0x0f,0xa7,0xd0"       /* rep xcryptcbc */
                      : "+S" (input), "+D" (output), "+a" (iv)
diff --combined include/linux/Kbuild
@@@ -20,18 -20,15 +20,18 @@@ header-y += wimax
  objhdr-y += version.h
  
  ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/a.out.h \
 -                $(srctree)/include/asm-$(SRCARCH)/a.out.h),)
 +                $(srctree)/include/asm-$(SRCARCH)/a.out.h \
 +                $(INSTALL_HDR_PATH)/include/asm-*/a.out.h),)
  header-y += a.out.h
  endif
  ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm.h \
 -                $(srctree)/include/asm-$(SRCARCH)/kvm.h),)
 +                $(srctree)/include/asm-$(SRCARCH)/kvm.h \
 +                $(INSTALL_HDR_PATH)/include/asm-*/kvm.h),)
  header-y += kvm.h
  endif
  ifneq ($(wildcard $(srctree)/arch/$(SRCARCH)/include/asm/kvm_para.h \
 -                $(srctree)/include/asm-$(SRCARCH)/kvm_para.h),)
 +                $(srctree)/include/asm-$(SRCARCH)/kvm_para.h \
 +                $(INSTALL_HDR_PATH)/include/asm-*/kvm_para.h),)
  header-y += kvm_para.h
  endif
  
@@@ -121,7 -118,6 +121,7 @@@ header-y += eventpoll.
  header-y += ext2_fs.h
  header-y += fadvise.h
  header-y += falloc.h
 +header-y += fanotify.h
  header-y += fb.h
  header-y += fcntl.h
  header-y += fd.h
@@@ -158,6 -154,7 +158,7 @@@ header-y += icmpv6.
  header-y += if.h
  header-y += if_addr.h
  header-y += if_addrlabel.h
+ header-y += if_alg.h
  header-y += if_arcnet.h
  header-y += if_arp.h
  header-y += if_bonding.h
@@@ -330,6 -327,10 +331,6 @@@ header-y += serio.
  header-y += shm.h
  header-y += signal.h
  header-y += signalfd.h
 -header-y += smb.h
 -header-y += smb_fs.h
 -header-y += smb_mount.h
 -header-y += smbno.h
  header-y += snmp.h
  header-y += socket.h
  header-y += sockios.h
@@@ -370,7 -371,9 +371,7 @@@ header-y += utime.
  header-y += utsname.h
  header-y += veth.h
  header-y += vhost.h
 -header-y += videodev.h
  header-y += videodev2.h
 -header-y += videotext.h
  header-y += virtio_9p.h
  header-y += virtio_balloon.h
  header-y += virtio_blk.h
diff --combined include/linux/socket.h
@@@ -30,10 -30,12 +30,10 @@@ struct cred
  #define __sockaddr_check_size(size)   \
        BUILD_BUG_ON(((size) > sizeof(struct __kernel_sockaddr_storage)))
  
 -#ifdef __KERNEL__
 -# ifdef CONFIG_PROC_FS
 +#ifdef CONFIG_PROC_FS
  struct seq_file;
  extern void socket_seq_show(struct seq_file *seq);
 -# endif
 -#endif /* __KERNEL__ */
 +#endif
  
  typedef unsigned short        sa_family_t;
  
@@@ -191,7 -193,8 +191,8 @@@ struct ucred 
  #define AF_PHONET     35      /* Phonet sockets               */
  #define AF_IEEE802154 36      /* IEEE802154 sockets           */
  #define AF_CAIF               37      /* CAIF sockets                 */
- #define AF_MAX                38      /* For now.. */
+ #define AF_ALG                38      /* Algorithm sockets            */
+ #define AF_MAX                39      /* For now.. */
  
  /* Protocol families, same as address families. */
  #define PF_UNSPEC     AF_UNSPEC
  #define PF_PHONET     AF_PHONET
  #define PF_IEEE802154 AF_IEEE802154
  #define PF_CAIF               AF_CAIF
+ #define PF_ALG                AF_ALG
  #define PF_MAX                AF_MAX
  
  /* Maximum queue length specifiable by listen.  */
  #define SOL_RDS               276
  #define SOL_IUCV      277
  #define SOL_CAIF      278
+ #define SOL_ALG               279
  
  /* IPX options */
  #define IPX_TYPE      1
  
 -#ifdef __KERNEL__
  extern void cred_to_ucred(struct pid *pid, const struct cred *cred, struct ucred *ucred);
  
  extern int memcpy_fromiovec(unsigned char *kdata, struct iovec *iov, int len);
@@@ -319,7 -325,7 +322,7 @@@ extern int csum_partial_copy_fromiovece
                                          int offset, 
                                          unsigned int len, __wsum *csump);
  
 -extern long verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
 +extern int verify_iovec(struct msghdr *m, struct iovec *iov, struct sockaddr *address, int mode);
  extern int memcpy_toiovec(struct iovec *v, unsigned char *kdata, int len);
  extern int memcpy_toiovecend(const struct iovec *v, unsigned char *kdata,
                             int offset, int len);
@@@ -330,5 -336,6 +333,5 @@@ struct timespec
  
  extern int __sys_recvmmsg(int fd, struct mmsghdr __user *mmsg, unsigned int vlen,
                          unsigned int flags, struct timespec *timeout);
 -#endif
  #endif /* not kernel and not glibc */
  #endif /* _LINUX_SOCKET_H */
diff --combined net/core/sock.c
@@@ -157,7 -157,7 +157,7 @@@ static const char *const af_family_key_
    "sk_lock-27"       , "sk_lock-28"          , "sk_lock-AF_CAN"      ,
    "sk_lock-AF_TIPC"  , "sk_lock-AF_BLUETOOTH", "sk_lock-IUCV"        ,
    "sk_lock-AF_RXRPC" , "sk_lock-AF_ISDN"     , "sk_lock-AF_PHONET"   ,
-   "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" ,
+   "sk_lock-AF_IEEE802154", "sk_lock-AF_CAIF" , "sk_lock-AF_ALG"      ,
    "sk_lock-AF_MAX"
  };
  static const char *const af_family_slock_key_strings[AF_MAX+1] = {
    "slock-27"       , "slock-28"          , "slock-AF_CAN"      ,
    "slock-AF_TIPC"  , "slock-AF_BLUETOOTH", "slock-AF_IUCV"     ,
    "slock-AF_RXRPC" , "slock-AF_ISDN"     , "slock-AF_PHONET"   ,
-   "slock-AF_IEEE802154", "slock-AF_CAIF" ,
+   "slock-AF_IEEE802154", "slock-AF_CAIF" , "slock-AF_ALG"      ,
    "slock-AF_MAX"
  };
  static const char *const af_family_clock_key_strings[AF_MAX+1] = {
    "clock-27"       , "clock-28"          , "clock-AF_CAN"      ,
    "clock-AF_TIPC"  , "clock-AF_BLUETOOTH", "clock-AF_IUCV"     ,
    "clock-AF_RXRPC" , "clock-AF_ISDN"     , "clock-AF_PHONET"   ,
-   "clock-AF_IEEE802154", "clock-AF_CAIF" ,
+   "clock-AF_IEEE802154", "clock-AF_CAIF" , "clock-AF_ALG"      ,
    "clock-AF_MAX"
  };
  
@@@ -992,54 -992,23 +992,54 @@@ static inline void sock_lock_init(struc
  /*
   * Copy all fields from osk to nsk but nsk->sk_refcnt must not change yet,
   * even temporarly, because of RCU lookups. sk_node should also be left as is.
 + * We must not copy fields between sk_dontcopy_begin and sk_dontcopy_end
   */
  static void sock_copy(struct sock *nsk, const struct sock *osk)
  {
  #ifdef CONFIG_SECURITY_NETWORK
        void *sptr = nsk->sk_security;
  #endif
 -      BUILD_BUG_ON(offsetof(struct sock, sk_copy_start) !=
 -                   sizeof(osk->sk_node) + sizeof(osk->sk_refcnt) +
 -                   sizeof(osk->sk_tx_queue_mapping));
 -      memcpy(&nsk->sk_copy_start, &osk->sk_copy_start,
 -             osk->sk_prot->obj_size - offsetof(struct sock, sk_copy_start));
 +      memcpy(nsk, osk, offsetof(struct sock, sk_dontcopy_begin));
 +
 +      memcpy(&nsk->sk_dontcopy_end, &osk->sk_dontcopy_end,
 +             osk->sk_prot->obj_size - offsetof(struct sock, sk_dontcopy_end));
 +
  #ifdef CONFIG_SECURITY_NETWORK
        nsk->sk_security = sptr;
        security_sk_clone(osk, nsk);
  #endif
  }
  
 +/*
 + * caches using SLAB_DESTROY_BY_RCU should let .next pointer from nulls nodes
 + * un-modified. Special care is taken when initializing object to zero.
 + */
 +static inline void sk_prot_clear_nulls(struct sock *sk, int size)
 +{
 +      if (offsetof(struct sock, sk_node.next) != 0)
 +              memset(sk, 0, offsetof(struct sock, sk_node.next));
 +      memset(&sk->sk_node.pprev, 0,
 +             size - offsetof(struct sock, sk_node.pprev));
 +}
 +
 +void sk_prot_clear_portaddr_nulls(struct sock *sk, int size)
 +{
 +      unsigned long nulls1, nulls2;
 +
 +      nulls1 = offsetof(struct sock, __sk_common.skc_node.next);
 +      nulls2 = offsetof(struct sock, __sk_common.skc_portaddr_node.next);
 +      if (nulls1 > nulls2)
 +              swap(nulls1, nulls2);
 +
 +      if (nulls1 != 0)
 +              memset((char *)sk, 0, nulls1);
 +      memset((char *)sk + nulls1 + sizeof(void *), 0,
 +             nulls2 - nulls1 - sizeof(void *));
 +      memset((char *)sk + nulls2 + sizeof(void *), 0,
 +             size - nulls2 - sizeof(void *));
 +}
 +EXPORT_SYMBOL(sk_prot_clear_portaddr_nulls);
 +
  static struct sock *sk_prot_alloc(struct proto *prot, gfp_t priority,
                int family)
  {
                if (!sk)
                        return sk;
                if (priority & __GFP_ZERO) {
 -                      /*
 -                       * caches using SLAB_DESTROY_BY_RCU should let
 -                       * sk_node.next un-modified. Special care is taken
 -                       * when initializing object to zero.
 -                       */
 -                      if (offsetof(struct sock, sk_node.next) != 0)
 -                              memset(sk, 0, offsetof(struct sock, sk_node.next));
 -                      memset(&sk->sk_node.pprev, 0,
 -                             prot->obj_size - offsetof(struct sock,
 -                                                       sk_node.pprev));
 +                      if (prot->clear_sk)
 +                              prot->clear_sk(sk, prot->obj_size);
 +                      else
 +                              sk_prot_clear_nulls(sk, prot->obj_size);
                }
 -      }
 -      else
 +      } else
                sk = kmalloc(prot->obj_size, priority);
  
        if (sk != NULL) {
@@@ -1677,10 -1653,10 +1677,10 @@@ int __sk_mem_schedule(struct sock *sk, 
  {
        struct proto *prot = sk->sk_prot;
        int amt = sk_mem_pages(size);
 -      int allocated;
 +      long allocated;
  
        sk->sk_forward_alloc += amt * SK_MEM_QUANTUM;
 -      allocated = atomic_add_return(amt, prot->memory_allocated);
 +      allocated = atomic_long_add_return(amt, prot->memory_allocated);
  
        /* Under limit. */
        if (allocated <= prot->sysctl_mem[0]) {
@@@ -1738,7 -1714,7 +1738,7 @@@ suppress_allocation
  
        /* Alas. Undo changes. */
        sk->sk_forward_alloc -= amt * SK_MEM_QUANTUM;
 -      atomic_sub(amt, prot->memory_allocated);
 +      atomic_long_sub(amt, prot->memory_allocated);
        return 0;
  }
  EXPORT_SYMBOL(__sk_mem_schedule);
@@@ -1751,12 -1727,12 +1751,12 @@@ void __sk_mem_reclaim(struct sock *sk
  {
        struct proto *prot = sk->sk_prot;
  
 -      atomic_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT,
 +      atomic_long_sub(sk->sk_forward_alloc >> SK_MEM_QUANTUM_SHIFT,
                   prot->memory_allocated);
        sk->sk_forward_alloc &= SK_MEM_QUANTUM - 1;
  
        if (prot->memory_pressure && *prot->memory_pressure &&
 -          (atomic_read(prot->memory_allocated) < prot->sysctl_mem[0]))
 +          (atomic_long_read(prot->memory_allocated) < prot->sysctl_mem[0]))
                *prot->memory_pressure = 0;
  }
  EXPORT_SYMBOL(__sk_mem_reclaim);
@@@ -1908,7 -1884,7 +1908,7 @@@ static void sock_def_readable(struct so
        rcu_read_lock();
        wq = rcu_dereference(sk->sk_wq);
        if (wq_has_sleeper(wq))
 -              wake_up_interruptible_sync_poll(&wq->wait, POLLIN |
 +              wake_up_interruptible_sync_poll(&wq->wait, POLLIN | POLLPRI |
                                                POLLRDNORM | POLLRDBAND);
        sk_wake_async(sk, SOCK_WAKE_WAITD, POLL_IN);
        rcu_read_unlock();
@@@ -2476,12 -2452,12 +2476,12 @@@ static char proto_method_implemented(co
  
  static void proto_seq_printf(struct seq_file *seq, struct proto *proto)
  {
 -      seq_printf(seq, "%-9s %4u %6d  %6d   %-3s %6u   %-3s  %-10s "
 +      seq_printf(seq, "%-9s %4u %6d  %6ld   %-3s %6u   %-3s  %-10s "
                        "%2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c %2c\n",
                   proto->name,
                   proto->obj_size,
                   sock_prot_inuse_get(seq_file_net(seq), proto),
 -                 proto->memory_allocated != NULL ? atomic_read(proto->memory_allocated) : -1,
 +                 proto->memory_allocated != NULL ? atomic_long_read(proto->memory_allocated) : -1L,
                   proto->memory_pressure != NULL ? *proto->memory_pressure ? "yes" : "no" : "NI",
                   proto->max_header,
                   proto->slab == NULL ? "no" : "yes",