02 Oct, 2020

1 commit

  • Output defects can exist in sysfs content using sprintf and snprintf.

    sprintf does not know the PAGE_SIZE maximum of the temporary buffer
    used for outputting sysfs content and it's possible to overrun the
    PAGE_SIZE buffer length.

    Add a generic sysfs_emit function that knows that the size of the
    temporary buffer and ensures that no overrun is done.

    Add a generic sysfs_emit_at function that can be used in multiple
    call situations that also ensures that no overrun is done.

    Validate the output buffer argument to be page aligned.
    Validate the offset len argument to be within the PAGE_SIZE buf.

    Signed-off-by: Joe Perches
    Link: https://lore.kernel.org/r/884235202216d464d61ee975f7465332c86f76b2.1600285923.git.joe@perches.com
    Signed-off-by: Greg Kroah-Hartman

    Joe Perches
     

06 Jun, 2020

1 commit

  • Pull rdma updates from Jason Gunthorpe:
    "A more active cycle than most of the recent past, with a few large,
    long discussed works this time.

    The RNBD block driver has been posted for nearly two years now, and
    flowing through RDMA due to it also introducing a new ULP.

    The removal of FMR has been a recurring discussion theme for a long
    time.

    And the usual smattering of features and bug fixes.

    Summary:

    - Various small driver bugs fixes in rxe, mlx5, hfi1, and efa

    - Continuing driver cleanups in bnxt_re, hns

    - Big cleanup of mlx5 QP creation flows

    - More consistent use of src port and flow label when LAG is used and
    a mlx5 implementation

    - Additional set of cleanups for IB CM

    - 'RNBD' network block driver and target. This is a network block
    RDMA device specific to ionos's cloud environment. It brings strong
    multipath and resiliency capabilities.

    - Accelerated IPoIB for HFI1

    - QP/WQ/SRQ ioctl migration for uverbs, and support for multiple
    async fds

    - Support for exchanging the new IBTA defiend ECE data during RDMA CM
    exchanges

    - Removal of the very old and insecure FMR interface from all ULPs
    and drivers. FRWR should be preferred for at least a decade now"

    * tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: (247 commits)
    RDMA/cm: Spurious WARNING triggered in cm_destroy_id()
    RDMA/mlx5: Return ECE DC support
    RDMA/mlx5: Don't rely on FW to set zeros in ECE response
    RDMA/mlx5: Return an error if copy_to_user fails
    IB/hfi1: Use free_netdev() in hfi1_netdev_free()
    RDMA/hns: Uninitialized variable in modify_qp_init_to_rtr()
    RDMA/core: Move and rename trace_cm_id_create()
    IB/hfi1: Fix hfi1_netdev_rx_init() error handling
    RDMA: Remove 'max_map_per_fmr'
    RDMA: Remove 'max_fmr'
    RDMA/core: Remove FMR device ops
    RDMA/rdmavt: Remove FMR memory registration
    RDMA/mthca: Remove FMR support for memory registration
    RDMA/mlx4: Remove FMR support for memory registration
    RDMA/i40iw: Remove FMR leftovers
    RDMA/bnxt_re: Remove FMR leftovers
    RDMA/mlx5: Remove FMR leftovers
    RDMA/core: Remove FMR pool API
    RDMA/rds: Remove FMR support for memory registration
    RDMA/srp: Remove support for FMR memory registration
    ...

    Linus Torvalds
     

18 May, 2020

1 commit

  • Function is going to be used in transport over RDMA module in subsequent
    patches, so export it to GPL modules.

    Link: https://lore.kernel.org/r/20200511135131.27580-2-danil.kipnis@cloud.ionos.com
    Signed-off-by: Roman Pen
    Acked-by: Tejun Heo
    Cc: linux-kernel@vger.kernel.org
    [jwang: extend the commit message]
    Signed-off-by: Jack Wang
    Reviewed-by: Bart Van Assche
    Signed-off-by: Jason Gunthorpe

    Jack Wang
     

21 Apr, 2020

1 commit

  • Some filesystem references got broken by a previous patch
    series I submitted. Address those.

    Signed-off-by: Mauro Carvalho Chehab
    Acked-by: David Sterba # fs/affs/Kconfig
    Link: https://lore.kernel.org/r/57318c53008dbda7f6f4a5a9e5787f4d37e8565a.1586881715.git.mchehab+huawei@kernel.org
    Signed-off-by: Jonathan Corbet

    Mauro Carvalho Chehab
     

06 Apr, 2020

2 commits

  • Commit 9255782f7061 ("sysfs: Wrap __compat_only_sysfs_link_entry_to_kobj
    function to change the symlink name") made this function a wrapper
    around a new non-underscored function, which is a bit odd. The normal
    naming convention is the other way around: the underscored function is
    the wrappee, and the non-underscored function is the wrapper.

    There's only one single user (well, two call-sites in that user) of the
    more limited double underscore version of this function, so just remove
    the oddly named wrapper entirely and just add the extra NULL argument to
    the user.

    I considered just doing that in the merge, but that tends to make
    history really hard to read.

    Link: https://lore.kernel.org/lkml/CAHk-=wgkkmNV5tMzQDmPAQuNJBuMcry--Jb+h8H1o4RA3kF7QQ@mail.gmail.com/
    Cc: Sourabh Jain
    Cc: Michael Ellerman
    Signed-off-by: Linus Torvalds

    Linus Torvalds
     
  • Pull powerpc updates from Michael Ellerman:
    "Slightly late as I had to rebase mid-week to insert a bug fix:

    - A large series from Nick for 64-bit to further rework our exception
    vectors, and rewrite portions of the syscall entry/exit and
    interrupt return in C. The result is much easier to follow code
    that is also faster in general.

    - Cleanup of our ptrace code to split various parts out that had
    become badly intertwined with #ifdefs over the years.

    - Changes to our NUMA setup under the PowerVM hypervisor which should
    hopefully avoid non-sensical topologies which can lead to warnings
    from the workqueue code and other problems.

    - MAINTAINERS updates to remove some of our old orphan entries and
    update the status of others.

    - Quite a few other small changes and fixes all over the map.

    Thanks to: Abdul Haleem, afzal mohammed, Alexey Kardashevskiy, Andrew
    Donnellan, Aneesh Kumar K.V, Balamuruhan S, Cédric Le Goater, Chen
    Zhou, Christophe JAILLET, Christophe Leroy, Christoph Hellwig, Clement
    Courbet, Daniel Axtens, David Gibson, Douglas Miller, Fabiano Rosas,
    Fangrui Song, Ganesh Goudar, Gautham R. Shenoy, Greg Kroah-Hartman,
    Greg Kurz, Gustavo Luiz Duarte, Hari Bathini, Ilie Halip, Jan Kara,
    Joe Lawrence, Joe Perches, Kajol Jain, Larry Finger, Laurentiu Tudor,
    Leonardo Bras, Libor Pechacek, Madhavan Srinivasan, Mahesh Salgaonkar,
    Masahiro Yamada, Masami Hiramatsu, Mauricio Faria de Oliveira, Michael
    Neuling, Michal Suchanek, Mike Rapoport, Nageswara R Sastry, Nathan
    Chancellor, Nathan Lynch, Naveen N. Rao, Nicholas Piggin, Nick
    Desaulniers, Oliver O'Halloran, Po-Hsu Lin, Pratik Rajesh Sampat,
    Rasmus Villemoes, Ravi Bangoria, Roman Bolshakov, Sam Bobroff,
    Sandipan Das, Santosh S, Sedat Dilek, Segher Boessenkool, Shilpasri G
    Bhat, Sourabh Jain, Srikar Dronamraju, Stephen Rothwell, Tyrel
    Datwyler, Vaibhav Jain, YueHaibing"

    * tag 'powerpc-5.7-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (158 commits)
    powerpc: Make setjmp/longjmp signature standard
    powerpc/cputable: Remove unnecessary copy of cpu_spec->oprofile_type
    powerpc: Suppress .eh_frame generation
    powerpc: Drop -fno-dwarf2-cfi-asm
    powerpc/32: drop unused ISA_DMA_THRESHOLD
    powerpc/powernv: Add documentation for the opal sensor_groups sysfs interfaces
    selftests/powerpc: Fix try-run when source tree is not writable
    powerpc/vmlinux.lds: Explicitly retain .gnu.hash
    powerpc/ptrace: move ptrace_triggered() into hw_breakpoint.c
    powerpc/ptrace: create ppc_gethwdinfo()
    powerpc/ptrace: create ptrace_get_debugreg()
    powerpc/ptrace: split out ADV_DEBUG_REGS related functions.
    powerpc/ptrace: move register viewing functions out of ptrace.c
    powerpc/ptrace: split out TRANSACTIONAL_MEM related functions.
    powerpc/ptrace: split out SPE related functions.
    powerpc/ptrace: split out ALTIVEC related functions.
    powerpc/ptrace: split out VSX related functions.
    powerpc/ptrace: drop PARAMETER_SAVE_AREA_OFFSET
    powerpc/ptrace: drop unnecessary #ifdefs CONFIG_PPC64
    powerpc/ptrace: remove unused header includes
    ...

    Linus Torvalds
     

27 Feb, 2020

4 commits

  • Add a helper to change the owner of sysfs objects.
    This function will be used to correctly account for kobject ownership
    changes, e.g. when moving network devices between network namespaces.

    This mirrors how a kobject is added through driver core which in its guts is
    done via kobject_add_internal() which in summary creates the main directory via
    create_dir(), populates that directory with the groups associated with the
    ktype of the kobject (if any) and populates the directory with the basic
    attributes associated with the ktype of the kobject (if any). These are the
    basic steps that are associated with adding a kobject in sysfs.
    Any additional properties are added by the specific subsystem itself (not by
    driver core) after it has registered the device. So for the example of network
    devices, a network device will e.g. register a queue subdirectory under the
    basic sysfs directory for the network device and than further subdirectories
    within that queues subdirectory. But that is all specific to network devices
    and they call the corresponding sysfs functions to do that directly when they
    create those queue objects. So anything that a subsystem adds outside of what
    driver core does must also be changed by it (That's already true for removal of
    files it created outside of driver core.) and it's the same for ownership
    changes.

    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Christian Brauner
    Signed-off-by: David S. Miller

    Christian Brauner
     
  • Add helpers to change the owner of sysfs groups.
    This function will be used to correctly account for kobject ownership
    changes, e.g. when moving network devices between network namespaces.

    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Christian Brauner
    Signed-off-by: David S. Miller

    Christian Brauner
     
  • Add a helper to change the owner of a sysfs link.
    This function will be used to correctly account for kobject ownership
    changes, e.g. when moving network devices between network namespaces.

    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Christian Brauner
    Signed-off-by: David S. Miller

    Christian Brauner
     
  • Add helpers to change the owner of a sysfs files.
    This function will be used to correctly account for kobject ownership
    changes, e.g. when moving network devices between network namespaces.

    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Christian Brauner
    Signed-off-by: David S. Miller

    Christian Brauner
     

19 Feb, 2020

1 commit

  • The __compat_only_sysfs_link_entry_to_kobj function creates a symlink
    to a kobject but doesn't provide an option to change the symlink file
    name.

    This patch adds a wrapper function compat_only_sysfs_link_entry_to_kobj
    that extends the __compat_only_sysfs_link_entry_to_kobj functionality
    which allows function caller to customize the symlink name.

    Signed-off-by: Sourabh Jain
    [mpe: Fix compile error when CONFIG_SYSFS=n]
    Signed-off-by: Michael Ellerman
    Link: https://lore.kernel.org/r/20191211160910.21656-3-sourabhjain@linux.ibm.com

    Sourabh Jain
     

04 Feb, 2020

1 commit

  • 'PTR_ERR(p) == -E*' is a stronger condition than IS_ERR(p).
    Hence, IS_ERR(p) is unneeded.

    The semantic patch that generates this commit is as follows:

    //
    @@
    expression ptr;
    constant error_code;
    @@
    -IS_ERR(ptr) && (PTR_ERR(ptr) == - error_code)
    +PTR_ERR(ptr) == - error_code
    //

    Link: http://lkml.kernel.org/r/20200106045833.1725-1-masahiroy@kernel.org
    Signed-off-by: Masahiro Yamada
    Cc: Julia Lawall
    Acked-by: Stephen Boyd [drivers/clk/clk.c]
    Acked-by: Bartosz Golaszewski [GPIO]
    Acked-by: Wolfram Sang [drivers/i2c]
    Acked-by: Rafael J. Wysocki [acpi/scan.c]
    Acked-by: Rob Herring
    Cc: Eric Biggers
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Masahiro Yamada
     

20 Jul, 2019

1 commit

  • Pull vfs mount updates from Al Viro:
    "The first part of mount updates.

    Convert filesystems to use the new mount API"

    * 'work.mount0' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (63 commits)
    mnt_init(): call shmem_init() unconditionally
    constify ksys_mount() string arguments
    don't bother with registering rootfs
    init_rootfs(): don't bother with init_ramfs_fs()
    vfs: Convert smackfs to use the new mount API
    vfs: Convert selinuxfs to use the new mount API
    vfs: Convert securityfs to use the new mount API
    vfs: Convert apparmorfs to use the new mount API
    vfs: Convert openpromfs to use the new mount API
    vfs: Convert xenfs to use the new mount API
    vfs: Convert gadgetfs to use the new mount API
    vfs: Convert oprofilefs to use the new mount API
    vfs: Convert ibmasmfs to use the new mount API
    vfs: Convert qib_fs/ipathfs to use the new mount API
    vfs: Convert efivarfs to use the new mount API
    vfs: Convert configfs to use the new mount API
    vfs: Convert binfmt_misc to use the new mount API
    convenience helper: get_tree_single()
    convenience helper get_tree_nodev()
    vfs: Kill sget_userns()
    ...

    Linus Torvalds
     

03 Jun, 2019

1 commit

  • Adding sysfs_update_groups function to update
    multiple groups.

    sysfs_update_groups - given a directory kobject, create a bunch of attribute groups
    @kobj: The kobject to update the group on
    @groups: The attribute groups to update, NULL terminated

    This function update a bunch of attribute groups. If an error occurs when
    updating a group, all previously updated groups will be removed together
    with already existing (not updated) attributes.

    Signed-off-by: Jiri Olsa
    Signed-off-by: Peter Zijlstra (Intel)
    Reviewed-by: Greg Kroah-Hartman
    Cc: Alexander Shishkin
    Cc: Arnaldo Carvalho de Melo
    Cc: Linus Torvalds
    Cc: Namhyung Kim
    Cc: Peter Zijlstra
    Cc: Thomas Gleixner
    Link: https://lkml.kernel.org/r/20190512155518.21468-2-jolsa@kernel.org
    Signed-off-by: Ingo Molnar

    Jiri Olsa
     

26 May, 2019

1 commit


21 May, 2019

1 commit


17 Mar, 2019

1 commit


16 Mar, 2019

1 commit


13 Mar, 2019

1 commit

  • Pull vfs mount infrastructure updates from Al Viro:
    "The rest of core infrastructure; no new syscalls in that pile, but the
    old parts are switched to new infrastructure. At that point
    conversions of individual filesystems can happen independently; some
    are done here (afs, cgroup, procfs, etc.), there's also a large series
    outside of that pile dealing with NFS (quite a bit of option-parsing
    stuff is getting used there - it's one of the most convoluted
    filesystems in terms of mount-related logics), but NFS bits are the
    next cycle fodder.

    It got seriously simplified since the last cycle; documentation is
    probably the weakest bit at the moment - I considered dropping the
    commit introducing Documentation/filesystems/mount_api.txt (cutting
    the size increase by quarter ;-), but decided that it would be better
    to fix it up after -rc1 instead.

    That pile allows to do followup work in independent branches, which
    should make life much easier for the next cycle. fs/super.c size
    increase is unpleasant; there's a followup series that allows to
    shrink it considerably, but I decided to leave that until the next
    cycle"

    * 'work.mount' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs: (41 commits)
    afs: Use fs_context to pass parameters over automount
    afs: Add fs_context support
    vfs: Add some logging to the core users of the fs_context log
    vfs: Implement logging through fs_context
    vfs: Provide documentation for new mount API
    vfs: Remove kern_mount_data()
    hugetlbfs: Convert to fs_context
    cpuset: Use fs_context
    kernfs, sysfs, cgroup, intel_rdt: Support fs_context
    cgroup: store a reference to cgroup_ns into cgroup_fs_context
    cgroup1_get_tree(): separate "get cgroup_root to use" into a separate helper
    cgroup_do_mount(): massage calling conventions
    cgroup: stash cgroup_root reference into cgroup_fs_context
    cgroup2: switch to option-by-option parsing
    cgroup1: switch to option-by-option parsing
    cgroup: take options parsing into ->parse_monolithic()
    cgroup: fold cgroup1_mount() into cgroup1_get_tree()
    cgroup: start switching to fs_context
    ipc: Convert mqueue fs to fs_context
    proc: Add fs_context support to procfs
    ...

    Linus Torvalds
     

28 Feb, 2019

1 commit

  • Make kernfs support superblock creation/mount/remount with fs_context.

    This requires that sysfs, cgroup and intel_rdt, which are built on kernfs,
    be made to support fs_context also.

    Notes:

    (1) A kernfs_fs_context struct is created to wrap fs_context and the
    kernfs mount parameters are moved in here (or are in fs_context).

    (2) kernfs_mount{,_ns}() are made into kernfs_get_tree(). The extra
    namespace tag parameter is passed in the context if desired

    (3) kernfs_free_fs_context() is provided as a destructor for the
    kernfs_fs_context struct, but for the moment it does nothing except
    get called in the right places.

    (4) sysfs doesn't wrap kernfs_fs_context since it has no parameters to
    pass, but possibly this should be done anyway in case someone wants to
    add a parameter in future.

    (5) A cgroup_fs_context struct is created to wrap kernfs_fs_context and
    the cgroup v1 and v2 mount parameters are all moved there.

    (6) cgroup1 parameter parsing error messages are now handled by invalf(),
    which allows userspace to collect them directly.

    (7) cgroup1 parameter cleanup is now done in the context destructor rather
    than in the mount/get_tree and remount functions.

    Weirdies:

    (*) cgroup_do_get_tree() calls cset_cgroup_from_root() with locks held,
    but then uses the resulting pointer after dropping the locks. I'm
    told this is okay and needs commenting.

    (*) The cgroup refcount web. This really needs documenting.

    (*) cgroup2 only has one root?

    Add a suggestion from Thomas Gleixner in which the RDT enablement code is
    placed into its own function.

    [folded a leak fix from Andrey Vagin]

    Signed-off-by: David Howells
    cc: Greg Kroah-Hartman
    cc: Tejun Heo
    cc: Li Zefan
    cc: Johannes Weiner
    cc: cgroups@vger.kernel.org
    cc: fenghua.yu@intel.com
    Signed-off-by: Al Viro

    David Howells
     

08 Feb, 2019

1 commit


18 Jan, 2019

1 commit


07 Jan, 2019

1 commit

  • It's rude to crash the system just because the developer did something
    wrong, as it prevents them from usually even seeing what went wrong.

    So convert the few BUG_ON() calls that have snuck into the sysfs code
    over the years to WARN_ON() to make it more "friendly". All of these
    are able to be recovered from, so it makes no sense to crash.

    Reported-by: Linus Torvalds
    Reviewed-by: Rafael J. Wysocki
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

04 Dec, 2018

1 commit

  • Let the passed in array be const (and thus placed in rodata) instead of
    a mutable array of const pointers.

    Cc: Greg Kroah-Hartman
    Cc: "Rafael J. Wysocki"
    Reviewed-by: Rafael J. Wysocki
    Reviewed-by: Greg Kroah-Hartman
    Signed-off-by: Jani Nikula
    Link: https://patchwork.freedesktop.org/patch/msgid/20181004143750.30880-1-jani.nikula@intel.com

    Jani Nikula
     

19 Aug, 2018

1 commit

  • Pull driver core updates from Greg KH:
    "Here are all of the driver core and related patches for 4.19-rc1.

    Nothing huge here, just a number of small cleanups and the ability to
    now stop the deferred probing after init happens.

    All of these have been in linux-next for a while with only a merge
    issue reported"

    * tag 'driver-core-4.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (21 commits)
    base: core: Remove WARN_ON from link dependencies check
    drivers/base: stop new probing during shutdown
    drivers: core: Remove glue dirs from sysfs earlier
    driver core: remove unnecessary function extern declare
    sysfs.h: fix non-kernel-doc comment
    PM / Domains: Stop deferring probe at the end of initcall
    iommu: Remove IOMMU_OF_DECLARE
    iommu: Stop deferring probe at end of initcalls
    pinctrl: Support stopping deferred probe after initcalls
    dt-bindings: pinctrl: add a 'pinctrl-use-default' property
    driver core: allow stopping deferred probe after init
    driver core: add a debugfs entry to show deferred devices
    sysfs: Fix internal_create_group() for named group updates
    base: fix order of OF initialization
    linux/device.h: fix kernel-doc notation warning
    Documentation: update firmware loader fallback reference
    kobject: Replace strncpy with memcpy
    drivers: base: cacheinfo: use OF property_read_u32 instead of get_property,read_number
    kernfs: Replace strncpy with memcpy
    device: Add #define dev_fmt similar to #define pr_fmt
    ...

    Linus Torvalds
     

16 Aug, 2018

1 commit

  • Pull SCSI updates from James Bottomley:
    "This is mostly updates to the usual drivers: mpt3sas, lpfc, qla2xxx,
    hisi_sas, smartpqi, megaraid_sas, arcmsr.

    In addition, with the continuing absence of Nic we have target updates
    for tcmu and target core (all with reviews and acks).

    The biggest observable change is going to be that we're (again) trying
    to switch to mulitqueue as the default (a user can still override the
    setting on the kernel command line).

    Other major core stuff is the removal of the remaining Microchannel
    drivers, an update of the internal timers and some reworks of
    completion and result handling"

    * tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (203 commits)
    scsi: core: use blk_mq_run_hw_queues in scsi_kick_queue
    scsi: ufs: remove unnecessary query(DM) UPIU trace
    scsi: qla2xxx: Fix issue reported by static checker for qla2x00_els_dcmd2_sp_done()
    scsi: aacraid: Spelling fix in comment
    scsi: mpt3sas: Fix calltrace observed while running IO & reset
    scsi: aic94xx: fix an error code in aic94xx_init()
    scsi: st: remove redundant pointer STbuffer
    scsi: qla2xxx: Update driver version to 10.00.00.08-k
    scsi: qla2xxx: Migrate NVME N2N handling into state machine
    scsi: qla2xxx: Save frame payload size from ICB
    scsi: qla2xxx: Fix stalled relogin
    scsi: qla2xxx: Fix race between switch cmd completion and timeout
    scsi: qla2xxx: Fix Management Server NPort handle reservation logic
    scsi: qla2xxx: Flush mailbox commands on chip reset
    scsi: qla2xxx: Fix unintended Logout
    scsi: qla2xxx: Fix session state stuck in Get Port DB
    scsi: qla2xxx: Fix redundant fc_rport registration
    scsi: qla2xxx: Silent erroneous message
    scsi: qla2xxx: Prevent sysfs access when chip is down
    scsi: qla2xxx: Add longer window for chip reset
    ...

    Linus Torvalds
     

03 Aug, 2018

1 commit


30 Jul, 2018

1 commit

  • Commit 5f81880d5204 ("sysfs, kobject: allow creating kobject belonging
    to arbitrary users") incorrectly changed the argument passed as the
    parent parameter when calling sysfs_add_file_mode_ns(). This caused some
    sysfs attribute files to not be added correctly to certain groups.

    Fixes: 5f81880d5204 ("sysfs, kobject: allow creating kobject belonging to arbitrary users")
    Signed-off-by: Tyler Hicks
    Reported-by: Heiner Kallweit
    Tested-by: Heiner Kallweit
    Signed-off-by: David S. Miller

    Tyler Hicks
     

21 Jul, 2018

2 commits

  • Normally kobjects and their sysfs representation belong to global root,
    however it is not necessarily the case for objects in separate namespaces.
    For example, objects in separate network namespace logically belong to the
    container's root and not global root.

    This change lays groundwork for allowing network namespace objects
    ownership to be transferred to container's root user by defining
    get_ownership() callback in ktype structure and using it in sysfs code to
    retrieve desired uid/gid when creating sysfs objects for given kobject.

    Co-Developed-by: Tyler Hicks
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Tyler Hicks
    Signed-off-by: David S. Miller

    Dmitry Torokhov
     
  • This change allows creating kernfs files and directories with arbitrary
    uid/gid instead of always using GLOBAL_ROOT_UID/GID by extending
    kernfs_create_dir_ns() and kernfs_create_file_ns() with uid/gid arguments.
    The "simple" kernfs_create_file() and kernfs_create_dir() are left alone
    and always create objects belonging to the global root.

    When creating symlinks ownership (uid/gid) is taken from the target kernfs
    object.

    Co-Developed-by: Tyler Hicks
    Signed-off-by: Dmitry Torokhov
    Signed-off-by: Tyler Hicks
    Signed-off-by: David S. Miller

    Dmitry Torokhov
     

07 Jul, 2018

1 commit

  • There are a couple of problems with named group updates in the code
    today:

    * sysfs_update_group() will always fail for a named group, because
    internal_create_group() will try to create a new sysfs directory
    unconditionally, which will ofcourse fail with -EEXIST.

    * We can leak the kernfs_node for grp->name if some one tries to:
    - rename a group (change grp->name), or
    - update a named group, to an unnamed group

    It appears that the whole purpose of sysfs_update_group() was to
    allow changing the permissions or visibility of attributes and not
    the names. So make it clear in the comments, and allow it to update
    an existing named group.

    Signed-off-by: Rajat Jain
    Signed-off-by: Greg Kroah-Hartman

    Rajat Jain
     

22 May, 2018

1 commit

  • new_sb is left uninitialized in case of early failures in kernfs_mount_ns(),
    and while IS_ERR(root) is true in all such cases, using IS_ERR(root) || !new_sb
    is not a solution - IS_ERR(root) is true in some cases when new_sb is true.

    Make sure new_sb is initialized (and matches the reality) in all cases and
    fix the condition for dropping kobj reference - we want it done precisely
    in those situations where the reference has not been transferred into a new
    super_block instance.

    Signed-off-by: Al Viro

    Al Viro
     

20 Mar, 2018

1 commit

  • The sysfs_create_link_nowarn() is going to be used in phylib framework in
    subsequent patch which can be built as module. Hence, export
    sysfs_create_link_nowarn() to avoid build errors.

    Cc: Florian Fainelli
    Cc: Andrew Lunn
    Fixes: a3995460491d ("net: phy: Relax error checking on sysfs_create_link()")
    Signed-off-by: Grygorii Strashko
    Acked-by: Greg Kroah-Hartman
    Signed-off-by: David S. Miller

    Grygorii Strashko
     

02 Feb, 2018

1 commit

  • Pull printk updates from Petr Mladek:

    - Add a console_msg_format command line option:

    The value "default" keeps the old "[time stamp] text\n" format. The
    value "syslog" allows to see the syslog-like "[timestamp] text" format.

    This feature was requested by people doing regression tests, for
    example, 0day robot. They want to have both filtered and full logs
    at hands.

    - Reduce the risk of softlockup:

    Pass the console owner in a busy loop.

    This is a new approach to the old problem. It was first proposed by
    Steven Rostedt on Kernel Summit 2017. It marks a context in which
    the console_lock owner calls console drivers and could not sleep.
    On the other side, printk() callers could detect this state and use
    a busy wait instead of a simple console_trylock(). Finally, the
    console_lock owner checks if there is a busy waiter at the end of
    the special context and eventually passes the console_lock to the
    waiter.

    The hand-off works surprisingly well and helps in many situations.
    Well, there is still a possibility of the softlockup, for example,
    when the flood of messages stops and the last owner still has too
    much to flush.

    There is increasing number of people having problems with
    printk-related softlockups. We might eventually need to get better
    solution. Anyway, this looks like a good start and promising
    direction.

    - Do not allow to schedule in console_unlock() called from printk():

    This reverts an older controversial commit. The reschedule helped
    to avoid softlockups. But it also slowed down the console output.
    This patch is obsoleted by the new console waiter logic described
    above. In fact, the reschedule made the hand-off less effective.

    - Deprecate "%pf" and "%pF" format specifier:

    It was needed on ia64, ppc64 and parisc64 to dereference function
    descriptors and show the real function address. It is done
    transparently by "%ps" and "pS" format specifier now.

    Sergey Senozhatsky found that all the function descriptors were in
    a special elf section and could be easily detected.

    - Remove printk_symbol() API:

    It has been obsoleted by "%pS" format specifier, and this change
    helped to remove few continuous lines and a less intuitive old API.

    - Remove redundant memsets:

    Sergey removed unnecessary memset when processing printk.devkmsg
    command line option.

    * 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: (27 commits)
    printk: drop redundant devkmsg_log_str memsets
    printk: Never set console_may_schedule in console_trylock()
    printk: Hide console waiter logic into helpers
    printk: Add console owner and waiter logic to load balance console writes
    kallsyms: remove print_symbol() function
    checkpatch: add pF/pf deprecation warning
    symbol lookup: introduce dereference_symbol_descriptor()
    parisc64: Add .opd based function descriptor dereference
    powerpc64: Add .opd based function descriptor dereference
    ia64: Add .opd based function descriptor dereference
    sections: split dereference_function_descriptor()
    openrisc: Fix conflicting types for _exext and _stext
    lib: do not use print_symbol()
    irq debug: do not use print_symbol()
    sysfs: do not use print_symbol()
    drivers: do not use print_symbol()
    x86: do not use print_symbol()
    unicore32: do not use print_symbol()
    sh: do not use print_symbol()
    mn10300: do not use print_symbol()
    ...

    Linus Torvalds
     

23 Jan, 2018

2 commits

  • It isn't needed at all in these files, dynamic debug is the best way to
    enable this type of thing, if you really want it. As it is, these
    defines were not doing anything at all.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     
  • Move the license "mark" of the sysfs files to be in SPDX form, instead
    of the custom text that it currently is in. This is in a quest to get
    rid of the 700+ different ways we say "GPLv2" in the kernel tree.

    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

22 Jan, 2018

1 commit

  • It's not good to crash the machine if panic_on_warn() is set just
    because someone made a stupid mistake of trying to create a sysfs file
    with the same name of an existing one. This makes the automated testing
    tools a lot harder to find the real bugs in the kernel.

    So just print a warning out and dump the stack to get the attention of
    the developer that they did something foolish. Then keep on trucking,
    as this should not be a fatal error at all.

    Reported-by: Dmitry Vyukov
    Signed-off-by: Greg Kroah-Hartman

    Greg Kroah-Hartman
     

05 Jan, 2018

1 commit

  • print_symbol() is a very old API that has been obsoleted by %pS format
    specifier in a normal printk() call.

    Replace print_symbol() with a direct printk("%pS") call.

    Link: http://lkml.kernel.org/r/20171211125025.2270-11-sergey.senozhatsky@gmail.com
    To: Andrew Morton
    To: Russell King
    To: Catalin Marinas
    To: Mark Salter
    To: Tony Luck
    To: David Howells
    To: Yoshinori Sato
    To: Guan Xuetao
    To: Borislav Petkov
    To: Greg Kroah-Hartman
    To: Thomas Gleixner
    To: Peter Zijlstra
    To: Vineet Gupta
    To: Fengguang Wu
    Cc: Steven Rostedt
    Cc: Petr Mladek
    Cc: LKML
    Cc: linux-arm-kernel@lists.infradead.org
    Cc: linux-c6x-dev@linux-c6x.org
    Cc: linux-ia64@vger.kernel.org
    Cc: linux-am33-list@redhat.com
    Cc: linux-sh@vger.kernel.org
    Cc: linux-edac@vger.kernel.org
    Cc: x86@kernel.org
    Cc: linux-snps-arc@lists.infradead.org
    Signed-off-by: Sergey Senozhatsky
    [pmladek@suse.com: updated commit message]
    Signed-off-by: Petr Mladek

    Sergey Senozhatsky
     

18 Dec, 2017

1 commit

  • Fix ptr_ret.cocci warnings:
    fs/sysfs/group.c:409:8-14: WARNING: PTR_ERR_OR_ZERO can be used

    Use PTR_ERR_OR_ZERO rather than if(IS_ERR(...)) + PTR_ERR

    Generated by: scripts/coccinelle/api/ptr_ret.cocci

    Signed-off-by: Vasyl Gomonovych
    Signed-off-by: Greg Kroah-Hartman

    Vasyl Gomonovych
     

28 Nov, 2017

1 commit

  • This is a pure automated search-and-replace of the internal kernel
    superblock flags.

    The s_flags are now called SB_*, with the names and the values for the
    moment mirroring the MS_* flags that they're equivalent to.

    Note how the MS_xyz flags are the ones passed to the mount system call,
    while the SB_xyz flags are what we then use in sb->s_flags.

    The script to do this was:

    # places to look in; re security/*: it generally should *not* be
    # touched (that stuff parses mount(2) arguments directly), but
    # there are two places where we really deal with superblock flags.
    FILES="drivers/mtd drivers/staging/lustre fs ipc mm \
    include/linux/fs.h include/uapi/linux/bfs_fs.h \
    security/apparmor/apparmorfs.c security/apparmor/include/lib.h"
    # the list of MS_... constants
    SYMS="RDONLY NOSUID NODEV NOEXEC SYNCHRONOUS REMOUNT MANDLOCK \
    DIRSYNC NOATIME NODIRATIME BIND MOVE REC VERBOSE SILENT \
    POSIXACL UNBINDABLE PRIVATE SLAVE SHARED RELATIME KERNMOUNT \
    I_VERSION STRICTATIME LAZYTIME SUBMOUNT NOREMOTELOCK NOSEC BORN \
    ACTIVE NOUSER"

    SED_PROG=
    for i in $SYMS; do SED_PROG="$SED_PROG -e s/MS_$i/SB_$i/g"; done

    # we want files that contain at least one of MS_...,
    # with fs/namespace.c and fs/pnode.c excluded.
    L=$(for i in $SYMS; do git grep -w -l MS_$i $FILES; done| sort|uniq|grep -v '^fs/namespace.c'|grep -v '^fs/pnode.c')

    for f in $L; do sed -i $f $SED_PROG; done

    Requested-by: Al Viro
    Signed-off-by: Linus Torvalds

    Linus Torvalds