1. 21 Sep, 2012 10 commits
  2. 20 Sep, 2012 1 commit
  3. 18 Sep, 2012 25 commits
    • Eric W. Biederman's avatar
      userns: Convert quota · 1a06d420
      Eric W. Biederman authored
      Now that the type changes are done, here is the final set of
      changes to make the quota code work when user namespaces are enabled.
      
      Small cleanups and fixes to make the code build when user namespaces
      are enabled.
      
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      1a06d420
    • Eric W. Biederman's avatar
      userns: Convert struct dquot_warn · 7b9c7321
      Eric W. Biederman authored
      Convert w_dq_id to be a struct kquid and remove the now unncessary
      w_dq_type.
      
      This is a simple conversion and enough other places have already
      been converted that this actually reduces the code complexity
      by a little bit, when removing now unnecessary type conversions.
      
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      7b9c7321
    • Eric W. Biederman's avatar
      userns: Convert struct dquot dq_id to be a struct kqid · 4c376dca
      Eric W. Biederman authored
      Change struct dquot dq_id to a struct kqid and remove the now
      unecessary dq_type.
      
      Make minimal changes to dquot, quota_tree, quota_v1, quota_v2, ext3,
      ext4, and ocfs2 to deal with the change in quota structures and
      signatures.  The ocfs2 changes are larger than most because of the
      extensive tracing throughout the ocfs2 quota code that prints out
      dq_id.
      
      quota_tree.c:get_index is modified to take a struct kqid instead of a
      qid_t because all of it's callers pass in dquot->dq_id and it allows
      me to introduce only a single conversion.
      
      The rest of the changes are either just replacing dq_type with dq_id.type,
      adding conversions to deal with the change in type and occassionally
      adding qid_eq to allow quota id comparisons in a user namespace safe way.
      
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Theodore Tso <tytso@mit.edu>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      4c376dca
    • Eric W. Biederman's avatar
      userns: Modify dqget to take struct kqid · aca645a6
      Eric W. Biederman authored
      Modify dqget to take struct kqid instead of a type and an identifier
      pair.
      
      Modify the callers of dqget in ocfs2 and dquot to take generate
      a struct kqid so they can continue to call dqget.  The conversion
      to create struct kqid should all be the final conversions that
      are needed in those code paths.
      
      Cc: Jan Kara <jack@suse.cz>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      aca645a6
    • Eric W. Biederman's avatar
      userns: Convert quota netlink aka quota_send_warning · 431f1974
      Eric W. Biederman authored
      Modify quota_send_warning to take struct kqid instead a type and
      identifier pair.
      
      When sending netlink broadcasts always convert uids and quota
      identifiers into the intial user namespace.  There is as yet no way to
      send a netlink broadcast message with different contents to receivers
      in different namespaces, so for the time being just map all of the
      identifiers into the initial user namespace which preserves the
      current behavior.
      
      Change the callers of quota_send_warning in gfs2, xfs and dquot
      to generate a struct kqid to pass to quota send warning.  When
      all of the user namespaces convesions are complete a struct kqid
      values will be availbe without need for conversion, but a conversion
      is needed now to avoid needing to convert everything at once.
      
      Cc: Ben Myers <bpm@sgi.com>
      Cc: Alex Elder <elder@kernel.org>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Steven Whitehouse <swhiteho@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      431f1974
    • Eric W. Biederman's avatar
      userns: Convert qutoactl · 74a8a103
      Eric W. Biederman authored
      Update the quotactl user space interface to successfull compile with
      user namespaces support enabled and to hand off quota identifiers to
      lower layers of the kernel in struct kqid instead of type and qid
      pairs.
      
      The quota on function is not converted because while it takes a quota
      type and an id.  The id is the on disk quota format to use, which
      is something completely different.
      
      The signature of two struct quotactl_ops methods were changed to take
      struct kqid argumetns get_dqblk and set_dqblk.
      
      The dquot, xfs, and ocfs2 implementations of get_dqblk and set_dqblk
      are minimally changed so that the code continues to work with
      the change in parameter type.
      
      This is the first in a series of changes to always store quota
      identifiers in the kernel in struct kqid and only use raw type and qid
      values when interacting with on disk structures or userspace.  Always
      using struct kqid internally makes it hard to miss places that need
      conversion to or from the kernel internal values.
      
      Cc: Jan Kara <jack@suse.cz>
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Mark Fasheh <mfasheh@suse.com>
      Cc: Joel Becker <jlbec@evilplan.org>
      Cc: Ben Myers <bpm@sgi.com>
      Cc: Alex Elder <elder@kernel.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      74a8a103
    • Eric W. Biederman's avatar
      userns: Implement struct kqid · e8a3e471
      Eric W. Biederman authored
      Add the data type struct kqid which holds the kernel internal form of
      the owning identifier of a quota.  struct kqid is a replacement for
      the implicit union of uid, gid and project id stored in an unsigned
      int and the quota type field that is was used in the quota data
      structures.  Making the data type explicit allows the kuid_t and
      kgid_t type safety to propogate more thoroughly through the code,
      revealing more places where uid/gid conversions need be made.
      
      Along with the data type struct kqid comes the helper functions
      qid_eq, qid_lt, from_kqid, from_kqid_munged, qid_valid, make_kqid,
      make_kqid_invalid, make_kqid_uid, make_kqid_gid.
      
      Cc: Jan Kara <jack@suse.cz>
      Cc: Dave Chinner <david@fromorbit.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      e8a3e471
    • Eric W. Biederman's avatar
      userns: Add kprojid_t and associated infrastructure in projid.h · f76d207a
      Eric W. Biederman authored
      Implement kprojid_t a cousin of the kuid_t and kgid_t.
      
      The per user namespace mapping of project id values can be set with
      /proc/<pid>/projid_map.
      
      A full compliment of helpers is provided: make_kprojid, from_kprojid,
      from_kprojid_munged, kporjid_has_mapping, projid_valid, projid_eq,
      projid_eq, projid_lt.
      
      Project identifiers are part of the generic disk quota interface,
      although it appears only xfs implements project identifiers currently.
      
      The xfs code allows anyone who has permission to set the project
      identifier on a file to use any project identifier so when
      setting up the user namespace project identifier mappings I do
      not require a capability.
      
      Cc: Dave Chinner <david@fromorbit.com>
      Cc: Jan Kara <jack@suse.cz>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      f76d207a
    • Eric W. Biederman's avatar
      userns: Convert configfs to use kuid and kgid where appropriate · 69552c0c
      Eric W. Biederman authored
      Cc: Joel Becker <jlbec@evilplan.org>
      Acked-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      69552c0c
    • Eric W. Biederman's avatar
      userns: Convert extN to support kuids and kgids in posix acls · af84df93
      Eric W. Biederman authored
      Convert ext2, ext3, and ext4 to fully support the posix acl changes,
      using e_uid e_gid instead e_id.
      
      Enabled building with posix acls enabled, all filesystems supporting
      user namespaces, now also support posix acls when user namespaces are enabled.
      
      Cc: Theodore Tso <tytso@mit.edu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      af84df93
    • Eric W. Biederman's avatar
      userns: Pass a userns parameter into posix_acl_to_xattr and posix_acl_from_xattr · 5f3a4a28
      Eric W. Biederman authored
       - Pass the user namespace the uid and gid values in the xattr are stored
         in into posix_acl_from_xattr.
      
       - Pass the user namespace kuid and kgid values should be converted into
         when storing uid and gid values in an xattr in posix_acl_to_xattr.
      
      - Modify all callers of posix_acl_from_xattr and posix_acl_to_xattr to
        pass in &init_user_ns.
      
      In the short term this change is not strictly needed but it makes the
      code clearer.  In the longer term this change is necessary to be able to
      mount filesystems outside of the initial user namespace that natively
      store posix acls in the linux xattr format.
      
      Cc: Theodore Tso <tytso@mit.edu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      5f3a4a28
    • Eric W. Biederman's avatar
      userns: Convert vfs posix_acl support to use kuids and kgids · 2f6f0654
      Eric W. Biederman authored
      - In setxattr if we are setting a posix acl convert uids and gids from
        the current user namespace into the initial user namespace, before
        the xattrs are passed to the underlying filesystem.
      
        Untranslatable uids and gids are represented as -1 which
        posix_acl_from_xattr will represent as INVALID_UID or INVALID_GID.
        posix_acl_valid will fail if an acl from userspace has any
        INVALID_UID or INVALID_GID values.  In net this guarantees that
        untranslatable posix acls will not be stored by filesystems.
      
      - In getxattr if we are reading a posix acl convert uids and gids from
        the initial user namespace into the current user namespace.
      
        Uids and gids that can not be tranlsated into the current user namespace
        will be represented as -1.
      
      - Replace e_id in struct posix_acl_entry with an anymouns union of
        e_uid and e_gid.  For the short term retain the e_id field
        until all of the users are converted.
      
      - Don't set struct posix_acl.e_id in the cases where the acl type
        does not use e_id.  Greatly reducing the use of ACL_UNDEFINED_ID.
      
      - Rework the ordering checks in posix_acl_valid so that I use kuid_t
        and kgid_t types throughout the code, and so that I don't need
        arithmetic on uid and gid types.
      
      Cc: Theodore Tso <tytso@mit.edu>
      Cc: Andrew Morton <akpm@linux-foundation.org>
      Cc: Andreas Dilger <adilger.kernel@dilger.ca>
      Cc: Jan Kara <jack@suse.cz>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      2f6f0654
    • Eric W. Biederman's avatar
      userns: Teach trace to use from_kuid · d20b92ab
      Eric W. Biederman authored
      - When tracing capture the kuid.
      - When displaying the data to user space convert the kuid into the
        user namespace of the process that opened the report file.
      
      Cc: Steven Rostedt <rostedt@goodmis.org>
      Cc: Frederic Weisbecker <fweisbec@gmail.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      d20b92ab
    • Eric W. Biederman's avatar
      userns: Convert bsd process accounting to use kuid and kgid where appropriate · f8f3d4de
      Eric W. Biederman authored
      BSD process accounting conveniently passes the file the accounting
      records will be written into to do_acct_process.  The file credentials
      captured the user namespace of the opener of the file.  Use the file
      credentials to format the uid and the gid of the current process into
      the user namespace of the user that started the bsd process
      accounting.
      
      Cc: Pavel Emelyanov <xemul@openvz.org>
      Reviewed-by: default avatarSerge Hallyn <serge.hallyn@canonical.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      f8f3d4de
    • Eric W. Biederman's avatar
      userns: Convert taskstats to handle the user and pid namespaces. · 4bd6e32a
      Eric W. Biederman authored
      - Explicitly limit exit task stat broadcast to the initial user and
        pid namespaces, as it is already limited to the initial network
        namespace.
      
      - For broadcast task stats explicitly generate all of the idenitiers
        in terms of the initial user namespace and the initial pid
        namespace.
      
      - For request stats report them in terms of the current user namespace
        and the current pid namespace.  Netlink messages are delivered
        syncrhonously to the kernel allowing us to get the user namespace
        and the pid namespace from the current task.
      
      - Pass the namespaces for representing pids and uids and gids
        into bacct_add_task.
      
      Cc: Balbir Singh <bsingharora@gmail.com>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      4bd6e32a
    • Eric W. Biederman's avatar
      userns: Convert audit to work with user namespaces enabled · cca080d9
      Eric W. Biederman authored
      - Explicitly format uids gids in audit messges in the initial user
        namespace. This is safe because auditd is restrected to be in
        the initial user namespace.
      
      - Convert audit_sig_uid into a kuid_t.
      
      - Enable building the audit code and user namespaces at the same time.
      
      The net result is that the audit subsystem now uses kuid_t and kgid_t whenever
      possible making it almost impossible to confuse a raw uid_t with a kuid_t
      preventing bugs.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      cca080d9
    • Eric W. Biederman's avatar
      userns: Convert the audit loginuid to be a kuid · e1760bd5
      Eric W. Biederman authored
      Always store audit loginuids in type kuid_t.
      
      Print loginuids by converting them into uids in the appropriate user
      namespace, and then printing the resulting uid.
      
      Modify audit_get_loginuid to return a kuid_t.
      
      Modify audit_set_loginuid to take a kuid_t.
      
      Modify /proc/<pid>/loginuid on read to convert the loginuid into the
      user namespace of the opener of the file.
      
      Modify /proc/<pid>/loginud on write to convert the loginuid
      rom the user namespace of the opener of the file.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Cc: Paul Moore <paul@paul-moore.com> ?
      Cc: David Miller <davem@davemloft.net>
      Signed-off-by: default avatarEric W. Biederman <ebiederm@xmission.com>
      e1760bd5
    • Eric W. Biederman's avatar
      audit: Add typespecific uid and gid comparators · ca57ec0f
      Eric W. Biederman authored
      The audit filter code guarantees that uid are always compared with
      uids and gids are always compared with gids, as the comparason
      operations are type specific.  Take advantage of this proper to define
      audit_uid_comparator and audit_gid_comparator which use the type safe
      comparasons from uidgid.h.
      
      Build on audit_uid_comparator and audit_gid_comparator and replace
      audit_compare_id with audit_compare_uid and audit_compare_gid.  This
      is one of those odd cases where being type safe and duplicating code
      leads to simpler shorter and more concise code.
      
      Don't allow bitmask operations in uid and gid comparisons in
      audit_data_to_entry.  Bitmask operations are already denined in
      audit_rule_to_entry.
      
      Convert constants in audit_rule_to_entry and audit_data_to_entry into
      kuids and kgids when appropriate.
      
      Convert the uid and gid field in struct audit_names to be of type
      kuid_t and kgid_t respectively, so that the new uid and gid comparators
      can be applied in a type safe manner.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      ca57ec0f
    • Eric W. Biederman's avatar
      audit: Don't pass pid or uid to audit_log_common_recv_msg · 860c0aaf
      Eric W. Biederman authored
      The only place we use the uid and the pid that we calculate in
      audit_receive_msg is in audit_log_common_recv_msg so move the
      calculation of these values into the audit_log_common_recv_msg.
      
      Simplify the calcuation of the current pid and uid by
      reading them from current instead of reading them from
      NETLINK_CREDS.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      860c0aaf
    • Eric W. Biederman's avatar
      audit: Remove the unused uid parameter from audit_receive_filter · 017143fe
      Eric W. Biederman authored
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      017143fe
    • Eric W. Biederman's avatar
      audit: Properly set the origin port id of audit messages. · 35ce9888
      Eric W. Biederman authored
      For user generated audit messages set the portid field in the netlink
      header to the netlink port where the user generated audit message came
      from.  Reporting the process id in a port id field was just nonsense.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      35ce9888
    • Eric W. Biederman's avatar
      audit: Simply AUDIT_TTY_SET and AUDIT_TTY_GET · 8aa14b64
      Eric W. Biederman authored
      Use current instead of looking up the current up the current task by
      process identifier.  Netlink requests are processed in trhe context of
      the sending task so this is safe.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      8aa14b64
    • Eric W. Biederman's avatar
      audit: kill audit_prepare_user_tty · f95732e2
      Eric W. Biederman authored
      Now that netlink messages are processed in the context of the sender
      tty_audit_push_task can be called directly and audit_prepare_user_tty
      which only added looking up the task of the tty by process id is
      not needed.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      f95732e2
    • Eric W. Biederman's avatar
      audit: Use current instead of NETLINK_CREDS() in audit_filter · 02276bda
      Eric W. Biederman authored
      Get caller process uid and gid and pid values from the current task
      instead of the NETLINK_CB.  This is simpler than passing NETLINK_CREDS
      from from audit_receive_msg to audit_filter_user_rules and avoid the
      chance of being hit by the occassional bugs in netlink uid/gid
      credential passing.  This is a safe changes because all netlink
      requests are processed in the task of the sending process.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      02276bda
    • Eric W. Biederman's avatar
      audit: Limit audit requests to processes in the initial pid and user namespaces. · 34e36d8e
      Eric W. Biederman authored
      This allows the code to safely make the assumption that all of the
      uids gids and pids that need to be send in audit messages are in the
      initial namespaces.
      
      If someone cares we may lift this restriction someday but start with
      limiting access so at least the code is always correct.
      
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: Eric Paris <eparis@redhat.com>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      34e36d8e
  4. 14 Sep, 2012 2 commits
  5. 13 Sep, 2012 1 commit
  6. 07 Sep, 2012 1 commit