18 Aug, 2020

1 commit

  • Presently mdp does not enable any SELinux policy capabilities
    in the dummy policy it generates. Thus, policies derived from
    it will by default lack various features commonly used in modern
    policies such as open permission, extended socket classes, network
    peer controls, etc. Split the policy capability definitions out into
    their own headers so that we can include them into mdp without pulling in
    other kernel headers and extend mdp generate policycap statements for the
    policy capabilities known to the kernel. Policy authors may wish to
    selectively remove some of these from the generated policy.

    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

10 Aug, 2020

2 commits

  • Pull Kbuild updates from Masahiro Yamada:

    - run the checker (e.g. sparse) after the compiler

    - remove unneeded cc-option tests for old compiler flags

    - fix tar-pkg to install dtbs

    - introduce ccflags-remove-y and asflags-remove-y syntax

    - allow to trace functions in sub-directories of lib/

    - introduce hostprogs-always-y and userprogs-always-y syntax

    - various Makefile cleanups

    * tag 'kbuild-v5.9' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild:
    kbuild: stop filtering out $(GCC_PLUGINS_CFLAGS) from cc-option base
    kbuild: include scripts/Makefile.* only when relevant CONFIG is enabled
    kbuild: introduce hostprogs-always-y and userprogs-always-y
    kbuild: sort hostprogs before passing it to ifneq
    kbuild: move host .so build rules to scripts/gcc-plugins/Makefile
    kbuild: Replace HTTP links with HTTPS ones
    kbuild: trace functions in subdirectories of lib/
    kbuild: introduce ccflags-remove-y and asflags-remove-y
    kbuild: do not export LDFLAGS_vmlinux
    kbuild: always create directories of targets
    powerpc/boot: add DTB to 'targets'
    kbuild: buildtar: add dtbs support
    kbuild: remove cc-option test of -ffreestanding
    kbuild: remove cc-option test of -fno-stack-protector
    Revert "kbuild: Create directory for target DTB"
    kbuild: run the checker after the compiler

    Linus Torvalds
     
  • To build host programs, you need to add the program names to 'hostprogs'
    to use the necessary build rule, but it is not enough to build them
    because there is no dependency.

    There are two types of host programs: built as the prerequisite of
    another (e.g. gen_crc32table in lib/Makefile), or always built when
    Kbuild visits the Makefile (e.g. genksyms in scripts/genksyms/Makefile).

    The latter is typical in Makefiles under scripts/, which contains host
    programs globally used during the kernel build. To build them, you need
    to add them to both 'hostprogs' and 'always-y'.

    This commit adds hostprogs-always-y as a shorthand.

    The same applies to user programs. net/bpfilter/Makefile builds
    bpfilter_umh on demand, hence always-y is unneeded. In contrast,
    programs under samples/ are added to both 'userprogs' and 'always-y'
    so they are always built when Kbuild visits the Makefiles.

    userprogs-always-y works as a shorthand.

    Signed-off-by: Masahiro Yamada
    Acked-by: Miguel Ojeda

    Masahiro Yamada
     

24 Jun, 2020

1 commit

  • commit e3e0b582c321 ("selinux: remove unused initial SIDs and improve
    handling") broke scripts/selinux/mdp since the unused initial SID names
    were removed and the corresponding generation of policy initial SID
    definitions by mdp was not updated accordingly. Fix it. With latest
    upstream checkpolicy it is no longer necessary to include the SID context
    definitions for the unused initial SIDs but retain them for compatibility
    with older checkpolicy.

    Fixes: e3e0b582c321 ("selinux: remove unused initial SIDs and improve handling")
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

04 Apr, 2020

1 commit

  • Pull SPDX updates from Greg KH:
    "Here are three SPDX patches for 5.7-rc1.

    One fixes up the SPDX tag for a single driver, while the other two go
    through the tree and add SPDX tags for all of the .gitignore files as
    needed.

    Nothing too complex, but you will get a merge conflict with your
    current tree, that should be trivial to handle (one file modified by
    two things, one file deleted.)

    All three of these have been in linux-next for a while, with no
    reported issues other than the merge conflict"

    * tag 'spdx-5.7-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/spdx:
    ASoC: MT6660: make spdxcheck.py happy
    .gitignore: add SPDX License Identifier
    .gitignore: remove too obvious comments

    Linus Torvalds
     

25 Mar, 2020

2 commits


28 Feb, 2020

1 commit

  • Remove initial SIDs that have never been used or are no longer used by
    the kernel from its string table, which is also used to generate the
    SECINITSID_* symbols referenced in code. Update the code to
    gracefully handle the fact that these can now be NULL. Stop treating
    it as an error if a policy defines additional initial SIDs unknown to
    the kernel. Do not load unused initial SID contexts into the sidtab.
    Fix the incorrect usage of the name from the ocontext in error
    messages when loading initial SIDs since these are not presently
    written to the kernel policy and are therefore always NULL.

    After this change, it is possible to safely reclaim and reuse some of
    the unused initial SIDs without compatibility issues. Specifically,
    unused initial SIDs that were being assigned the same context as the
    unlabeled initial SID in policies can be reclaimed and reused for
    another purpose, with existing policies still treating them as having
    the unlabeled context and future policies having the option of mapping
    them to a more specific context. For example, this could have been
    used when the infiniband labeling support was introduced to define
    initial SIDs for the default pkey and endport SIDs similar to the
    handling of port/netif/node SIDs rather than always using
    SECINITSID_UNLABELED as the default.

    The set of safely reclaimable unused initial SIDs across all known
    policies is igmp_packet (13), icmp_socket (14), tcp_socket (15), kmod
    (24), policy (25), and scmp_packet (26); these initial SIDs were
    assigned the same context as unlabeled in all known policies including
    mls. If only considering non-mls policies (i.e. assuming that mls
    users always upgrade policy with their kernels), the set of safely
    reclaimable unused initial SIDs further includes file_labels (6), init
    (7), sysctl_modprobe (16), and sysctl_fs (18) through sysctl_dev (23).

    Adding new initial SIDs beyond SECINITSID_NUM to policy unfortunately
    became a fatal error in commit 24ed7fdae669 ("selinux: use separate
    table for initial SID lookup") and even before that it could cause
    problems on a policy reload (collision between the new initial SID and
    one allocated at runtime) ever since commit 42596eafdd75 ("selinux:
    load the initial SIDs upon every policy load") so we cannot safely
    start adding new initial SIDs to policies beyond SECINITSID_NUM (27)
    until such a time as all such kernels do not need to be supported and
    only those that include this commit are relevant. That is not a big
    deal since we haven't added a new initial SID since 2004 (v2.6.7) and
    we have plenty of unused ones we can reclaim if we truly need one.

    If we want to avoid the wasted storage in initial_sid_to_string[]
    and/or sidtab->isids[] for the unused initial SIDs, we could introduce
    an indirection between the kernel initial SID values and the policy
    initial SID values and just map the policy SID values in the ocontexts
    to the kernel values during policy_load_isids(). Originally I thought
    we'd do this by preserving the initial SID names in the kernel policy
    and creating a mapping at load time like we do for the security
    classes and permissions but that would require a new kernel policy
    format version and associated changes to libsepol/checkpolicy and I'm
    not sure it is justified. Simpler approach is just to create a fixed
    mapping table in the kernel from the existing fixed policy values to
    the kernel values. Less flexible but probably sufficient.

    A separate selinux userspace change was applied in
    https://github.com/SELinuxProject/selinux/commit/8677ce5e8f592950ae6f14cea1b68a20ddc1ac25
    to enable removal of most of the unused initial SID contexts from
    policies, but there is no dependency between that change and this one.
    That change permits removing all of the unused initial SID contexts
    from policy except for the fs and sysctl SID contexts. The initial
    SID declarations themselves would remain in policy to preserve the
    values of subsequent ones but the contexts can be dropped. If/when
    the kernel decides to reuse one of them, future policies can change
    the name and start assigning a context again without breaking
    compatibility.

    Here is how I would envision staging changes to the initial SIDs in a
    compatible manner after this commit is applied:

    1. At any time after this commit is applied, the kernel could choose
    to reclaim one of the safely reclaimable unused initial SIDs listed
    above for a new purpose (i.e. replace its NULL entry in the
    initial_sid_to_string[] table with a new name and start using the
    newly generated SECINITSID_name symbol in code), and refpolicy could
    at that time rename its declaration of that initial SID to reflect its
    new purpose and start assigning it a context going
    forward. Existing/old policies would map the reclaimed initial SID to
    the unlabeled context, so that would be the initial default behavior
    until policies are updated. This doesn't depend on the selinux
    userspace change; it will work with existing policies and userspace.

    2. In 6 months or so we'll have another SELinux userspace release that
    will include the libsepol/checkpolicy support for omitting unused
    initial SID contexts.

    3. At any time after that release, refpolicy can make that release its
    minimum build requirement and drop the sid context statements (but not
    the sid declarations) for all of the unused initial SIDs except for
    fs and sysctl, which must remain for compatibility on policy
    reload with old kernels and for compatibility with kernels that were
    still using SECINITSID_SYSCTL (< 2.6.39). This doesn't depend on this
    kernel commit; it will work with previous kernels as well.

    4. After N years for some value of N, refpolicy decides that it no
    longer cares about policy reload compatibility for kernels that
    predate this kernel commit, and refpolicy drops the fs and sysctl
    SID contexts from policy too (but retains the declarations).

    5. After M years for some value of M, the kernel decides that it no
    longer cares about compatibility with refpolicies that predate step 4
    (dropping the fs and sysctl SIDs), and those two SIDs also become
    safely reclaimable. This step is optional and need not ever occur unless
    we decide that the need to reclaim those two SIDs outweighs the
    compatibility cost.

    6. After O years for some value of O, refpolicy decides that it no
    longer cares about policy load (not just reload) compatibility for
    kernels that predate this kernel commit, and both kernel and refpolicy
    can then start adding and using new initial SIDs beyond 27. This does
    not depend on the previous change (step 5) and can occur independent
    of it.

    Fixes: https://github.com/SELinuxProject/selinux-kernel/issues/12
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

04 Feb, 2020

1 commit

  • In old days, the "host-progs" syntax was used for specifying host
    programs. It was renamed to the current "hostprogs-y" in 2004.

    It is typically useful in scripts/Makefile because it allows Kbuild to
    selectively compile host programs based on the kernel configuration.

    This commit renames like follows:

    always -> always-y
    hostprogs-y -> hostprogs

    So, scripts/Makefile will look like this:

    always-$(CONFIG_BUILD_BIN2C) += ...
    always-$(CONFIG_KALLSYMS) += ...
    ...
    hostprogs := $(always-y) $(always-m)

    I think this makes more sense because a host program is always a host
    program, irrespective of the kernel configuration. We want to specify
    which ones to compile by CONFIG options, so always-y will be handier.

    The "always", "hostprogs-y", "hostprogs-m" will be kept for backward
    compatibility for a while.

    Signed-off-by: Masahiro Yamada

    Masahiro Yamada
     

31 May, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this program is free software you can redistribute it and or modify
    it under the terms of the gnu general public license as published by
    the free software foundation either version 2 of the license or at
    your option any later version this program is distributed in the
    hope that it will be useful but without any warranty without even
    the implied warranty of merchantability or fitness for a particular
    purpose see the gnu general public license for more details you
    should have received a copy of the gnu general public license along
    with this program if not write to the free software foundation inc
    59 temple place suite 330 boston ma 02111 1307 usa

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-or-later

    has been chosen to replace the boilerplate/reference in 1334 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Allison Randal
    Reviewed-by: Richard Fontana
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190527070033.113240726@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

21 May, 2019

1 commit


20 Mar, 2019

1 commit

  • We need to add the object tree include directory to the include path
    for building mdp in order to pick up generated/autoconf.h. Otherwise,
    make O=/path/to/objtree breaks.

    Fixes: e37c1877ba5b ("scripts/selinux: modernize mdp")
    Reported-by: Stephen Rothwell
    Signed-off-by: Stephen Smalley
    Signed-off-by: Paul Moore

    Stephen Smalley
     

19 Mar, 2019

2 commits

  • When compiling genheaders and mdp from a newer host kernel, the
    following error happens:

    In file included from scripts/selinux/genheaders/genheaders.c:18:
    ./security/selinux/include/classmap.h:238:2: error: #error New
    address family defined, please update secclass_map. #error New
    address family defined, please update secclass_map. ^~~~~
    make[3]: *** [scripts/Makefile.host:107:
    scripts/selinux/genheaders/genheaders] Error 1 make[2]: ***
    [scripts/Makefile.build:599: scripts/selinux/genheaders] Error 2
    make[1]: *** [scripts/Makefile.build:599: scripts/selinux] Error 2
    make[1]: *** Waiting for unfinished jobs....

    Instead of relying on the host definition, include linux/socket.h in
    classmap.h to have PF_MAX.

    Signed-off-by: Paulo Alcantara
    Acked-by: Stephen Smalley
    [PM: manually merge in mdp.c, subject line tweaks]
    Signed-off-by: Paul Moore

    Paulo Alcantara
     
  • Derived in part from a patch by Dominick Grift.

    The MDP example no longer works on modern systems. Fix it.
    While we are at it, add MLS support and enable it.

    NB This still does not work on systems using dbus-daemon instead of
    dbus-broker because dbus-daemon does not yet gracefully handle unknown
    classes/permissions. This appears to be a deficiency in libselinux's
    selinux_set_mapping() interface and underlying implementation,
    which was never fully updated to deal with unknown classes/permissions
    unlike the kernel. The same problem also occurs with XSELinux.
    Programs that instead use selinux_check_access() like dbus-broker
    should not have this problem.

    Changes to mdp:
    Add support for devtmpfs, required by modern Linux distributions.
    Add MLS support, with sample sensitivities, categories, and constraints.
    Generate fs_use and genfscon rules based on kernel configuration.
    Update list of filesystem types for fs_use and genfscon rules.
    Use object_r for object contexts.

    Changes to install_policy.sh:
    Bail immediately on any errors.
    Provide more helpful error messages when unable to find userspace tools.
    Refuse to run if SELinux is already enabled.
    Unconditionally move aside /etc/selinux/config and create a new one.
    Build policy with -U allow so that userspace object managers do not break.
    Build policy with MLS enabled by default.
    Create seusers, failsafe_context, and default_contexts for use by
    pam_selinux / libselinux.
    Create x_contexts for the SELinux X extension.
    Create virtual_domain_context and virtual_image_context for libvirtd.
    Set to permissive mode rather than enforcing to permit initial autorelabel.
    Update the list of filesystem types to be relabeled.
    Write -F to /.autorelabel to cause a forced autorelabel on reboot.
    Drop broken attempt to relabel the /dev mountpoint directory.

    Signed-off-by: Stephen Smalley
    Acked-by: Dominick Grift
    Signed-off-by: Paul Moore

    Stephen Smalley
     

10 Dec, 2018

1 commit

  • Please, use at least K&R C; printf had been able to left-adjust
    a field for as long as stdio existed and use of '*' for variable
    width had been there since v7. Yes, the first edition of K&R
    didn't cover the latter feature (it slightly predates v7), but
    you are using a much later feature of the language than that -
    in K&R C
    static char *stoupperx(const char *s)
    {
    ...
    }
    would've been spelled as
    static char *stoupperx(s)
    char *s;
    {
    ...
    }

    While we are at it, the use of strstr() is bogus - it finds the
    _first_ instance of substring, so it's a lousy fit for checking
    if a string ends with given suffix...

    Signed-off-by: Al Viro

    Al Viro
     

06 Jun, 2018

1 commit

  • The Lustre filesystem has been in the kernel tree for over 5 years now.
    While it has been an endless source of enjoyment for new kernel
    developers learning how to do basic codingstyle cleanups, as well as an
    semi-entertaining source of bewilderment from the vfs developers any
    time they have looked into the codebase to try to figure out how to port
    their latest api changes to this filesystem, it has not really moved
    forward into the "this is in shape to get out of staging" despite many
    half-completed attempts.

    And getting code out of staging is the main goal of that portion of the
    kernel tree. Code should not stagnate and it feels like having this
    code in staging is only causing the development cycle of the filesystem
    to take longer than it should. There is a whole separate out-of-tree
    copy of this codebase where the developers work on it, and then random
    changes are thrown over the wall at staging at some later point in time.
    This dual-tree development model has never worked, and the state of this
    codebase is proof of that.

    So, let's just delete the whole mess. Now the lustre developers can go
    off and work in their out-of-tree codebase and not have to worry about
    providing valid changelog entries and breaking their patches up into
    logical pieces. They can take the time they have spend doing those
    types of housekeeping chores and get the codebase into a much better
    shape, and it can be submitted for inclusion into the real part of the
    kernel tree when ready.

    Cc: Oleg Drokin
    Cc: Andreas Dilger
    Cc: James Simmons
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

18 Nov, 2017

1 commit

  • Pull Kbuild updates from Masahiro Yamada:
    "One of the most remarkable improvements in this cycle is, Kbuild is
    now able to cache the result of shell commands. Some variables are
    expensive to compute, for example, $(call cc-option,...) invokes the
    compiler. It is not efficient to redo this computation every time,
    even when we are not actually building anything. Kbuild creates a
    hidden file ".cache.mk" that contains invoked shell commands and their
    results. The speed-up should be noticeable.

    Summary:

    - Fix arch build issues (hexagon, sh)

    - Clean up various Makefiles and scripts

    - Fix wrong usage of {CFLAGS,LDFLAGS}_MODULE in arch Makefiles

    - Cache variables that are expensive to compute

    - Improve cc-ldopton and ld-option for Clang

    - Optimize output directory creation"

    * tag 'kbuild-v4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/masahiroy/linux-kbuild: (30 commits)
    kbuild: move coccicheck help from scripts/Makefile.help to top Makefile
    sh: decompressor: add shipped files to .gitignore
    frv: .gitignore: ignore vmlinux.lds
    selinux: remove unnecessary assignment to subdir-
    kbuild: specify FORCE in Makefile.headersinst as .PHONY target
    kbuild: remove redundant mkdir from ./Kbuild
    kbuild: optimize object directory creation for incremental build
    kbuild: create object directories simpler and faster
    kbuild: filter-out PHONY targets from "targets"
    kbuild: remove redundant $(wildcard ...) for cmd_files calculation
    kbuild: create directory for make cache only when necessary
    sh: select KBUILD_DEFCONFIG depending on ARCH
    kbuild: fix linker feature test macros when cross compiling with Clang
    kbuild: shrink .cache.mk when it exceeds 1000 lines
    kbuild: do not call cc-option before KBUILD_CFLAGS initialization
    kbuild: Cache a few more calls to the compiler
    kbuild: Add a cache for generated variables
    kbuild: add forward declaration of default target to Makefile.asm-generic
    kbuild: remove KBUILD_SUBDIR_ASFLAGS and KBUILD_SUBDIR_CCFLAGS
    hexagon/kbuild: replace CFLAGS_MODULE with KBUILD_CFLAGS_MODULE
    ...

    Linus Torvalds
     

16 Nov, 2017

1 commit


02 Nov, 2017

1 commit

  • Many source files in the tree are missing licensing information, which
    makes it harder for compliance tools to determine the correct license.

    By default all files without license information are under the default
    license of the kernel, which is GPL version 2.

    Update the files which contain no license information with the 'GPL-2.0'
    SPDX license identifier. The SPDX identifier is a legally binding
    shorthand, which can be used instead of the full boiler plate text.

    This patch is based on work done by Thomas Gleixner and Kate Stewart and
    Philippe Ombredanne.

    How this work was done:

    Patches were generated and checked against linux-4.14-rc6 for a subset of
    the use cases:
    - file had no licensing information it it.
    - file was a */uapi/* one with no licensing information in it,
    - file was a */uapi/* one with existing licensing information,

    Further patches will be generated in subsequent months to fix up cases
    where non-standard license headers were used, and references to license
    had to be inferred by heuristics based on keywords.

    The analysis to determine which SPDX License Identifier to be applied to
    a file was done in a spreadsheet of side by side results from of the
    output of two independent scanners (ScanCode & Windriver) producing SPDX
    tag:value files created by Philippe Ombredanne. Philippe prepared the
    base worksheet, and did an initial spot review of a few 1000 files.

    The 4.13 kernel was the starting point of the analysis with 60,537 files
    assessed. Kate Stewart did a file by file comparison of the scanner
    results in the spreadsheet to determine which SPDX license identifier(s)
    to be applied to the file. She confirmed any determination that was not
    immediately clear with lawyers working with the Linux Foundation.

    Criteria used to select files for SPDX license identifier tagging was:
    - Files considered eligible had to be source code files.
    - Make and config files were included as candidates if they contained >5
    lines of source
    - File already had some variant of a license header in it (even if
    Reviewed-by: Philippe Ombredanne
    Reviewed-by: Thomas Gleixner
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

01 Aug, 2017

1 commit


19 May, 2017

1 commit


11 Mar, 2017

1 commit

  • Compiling with clang and -Wundef makes the compiler report a usage of
    undefined PF_MAX macro in security/selinux/include/classmap.h:

    In file included from scripts/selinux/mdp/mdp.c:48:
    security/selinux/include/classmap.h:37:31: warning: no previous
    extern declaration for non-static variable 'secclass_map'
    [-Wmissing-variable-declarations]
    struct security_class_mapping secclass_map[] = {
    ^
    security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not
    defined, evaluates to 0 [-Werror,-Wundef]
    #if PF_MAX > 43
    ^
    In file included from scripts/selinux/genheaders/genheaders.c:17:
    security/selinux/include/classmap.h:37:31: warning: no previous
    extern declaration for non-static variable 'secclass_map'
    [-Wmissing-variable-declarations]
    struct security_class_mapping secclass_map[] = {
    ^
    security/selinux/include/classmap.h:235:5: error: 'PF_MAX' is not
    defined, evaluates to 0 [-Werror,-Wundef]
    #if PF_MAX > 43
    ^

    PF_MAX is defined in include/linux/socket.h but not in
    include/uapi/linux/socket.h. Therefore host programs have to rely on the
    definition from libc's /usr/include/bits/socket.h, included by
    .

    Fix the issue by using sys/socket.h in mdp and genheaders. When
    classmap.h is included by security/selinux/avc.c, it uses the kernel
    definition of PF_MAX, which makes the test consistent.

    Signed-off-by: Nicolas Iooss
    Signed-off-by: Paul Moore

    Nicolas Iooss
     

21 Dec, 2016

1 commit

  • Commit 3322d0d64f4e ("selinux: keep SELinux in sync with new capability
    definitions") added a check on the defined capabilities without
    explicitly including the capability header file which caused problems
    when building genheaders for users of clang/llvm. Resolve this by
    using the kernel headers when building genheaders, which is arguably
    the right thing to do regardless, and explicitly including the
    kernel's capability.h header file in classmap.h. We also update the
    mdp build, even though it wasn't causing an error we really should
    be using the headers from the kernel we are building.

    Reported-by: Nicolas Iooss
    Signed-off-by: Paul Moore

    Paul Moore
     

14 Jul, 2015

1 commit


20 Aug, 2014

1 commit


19 Jul, 2014

1 commit


18 Jun, 2014

1 commit


10 Jun, 2014

1 commit


20 May, 2011

1 commit


04 Mar, 2011

1 commit

  • The security_is_socket_class() is auto-generated by genheaders based
    on classmap.h to reduce maintenance effort when a new class is defined
    in SELinux kernel. The name for any socket class should be suffixed by
    "socket" and doesn't contain more than one substr of "socket".

    Signed-off-by: Harry Ciao
    Signed-off-by: Eric Paris
    Acked-by: Stephen Smalley

    Harry Ciao
     

16 Mar, 2010

1 commit

  • Fix const warning in the genheaders script as a result of
    changes to the headers, as noted here:

    http://linux.derkeiler.com/Mailing-Lists/Kernel/2010-03/msg03977.html

    Reported-by: Stephen Rothwell
    Signed-off-by: James Morris

    James Morris
     

23 Nov, 2009

1 commit

  • If a permission name is long enough the selinux class definition generation
    tool will go into a infinite loop. This is because it's macro max() is
    fooled into thinking it is dealing with unsigned numbers. This patch makes
    sure the macro always uses signed number so 1 > -1.

    Signed-off-by: Eric Paris
    Signed-off-by: James Morris

    Eric Paris
     

19 Nov, 2009

1 commit

  • scripts/selinux/genheaders/genheaders.c:20: warning: no previous prototype
    for ?usage?
    scripts/selinux/genheaders/genheaders.c:26: warning: no previous prototype
    for ?stoupperx?

    Signed-off-by: Alan Cox
    Acked-by: WANG Cong
    Signed-off-by: James Morris

    Alan Cox
     

24 Oct, 2009

1 commit


07 Oct, 2009

2 commits

  • Add a simple utility (scripts/selinux/genheaders) and invoke it to
    generate the kernel-private class and permission indices in flask.h
    and av_permissions.h automatically during the kernel build from the
    security class mapping definitions in classmap.h. Adding new kernel
    classes and permissions can then be done just by adding them to classmap.h.

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     
  • Modify SELinux to dynamically discover class and permission values
    upon policy load, based on the dynamic object class/perm discovery
    logic from libselinux. A mapping is created between kernel-private
    class and permission indices used outside the security server and the
    policy values used within the security server.

    The mappings are only applied upon kernel-internal computations;
    similar mappings for the private indices of userspace object managers
    is handled on a per-object manager basis by the userspace AVC. The
    interfaces for compute_av and transition_sid are split for kernel
    vs. userspace; the userspace functions are distinguished by a _user
    suffix.

    The kernel-private class indices are no longer tied to the policy
    values and thus do not need to skip indices for userspace classes;
    thus the kernel class index values are compressed. The flask.h
    definitions were regenerated by deleting the userspace classes from
    refpolicy's definitions and then regenerating the headers. Going
    forward, we can just maintain the flask.h, av_permissions.h, and
    classmap.h definitions separately from policy as they are no longer
    tied to the policy values. The next patch introduces a utility to
    automate generation of flask.h and av_permissions.h from the
    classmap.h definitions.

    The older kernel class and permission string tables are removed and
    replaced by a single security class mapping table that is walked at
    policy load to generate the mapping. The old kernel class validation
    logic is completely replaced by the mapping logic.

    The handle unknown logic is reworked. reject_unknown=1 is handled
    when the mappings are computed at policy load time, similar to the old
    handling by the class validation logic. allow_unknown=1 is handled
    when computing and mapping decisions - if the permission was not able
    to be mapped (i.e. undefined, mapped to zero), then it is
    automatically added to the allowed vector. If the class was not able
    to be mapped (i.e. undefined, mapped to zero), then all permissions
    are allowed for it if allow_unknown=1.

    avc_audit leverages the new security class mapping table to lookup the
    class and permission names from the kernel-private indices.

    The mdp program is updated to use the new table when generating the
    class definitions and allow rules for a minimal boot policy for the
    kernel. It should be noted that this policy will not include any
    userspace classes, nor will its policy index values for the kernel
    classes correspond with the ones in refpolicy (they will instead match
    the kernel-private indices).

    Signed-off-by: Stephen Smalley
    Signed-off-by: James Morris

    Stephen Smalley
     

23 Sep, 2009

1 commit


05 Sep, 2008

1 commit


27 Aug, 2008

1 commit

  • In August 2006 I posted a patch generating a minimal SELinux policy. This
    week, David P. Quigley posted an updated version of that as a patch against
    the kernel. It also had nice logic for auto-installing the policy.

    Following is David's original patch intro (preserved especially
    bc it has stats on the generated policies):

    se interested in the changes there were only two significant
    changes. The first is that the iteration through the list of classes
    used NULL as a sentinel value. The problem with this is that the
    class_to_string array actually has NULL entries in its table as place
    holders for the user space object classes.

    The second change was that it would seem at some point the initial sids
    table was NULL terminated. This is no longer the case so that iteration
    has to be done on array length instead of looking for NULL.

    Some statistics on the policy that it generates:

    The policy consists of 523 lines which contain no blank lines. Of those
    523 lines 453 of them are class, permission, and initial sid
    definitions. These lines are usually little to no concern to the policy
    developer since they will not be adding object classes or permissions.
    Of the remaining 70 lines there is one type, one role, and one user
    statement. The remaining lines are broken into three portions. The first
    group are TE allow rules which make up 29 of the remaining lines, the
    second is assignment of labels to the initial sids which consist of 27
    lines, and file system labeling statements which are the remaining 11.

    In addition to the policy.conf generated there is a single file_contexts
    file containing two lines which labels the entire system with base_t.

    This policy generates a policy.23 binary that is 7920 bytes.

    (then a few versions later...):

    The new policy is 587 lines (stripped of blank lines) with 476 of those
    lines being the boilerplate that I mentioned last time. The remaining
    111 lines have the 3 lines for type, user, and role, 70 lines for the
    allow rules (one for each object class including user space object
    classes), 27 lines to assign types to the initial sids, and 11 lines for
    file system labeling. The policy binary is 9194 bytes.

    Changelog:

    Aug 26: Added Documentation/SELinux.txt
    Aug 26: Incorporated a set of comments by Stephen Smalley:
    1. auto-setup SELINUXTYPE=dummy
    2. don't auto-install if selinux is enabled with
    non-dummy policy
    3. don't re-compute policy version
    4. /sbin/setfiles not /usr/sbin/setfiles
    Aug 22: As per JMorris comments, made sure make distclean
    cleans up the mdp directory.
    Removed a check for file_contexts which is now
    created in the same file as the check, making it
    superfluous.

    Signed-off-by: Serge Hallyn
    Signed-off-by: David Quigley
    Signed-off-by: James Morris

    Serge E. Hallyn