1. 20 3月, 2014 6 次提交
    • R
      audit: anchor all pid references in the initial pid namespace · f1dc4867
      Richard Guy Briggs 提交于
      Store and log all PIDs with reference to the initial PID namespace and
      use the access functions task_pid_nr() and task_tgid_nr() for task->pid
      and task->tgid.
      
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      (informed by ebiederman's c776b5d2)
      Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      f1dc4867
    • R
      audit: convert PPIDs to the inital PID namespace. · c92cdeb4
      Richard Guy Briggs 提交于
      sys_getppid() returns the parent pid of the current process in its own pid
      namespace.  Since audit filters are based in the init pid namespace, a process
      could avoid a filter or trigger an unintended one by being in an alternate pid
      namespace or log meaningless information.
      
      Switch to task_ppid_nr() for PPIDs to anchor all audit filters in the
      init_pid_ns.
      
      (informed by ebiederman's 6c621b7e)
      Cc: stable@vger.kernel.org
      Cc: Eric W. Biederman <ebiederm@xmission.com>
      Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      c92cdeb4
    • R
      audit: rename the misleading audit_get_context() to audit_take_context() · 4a3eb726
      Richard Guy Briggs 提交于
      "get" usually implies incrementing a refcount into a structure to indicate a
      reference being held by another part of code.
      
      Change this function name to indicate it is in fact being taken from it,
      returning the value while clearing it in the supplying structure.
      Signed-off-by: NRichard Guy Briggs <rgb@redhat.com>
      4a3eb726
    • E
      audit: Send replies in the proper network namespace. · 099dd235
      Eric W. Biederman 提交于
      In perverse cases of file descriptor passing the current network
      namespace of a process and the network namespace of a socket used by
      that socket may differ.  Therefore use the network namespace of the
      appropiate socket to ensure replies always go to the appropiate
      socket.
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      Acked-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      099dd235
    • E
      audit: Use struct net not pid_t to remember the network namespce to reply in · 638a0fd2
      Eric W. Biederman 提交于
      While reading through 3.14-rc1 I found a pretty siginficant mishandling
      of network namespaces in the recent audit changes.
      
      In struct audit_netlink_list and audit_reply add a reference to the
      network namespace of the caller and remove the userspace pid of the
      caller.  This cleanly remembers the callers network namespace, and
      removes a huge class of races and nasty failure modes that can occur
      when attempting to relook up the callers network namespace from a pid_t
      (including the caller's network namespace changing, pid wraparound, and
      the pid simply not being present).
      Signed-off-by: N"Eric W. Biederman" <ebiederm@xmission.com>
      Acked-by: NRichard Guy Briggs <rgb@redhat.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      638a0fd2
    • W
      audit: Audit proc/<pid>/cmdline aka proctitle · 3f1c8250
      William Roberts 提交于
      During an audit event, cache and print the value of the process's
      proctitle value (proc/<pid>/cmdline). This is useful in situations
      where processes are started via fork'd virtual machines where the
      comm field is incorrect. Often times, setting the comm field still
      is insufficient as the comm width is not very wide and most
      virtual machine "package names" do not fit. Also, during execution,
      many threads have their comm field set as well. By tying it back to
      the global cmdline value for the process, audit records will be more
      complete in systems with these properties. An example of where this
      is useful and applicable is in the realm of Android. With Android,
      their is no fork/exec for VM instances. The bare, preloaded Dalvik
      VM listens for a fork and specialize request. When this request comes
      in, the VM forks, and the loads the specific application (specializing).
      This was done to take advantage of COW and to not require a load of
      basic packages by the VM on very app spawn. When this spawn occurs,
      the package name is set via setproctitle() and shows up in procfs.
      Many of these package names are longer then 16 bytes, the historical
      width of task->comm. Having the cmdline in the audit records will
      couple the application back to the record directly. Also, on my
      Debian development box, some audit records were more useful then
      what was printed under comm.
      
      The cached proctitle is tied to the life-cycle of the audit_context
      structure and is built on demand.
      
      Proctitle is controllable by userspace, and thus should not be trusted.
      It is meant as an aid to assist in debugging. The proctitle event is
      emitted during syscall audits, and can be filtered with auditctl.
      
      Example:
      type=AVC msg=audit(1391217013.924:386): avc:  denied  { getattr } for  pid=1971 comm="mkdir" name="/" dev="selinuxfs" ino=1 scontext=system_u:system_r:consolekit_t:s0-s0:c0.c255 tcontext=system_u:object_r:security_t:s0 tclass=filesystem
      type=SYSCALL msg=audit(1391217013.924:386): arch=c000003e syscall=137 success=yes exit=0 a0=7f019dfc8bd7 a1=7fffa6aed2c0 a2=fffffffffff4bd25 a3=7fffa6aed050 items=0 ppid=1967 pid=1971 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="mkdir" exe="/bin/mkdir" subj=system_u:system_r:consolekit_t:s0-s0:c0.c255 key=(null)
      type=UNKNOWN[1327] msg=audit(1391217013.924:386):  proctitle=6D6B646972002D70002F7661722F72756E2F636F6E736F6C65
      
      Acked-by: Steve Grubb <sgrubb@redhat.com> (wrt record formating)
      Signed-off-by: NWilliam Roberts <wroberts@tresys.com>
      Signed-off-by: NEric Paris <eparis@redhat.com>
      3f1c8250
  2. 08 3月, 2014 1 次提交
  3. 18 1月, 2014 2 次提交
  4. 15 1月, 2014 3 次提交
    • J
      audit: Convert int limit uses to u32 · 3e1d0bb6
      Joe Perches 提交于
      The equivalent uapi struct uses __u32 so make the kernel
      uses u32 too.
      
      This can prevent some oddities where the limit is
      logged/emitted as a negative value.
      
      Convert kstrtol to kstrtouint to disallow negative values.
      Signed-off-by: NJoe Perches <joe@perches.com>
      [eparis: do not remove static from audit_default declaration]
      3e1d0bb6
    • J
      audit: Use more current logging style · d957f7b7
      Joe Perches 提交于
      Add pr_fmt to prefix "audit: " to output
      Convert printk(KERN_<LEVEL> to pr_<level>
      Coalesce formats
      Use pr_cont
      Move a brace after switch
      Signed-off-by: NJoe Perches <joe@perches.com>
      d957f7b7
    • J
      audit: Use hex_byte_pack_upper · b8dbc324
      Joe Perches 提交于
      Using the generic kernel function causes the
      object size to increase with gcc 4.8.1.
      
      $ size kernel/audit.o*
         text	   data	    bss	    dec	    hex	filename
        18577	   6079	   8436	  33092	   8144	kernel/audit.o.new
        18579	   6015	   8420	  33014	   80f6	kernel/audit.o.old
      
      Unsigned...
      b8dbc324
  5. 14 1月, 2014 28 次提交