Skip to content
Snippets Groups Projects
  1. Jan 13, 2023
  2. Jan 09, 2023
    • Masahiro Yamada's avatar
      tomoyo: Omit use of bin2c · 80f8be7a
      Masahiro Yamada authored
      
      bin2c was, as its name implies, introduced to convert a binary file to
      C code.
      
      However, I did not see any good reason ever for using this tool because
      using the .incbin directive is much faster, and often results in simpler
      code.
      
      Most of the uses of bin2c have been killed, for example:
      
        - 13610aa9 ("kernel/configs: use .incbin directive to embed config_data.gz")
        - 4c0f032d ("s390/purgatory: Omit use of bin2c")
      
      security/tomoyo/Makefile has even less reason for using bin2c because
      the policy files are text data. So, sed is enough for converting them
      to C string literals, and what is nicer, generates human-readable
      builtin-policy.h.
      
      This is the last user of bin2c. After this commit lands, bin2c will be
      removed.
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      [penguin-kernel: Update sed script to also escape backslash and quote ]
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      80f8be7a
  3. Jan 07, 2023
  4. Oct 19, 2022
  5. Aug 21, 2022
  6. May 23, 2022
  7. Feb 23, 2022
    • Randy Dunlap's avatar
      TOMOYO: fix __setup handlers return values · 39844b7e
      Randy Dunlap authored
      
      __setup() handlers should return 1 if the parameter is handled.
      Returning 0 causes the entire string to be added to init's
      environment strings (limited to 32 strings), unnecessarily polluting it.
      
      Using the documented strings "TOMOYO_loader=string1" and
      "TOMOYO_trigger=string2" causes an Unknown parameter message:
        Unknown kernel command line parameters
          "BOOT_IMAGE=/boot/bzImage-517rc5 TOMOYO_loader=string1 \
           TOMOYO_trigger=string2", will be passed to user space.
      
      and these strings are added to init's environment string space:
        Run /sbin/init as init process
          with arguments:
           /sbin/init
          with environment:
           HOME=/
           TERM=linux
           BOOT_IMAGE=/boot/bzImage-517rc5
           TOMOYO_loader=string1
           TOMOYO_trigger=string2
      
      With this change, these __setup handlers act as expected,
      and init's environment is not polluted with these strings.
      
      Fixes: 0e4ae0e0 ("TOMOYO: Make several options configurable.")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Reported-by: default avatarIgor Zhbanov <i.zhbanov@omprussia.ru>
      Link: https://lore.kernel.org/r/64644a2f-4a20-bab3-1e15-3b2cdd0defe3@omprussia.ru
      
      
      Cc: James Morris <jmorris@namei.org>
      Cc: Kentaro Takeda <takedakn@nttdata.co.jp>
      Cc: tomoyo-dev-en@lists.osdn.me
      Cc: "Serge E. Hallyn" <serge@hallyn.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      39844b7e
  8. Feb 07, 2022
  9. Dec 15, 2021
    • Tetsuo Handa's avatar
      tomoyo: use hwight16() in tomoyo_domain_quota_is_ok() · f702e110
      Tetsuo Handa authored
      
      hwight16() is much faster. While we are at it, no need to include
      "perm =" part into data_race() macro, for perm is a local variable
      that cannot be accessed by other threads.
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      f702e110
    • Dmitry Vyukov's avatar
      tomoyo: Check exceeded quota early in tomoyo_domain_quota_is_ok(). · 04e57a2d
      Dmitry Vyukov authored
      
      If tomoyo is used in a testing/fuzzing environment in learning mode,
      for lots of domains the quota will be exceeded and stay exceeded
      for prolonged periods of time. In such cases it's pointless (and slow)
      to walk the whole acl list again and again just to rediscover that
      the quota is exceeded. We already have the TOMOYO_DIF_QUOTA_WARNED flag
      that notes the overflow condition. Check it early to avoid the slowdown.
      
      [penguin-kernel]
      This patch causes a user visible change that the learning mode will not be
      automatically resumed after the quota is increased. To resume the learning
      mode, administrator will need to explicitly clear TOMOYO_DIF_QUOTA_WARNED
      flag after increasing the quota. But I think that this change is generally
      preferable, for administrator likely wants to optimize the acl list for
      that domain before increasing the quota, or that domain likely hits the
      quota again. Therefore, don't try to care to clear TOMOYO_DIF_QUOTA_WARNED
      flag automatically when the quota for that domain changed.
      
      Signed-off-by: default avatarDmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      04e57a2d
  10. Sep 03, 2021
  11. Jun 15, 2021
    • ChenXiaoSong's avatar
      tomoyo: fix doc warnings · 98eaa63e
      ChenXiaoSong authored
      
      Fix gcc W=1 warnings:
      
      security/tomoyo/audit.c:331: warning: Function parameter or member 'matched_acl' not described in 'tomoyo_get_audit'
      security/tomoyo/securityfs_if.c:146: warning: Function parameter or member 'inode' not described in 'tomoyo_release'
      security/tomoyo/tomoyo.c:122: warning: Function parameter or member 'path' not described in 'tomoyo_inode_getattr'
      security/tomoyo/tomoyo.c:497: warning: Function parameter or member 'clone_flags' not described in 'tomoyo_task_alloc'
      security/tomoyo/util.c:92: warning: Function parameter or member 'time64' not described in 'tomoyo_convert_time'
      
      Signed-off-by: default avatarChenXiaoSong <chenxiaosong2@huawei.com>
      [ penguin-kernel: Also adjust spaces and similar warnings ]
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      98eaa63e
  12. Mar 28, 2021
  13. Feb 01, 2021
  14. Dec 06, 2020
  15. Nov 27, 2020
  16. Nov 03, 2020
  17. Oct 28, 2020
  18. Oct 12, 2020
    • Tetsuo Handa's avatar
      tomoyo: Loosen pathname/domainname validation. · a2075167
      Tetsuo Handa authored
      
      Since commit e2dc9bf3 ("umd: Transform fork_usermode_blob into
      fork_usermode_driver") started calling execve() on a program written in
      a local mount which is not connected to mount tree,
      tomoyo_realpath_from_path() started returning a pathname in
      "$fsname:/$pathname" format which violates TOMOYO's domainname rule that
      it must start with "<$namespace>" followed by zero or more repetitions of
      pathnames which start with '/'.
      
      Since $fsname must not contain '.' since commit 79c0b2df ("add
      filesystem subtype support"), tomoyo_correct_path() can recognize a token
      which appears '/' before '.' appears (e.g. proc:/self/exe ) as a pathname
      while rejecting a token which appears '.' before '/' appears (e.g.
      exec.realpath="/bin/bash" ) as a condition parameter.
      
      Therefore, accept domainnames which contain pathnames which do not start
      with '/' but contain '/' before '.' (e.g. <kernel> tmpfs:/bpfilter_umh ).
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      a2075167
  19. Sep 09, 2020
    • Tetsuo Handa's avatar
      tomoyo: Loosen pathname/domainname validation. · 5384d92e
      Tetsuo Handa authored
      
      Since commit e2dc9bf3 ("umd: Transform fork_usermode_blob into
      fork_usermode_driver") started calling execve() on a program written in
      a local mount which is not connected to mount tree,
      tomoyo_realpath_from_path() started returning a pathname in
      "$fsname:/$pathname" format which violates TOMOYO's domainname rule that
      it must start with "<$namespace>" followed by zero or more repetitions of
      pathnames which start with '/'.
      
      Since $fsname must not contain '.' since commit 79c0b2df ("add
      filesystem subtype support"), tomoyo_correct_path() can recognize a token
      which appears '/' before '.' appears (e.g. proc:/self/exe ) as a pathname
      while rejecting a token which appears '.' before '/' appears (e.g.
      exec.realpath="/bin/bash" ) as a condition parameter.
      
      Therefore, accept domainnames which contain pathnames which do not start
      with '/' but contain '/' before '.' (e.g. <kernel> tmpfs:/bpfilter_umh ).
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      5384d92e
  20. Aug 24, 2020
  21. Aug 12, 2020
  22. Jul 21, 2020
  23. Jun 13, 2020
    • Masahiro Yamada's avatar
      treewide: replace '---help---' in Kconfig files with 'help' · a7f7f624
      Masahiro Yamada authored
      
      Since commit 84af7a61 ("checkpatch: kconfig: prefer 'help' over
      '---help---'"), the number of '---help---' has been gradually
      decreasing, but there are still more than 2400 instances.
      
      This commit finishes the conversion. While I touched the lines,
      I also fixed the indentation.
      
      There are a variety of indentation styles found.
      
        a) 4 spaces + '---help---'
        b) 7 spaces + '---help---'
        c) 8 spaces + '---help---'
        d) 1 space + 1 tab + '---help---'
        e) 1 tab + '---help---'    (correct indentation)
        f) 1 tab + 1 space + '---help---'
        g) 1 tab + 2 spaces + '---help---'
      
      In order to convert all of them to 1 tab + 'help', I ran the
      following commend:
      
        $ find . -name 'Kconfig*' | xargs sed -i 's/^[[:space:]]*---help---/\thelp/'
      
      Signed-off-by: default avatarMasahiro Yamada <masahiroy@kernel.org>
      a7f7f624
  24. May 29, 2020
  25. May 20, 2020
    • Eric W. Biederman's avatar
      exec: Factor security_bprm_creds_for_exec out of security_bprm_set_creds · b8bff599
      Eric W. Biederman authored
      Today security_bprm_set_creds has several implementations:
      apparmor_bprm_set_creds, cap_bprm_set_creds, selinux_bprm_set_creds,
      smack_bprm_set_creds, and tomoyo_bprm_set_creds.
      
      Except for cap_bprm_set_creds they all test bprm->called_set_creds and
      return immediately if it is true.  The function cap_bprm_set_creds
      ignores bprm->calld_sed_creds entirely.
      
      Create a new LSM hook security_bprm_creds_for_exec that is called just
      before prepare_binprm in __do_execve_file, resulting in a LSM hook
      that is called exactly once for the entire of exec.  Modify the bits
      of security_bprm_set_creds that only want to be called once per exec
      into security_bprm_creds_for_exec, leaving only cap_bprm_set_creds
      behind.
      
      Remove bprm->called_set_creds all of it's former users have been moved
      to security_bprm_creds_for_exec.
      
      Add or upate comments a appropriate to bring them up to date and
      to reflect this change.
      
      Link: https://lkml.kernel.org/r/87v9kszrzh.fsf_-_@x220.int.ebiederm.org
      
      
      Acked-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      Acked-by: Casey Schaufler <casey@schaufler-ca.com> # For the LSM and Smack bits
      Reviewed-by: default avatarKees Cook <keescook@chromium.org>
      Signed-off-by: default avatar"Eric W. Biederman" <ebiederm@xmission.com>
      b8bff599
  26. May 19, 2020
  27. May 12, 2020
  28. Apr 24, 2020
  29. Mar 25, 2020
  30. Jan 02, 2020
  31. Dec 16, 2019
  32. Dec 11, 2019
  33. May 21, 2019
  34. May 10, 2019
    • Tetsuo Handa's avatar
      tomoyo: Don't emit WARNING: string while fuzzing testing. · 4ad98ac4
      Tetsuo Handa authored
      
      Commit cff0e6c3ec3e6230 ("tomoyo: Add a kernel config option for fuzzing
      testing.") enabled the learning mode, but syzkaller is detecting any
      "WARNING:" string as a crash. Thus, disable TOMOYO's quota warning if
      built for fuzzing testing.
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Cc: Dmitry Vyukov <dvyukov@google.com>
      Signed-off-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      4ad98ac4
    • Tetsuo Handa's avatar
      tomoyo: Change pathname calculation for read-only filesystems. · 27df4b4a
      Tetsuo Handa authored
      
      Commit 5625f2e3 ("TOMOYO: Change pathname for non-rename()able
      filesystems.") intended to be applied to filesystems where the content is
      not controllable from the userspace (e.g. proc, sysfs, securityfs), based
      on an assumption that such filesystems do not support rename() operation.
      
      But it turned out that read-only filesystems also do not support rename()
      operation despite the content is controllable from the userspace, and that
      commit is annoying TOMOYO users who want to use e.g. squashfs as the root
      filesystem due to use of local name which does not start with '/'.
      
      Therefore, based on an assumption that filesystems which require the
      device argument upon mount() request is an indication that the content
      is controllable from the userspace, do not use local name if a filesystem
      does not support rename() operation but requires the device argument upon
      mount() request.
      
      Signed-off-by: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
      Signed-off-by: default avatarJames Morris <jamorris@linux.microsoft.com>
      27df4b4a
Loading