Skip to content
Snippets Groups Projects
  1. Nov 01, 2012
  2. Oct 25, 2012
    • H. Peter Anvin's avatar
      Makefile: Documentation for external tool should be correct · 2008713c
      H. Peter Anvin authored
      
      If one includes documentation for an external tool, it should be
      correct.  This is not:
      
      1. Overriding the input to rngd should typically be neither
         necessary nor desired.  This is especially so since newer
         versions of rngd support a number of different *types* of sources.
      2. The default kernel-exported device is called /dev/hwrng not
         /dev/hwrandom nor /dev/hw_random (both of which were used in the
         past; however, kernel and udev seem to have converged on
         /dev/hwrng.)
      
      Overall it is better if the documentation for rngd is kept with rngd
      rather than in a kernel Makefile.
      
      Signed-off-by: default avatarH. Peter Anvin <hpa@linux.intel.com>
      Cc: David Howells <dhowells@redhat.com>
      Cc: Jeff Garzik <jgarzik@redhat.com>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2008713c
    • Andrew Vagin's avatar
      pidns: limit the nesting depth of pid namespaces · f2302505
      Andrew Vagin authored
      
      'struct pid' is a "variable sized struct" - a header with an array of
      upids at the end.
      
      The size of the array depends on a level (depth) of pid namespaces.  Now a
      level of pidns is not limited, so 'struct pid' can be more than one page.
      
      Looks reasonable, that it should be less than a page.  MAX_PIS_NS_LEVEL is
      not calculated from PAGE_SIZE, because in this case it depends on
      architectures, config options and it will be reduced, if someone adds a
      new fields in struct pid or struct upid.
      
      I suggest to set MAX_PIS_NS_LEVEL = 32, because it saves ability to expand
      "struct pid" and it's more than enough for all known for me use-cases.
      When someone finds a reasonable use case, we can add a config option or a
      sysctl parameter.
      
      In addition it will reduce the effect of another problem, when we have
      many nested namespaces and the oldest one starts dying.
      zap_pid_ns_processe will be called for each namespace and find_vpid will
      be called for each process in a namespace.  find_vpid will be called
      minimum max_level^2 / 2 times.  The reason of that is that when we found a
      bit in pidmap, we can't determine this pidns is top for this process or it
      isn't.
      
      vpid is a heavy operation, so a fork bomb, which create many nested
      namespace, can make a system inaccessible for a long time.  For example my
      system becomes inaccessible for a few minutes with 4000 processes.
      
      [akpm@linux-foundation.org: return -EINVAL in response to excessive nesting, not -ENOMEM]
      Signed-off-by: default avatarAndrew Vagin <avagin@openvz.org>
      Acked-by: default avatarOleg Nesterov <oleg@redhat.com>
      Cc: Cyrill Gorcunov <gorcunov@openvz.org>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Pavel Emelyanov <xemul@parallels.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      f2302505
  3. Oct 24, 2012
  4. Oct 22, 2012
  5. Oct 20, 2012
  6. Oct 19, 2012
    • Tejun Heo's avatar
      Revert "cgroup: Remove task_lock() from cgroup_post_fork()" · d8783832
      Tejun Heo authored
      
      This reverts commit 7e3aa30a.
      
      The commit incorrectly assumed that fork path always performed
      threadgroup_change_begin/end() and depended on that for
      synchronization against task exit and cgroup migration paths instead
      of explicitly grabbing task_lock().
      
      threadgroup_change is not locked when forking a new process (as
      opposed to a new thread in the same process) and even if it were it
      wouldn't be effective as different processes use different threadgroup
      locks.
      
      Revert the incorrect optimization.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      LKML-Reference: <20121008020000.GB2575@localhost>
      Acked-by: default avatarLi Zefan <lizefan@huawei.com>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: stable@vger.kernel.org
      d8783832
    • Tejun Heo's avatar
      Revert "cgroup: Drop task_lock(parent) on cgroup_fork()" · 9bb71308
      Tejun Heo authored
      
      This reverts commit 7e381b0e.
      
      The commit incorrectly assumed that fork path always performed
      threadgroup_change_begin/end() and depended on that for
      synchronization against task exit and cgroup migration paths instead
      of explicitly grabbing task_lock().
      
      threadgroup_change is not locked when forking a new process (as
      opposed to a new thread in the same process) and even if it were it
      wouldn't be effective as different processes use different threadgroup
      locks.
      
      Revert the incorrect optimization.
      
      Signed-off-by: default avatarTejun Heo <tj@kernel.org>
      LKML-Reference: <20121008020000.GB2575@localhost>
      Acked-by: default avatarLi Zefan <lizefan@huawei.com>
      Bitterly-Acked-by: default avatarFrederic Weisbecker <fweisbec@gmail.com>
      Cc: stable@vger.kernel.org
      9bb71308
    • Cyrill Gorcunov's avatar
      pidns: remove recursion from free_pid_ns() · bbc2e3ef
      Cyrill Gorcunov authored
      
      free_pid_ns() operates in a recursive fashion:
      
      free_pid_ns(parent)
        put_pid_ns(parent)
          kref_put(&ns->kref, free_pid_ns);
            free_pid_ns
      
      thus if there was a huge nesting of namespaces the userspace may trigger
      avalanche calling of free_pid_ns leading to kernel stack exhausting and a
      panic eventually.
      
      This patch turns the recursion into an iterative loop.
      
      Based on a patch by Andrew Vagin.
      
      [akpm@linux-foundation.org: export put_pid_ns() to modules]
      Signed-off-by: default avatarCyrill Gorcunov <gorcunov@openvz.org>
      Cc: Andrew Vagin <avagin@openvz.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Pavel Emelyanov <xemul@parallels.com>
      Cc: Greg KH <greg@kroah.com>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      bbc2e3ef
    • Kees Cook's avatar
      kernel/sys.c: fix stack memory content leak via UNAME26 · 2702b152
      Kees Cook authored
      
      Calling uname() with the UNAME26 personality set allows a leak of kernel
      stack contents.  This fixes it by defensively calculating the length of
      copy_to_user() call, making the len argument unsigned, and initializing
      the stack buffer to zero (now technically unneeded, but hey, overkill).
      
      CVE-2012-0957
      
      Reported-by: default avatarPaX Team <pageexec@freemail.hu>
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: PaX Team <pageexec@freemail.hu>
      Cc: Brad Spengler <spender@grsecurity.net>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      2702b152
  7. Oct 17, 2012
  8. Oct 13, 2012
  9. Oct 12, 2012
  10. Oct 11, 2012
  11. Oct 10, 2012
    • Rusty Russell's avatar
      MODSIGN: Make mrproper should remove generated files. · d5b71936
      Rusty Russell authored
      
      It doesn't, because the clean targets don't include kernel/Makefile, and
      because two files were missing from the list.
      
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      d5b71936
    • David Howells's avatar
      MODSIGN: Use utf8 strings in signer's name in autogenerated X.509 certs · e7d113bc
      David Howells authored
      
      Place an indication that the certificate should use utf8 strings into the
      x509.genkey template generated by kernel/Makefile.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      e7d113bc
    • David Howells's avatar
      MODSIGN: Use the same digest for the autogen key sig as for the module sig · 5e8cb1e4
      David Howells authored
      
      Use the same digest type for the autogenerated key signature as for the module
      signature so that the hash algorithm is guaranteed to be present in the kernel.
      
      Without this, the X.509 certificate loader may reject the X.509 certificate so
      generated because it was self-signed and the signature will be checked against
      itself - but this won't work if the digest algorithm must be loaded as a
      module.
      
      The symptom is that the key fails to load with the following message emitted
      into the kernel log:
      
      	MODSIGN: Problem loading in-kernel X.509 certificate (-65)
      
      the error in brackets being -ENOPKG.  What you should see is something like:
      
      	MODSIGN: Loaded cert 'Magarathea: Glacier signing key: 9588321144239a119d3406d4c4cf1fbae1836fa0'
      
      Note that this doesn't apply to certificates that are not self-signed as we
      don't check those currently as they require the parent CA certificate to be
      available.
      
      Reported-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      5e8cb1e4
    • David Howells's avatar
      MODSIGN: Implement module signature checking · 48ba2462
      David Howells authored
      
      Check the signature on the module against the keys compiled into the kernel or
      available in a hardware key store.
      
      Currently, only RSA keys are supported - though that's easy enough to change,
      and the signature is expected to contain raw components (so not a PGP or
      PKCS#7 formatted blob).
      
      The signature blob is expected to consist of the following pieces in order:
      
       (1) The binary identifier for the key.  This is expected to match the
           SubjectKeyIdentifier from an X.509 certificate.  Only X.509 type
           identifiers are currently supported.
      
       (2) The signature data, consisting of a series of MPIs in which each is in
           the format of a 2-byte BE word sizes followed by the content data.
      
       (3) A 12 byte information block of the form:
      
      	struct module_signature {
      		enum pkey_algo		algo : 8;
      		enum pkey_hash_algo	hash : 8;
      		enum pkey_id_type	id_type : 8;
      		u8			__pad;
      		__be32			id_length;
      		__be32			sig_length;
      	};
      
           The three enums are defined in crypto/public_key.h.
      
           'algo' contains the public-key algorithm identifier (0->DSA, 1->RSA).
      
           'hash' contains the digest algorithm identifier (0->MD4, 1->MD5, 2->SHA1,
            etc.).
      
           'id_type' contains the public-key identifier type (0->PGP, 1->X.509).
      
           '__pad' should be 0.
      
           'id_length' should contain in the binary identifier length in BE form.
      
           'sig_length' should contain in the signature data length in BE form.
      
           The lengths are in BE order rather than CPU order to make dealing with
           cross-compilation easier.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: Rusty Russell <rusty@rustcorp.com.au> (minor Kconfig fix)
      48ba2462
    • David Howells's avatar
      MODSIGN: Provide module signing public keys to the kernel · 631cc66e
      David Howells authored
      
      Include a PGP keyring containing the public keys required to perform module
      verification in the kernel image during build and create a special keyring
      during boot which is then populated with keys of crypto type holding the public
      keys found in the PGP keyring.
      
      These can be seen by root:
      
      [root@andromeda ~]# cat /proc/keys
      07ad4ee0 I-----     1 perm 3f010000     0     0 crypto    modsign.0: RSA 87b9b3bd []
      15c7f8c3 I-----     1 perm 1f030000     0     0 keyring   .module_sign: 1/4
      ...
      
      It is probably worth permitting root to invalidate these keys, resulting in
      their removal and preventing further modules from being loaded with that key.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      631cc66e
    • David Howells's avatar
      MODSIGN: Automatically generate module signing keys if missing · d441108c
      David Howells authored
      
      Automatically generate keys for module signing if they're absent so that
      allyesconfig doesn't break.  The builder should consider generating their own
      key and certificate, however, so that the keys are appropriately named.
      
      The private key for the module signer should be placed in signing_key.priv
      (unencrypted!) and the public key in an X.509 certificate as signing_key.x509.
      
      If a transient key is desired for signing the modules, a config file for
      'openssl req' can be placed in x509.genkey, looking something like the
      following:
      
      	[ req ]
      	default_bits = 4096
      	distinguished_name = req_distinguished_name
      	prompt = no
      	x509_extensions = myexts
      
      	[ req_distinguished_name ]
      	O = Magarathea
      	CN = Glacier signing key
      	emailAddress = slartibartfast@magrathea.h2g2
      
      	[ myexts ]
      	basicConstraints=critical,CA:FALSE
      	keyUsage=digitalSignature
      	subjectKeyIdentifier=hash
      	authorityKeyIdentifier=hash
      
      The build process will use this to configure:
      
      	openssl req -new -nodes -utf8 -sha1 -days 36500 -batch \
      		-x509 -config x509.genkey \
      		-outform DER -out signing_key.x509 \
      		-keyout signing_key.priv
      
      to generate the key.
      
      Note that it is required that the X.509 certificate have a subjectKeyIdentifier
      and an authorityKeyIdentifier.  Without those, the certificate will be
      rejected.  These can be used to check the validity of a certificate.
      
      Note that 'make distclean' will remove signing_key.{priv,x509} and x509.genkey,
      whether or not they were generated automatically.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      d441108c
    • David Howells's avatar
      MODSIGN: Add FIPS policy · 1d0059f3
      David Howells authored
      
      If we're in FIPS mode, we should panic if we fail to verify the signature on a
      module or we're asked to load an unsigned module in signature enforcing mode.
      Possibly FIPS mode should automatically enable enforcing mode.
      
      Signed-off-by: default avatarDavid Howells <dhowells@redhat.com>
      Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
      1d0059f3
Loading