1. 31 Aug, 2022 6 commits
    • Christian Brauner's avatar
      xattr: constify value argument in vfs_setxattr() · 6344e669
      Christian Brauner authored
      Now that we don't perform translations directly in vfs_setxattr()
      anymore we can constify the @value argument in vfs_setxattr(). This also
      allows us to remove the hack to cast from a const in ovl_do_setxattr().
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Reviewed-by: default avatarSeth Forshee (DigitalOcean) <sforshee@kernel.org>
      6344e669
    • Christian Brauner's avatar
      ovl: use vfs_set_acl_prepare() · 7e1401ac
      Christian Brauner authored
      The posix_acl_from_xattr() helper should mainly be used in
      i_op->get_acl() handlers. It translates from the uapi struct into the
      kernel internal POSIX ACL representation and doesn't care about mount
      idmappings.
      
      Use the vfs_set_acl_prepare() helper to generate a kernel internal POSIX
      ACL representation in struct posix_acl format taking care to map from
      the mount idmapping into the filesystem's idmapping.
      
      The returned struct posix_acl is in the correct format to be cached by
      the VFS or passed to the filesystem's i_op->set_acl() method to write to
      the backing store.
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Reviewed-by: default avatarSeth Forshee (DigitalOcean) <sforshee@kernel.org>
      7e1401ac
    • Christian Brauner's avatar
      acl: move idmapping handling into posix_acl_xattr_set() · 52edb408
      Christian Brauner authored
      The uapi POSIX ACL struct passed through the value argument during
      setxattr() contains {g,u}id values encoded via ACL_{GROUP,USER} entries
      that should actually be stored in the form of k{g,u}id_t (See [1] for a
      long explanation of the issue.).
      
      In 0c5fd887 ("acl: move idmapped mount fixup into vfs_{g,s}etxattr()")
      we took the mount's idmapping into account in order to let overlayfs
      handle POSIX ACLs on idmapped layers correctly. The fixup is currently
      performed directly in vfs_setxattr() which piles on top of the earlier
      hackiness by handling the mount's idmapping and stuff the vfs{g,u}id_t
      values into the uapi struct as well. While that is all correct and works
      fine it's just ugly.
      
      Now that we have introduced vfs_make_posix_acl() earlier move handling
      idmapped mounts out of vfs_setxattr() and into the POSIX ACL handler
      where it belongs.
      
      Note that we also need to call vfs_make_posix_acl() for EVM which
      interpretes POSIX ACLs during security_inode_setxattr(). Leave them a
      longer comment for future reference.
      
      All filesystems that support idmapped mounts via FS_ALLOW_IDMAP use the
      standard POSIX ACL xattr handlers and are covered by this change. This
      includes overlayfs which simply calls vfs_{g,s}etxattr().
      
      The following filesystems use custom POSIX ACL xattr handlers: 9p, cifs,
      ecryptfs, and ntfs3 (and overlayfs but we've covered that in the paragraph
      above) and none of them support idmapped mounts yet.
      
      Link: https://lore.kernel.org/all/20220801145520.1532837-1-brauner@kernel.org/ [1]
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Reviewed-by: default avatarSeth Forshee (DigitalOcean) <sforshee@kernel.org>
      52edb408
    • Christian Brauner's avatar
      acl: add vfs_set_acl_prepare() · 6b70fe06
      Christian Brauner authored
      Various filesystems store POSIX ACLs on the backing store in their uapi
      format. Such filesystems need to translate from the uapi POSIX ACL
      format into the VFS format during i_op->get_acl(). The VFS provides the
      posix_acl_from_xattr() helper for this task.
      
      But the usage of posix_acl_from_xattr() is currently ambiguous. It is
      intended to transform from a uapi POSIX ACL  to the VFS represenation.
      For example, when retrieving POSIX ACLs for permission checking during
      lookup or when calling getxattr() to retrieve system.posix_acl_{access,default}.
      
      Calling posix_acl_from_xattr() during i_op->get_acl() will map the raw
      {g,u}id values stored as ACL_{GROUP,USER} entries in the uapi POSIX ACL
      format into k{g,u}id_t in the filesystem's idmapping and return a struct
      posix_acl ready to be returned to the VFS for caching and to perform
      permission checks on.
      
      However, posix_acl_from_xattr() is also called during setxattr() for all
      filesystems that rely on VFS provides posix_acl_{access,default}_xattr_handler.
      The posix_acl_xattr_set() handler which is used for the ->set() method
      of posix_acl_{access,default}_xattr_handler uses posix_acl_from_xattr()
      to translate from the uapi POSIX ACL format to the VFS format so that it
      can be passed to the i_op->set_acl() handler of the filesystem or for
      direct caching in case no i_op->set_acl() handler is defined.
      
      During setxattr() the {g,u}id values stored as ACL_{GROUP,USER} entries
      in the uapi POSIX ACL format aren't raw {g,u}id values that need to be
      mapped according to the filesystem's idmapping. Instead they are {g,u}id
      values in the caller's idmapping which have been generated during
      posix_acl_fix_xattr_from_user(). In other words, they are k{g,u}id_t
      which are passed as raw {g,u}id values abusing the uapi POSIX ACL format
      (Please note that this type safety violation has existed since the
      introduction of k{g,u}id_t. Please see [1] for more details.).
      
      So when posix_acl_from_xattr() is called in posix_acl_xattr_set() the
      filesystem idmapping is completely irrelevant. Instead, we abuse the
      initial idmapping to recover the k{g,u}id_t base on the value stored in
      raw {g,u}id as ACL_{GROUP,USER} in the uapi POSIX ACL format.
      
      We need to clearly distinguish betweeen these two operations as it is
      really easy to confuse for filesystems as can be seen in ntfs3.
      
      In order to do this we factor out make_posix_acl() which takes callbacks
      allowing callers to pass dedicated methods to generate the correct
      k{g,u}id_t. This is just an internal static helper which is not exposed
      to any filesystems but it neatly encapsulates the basic logic of walking
      through a uapi POSIX ACL and returning an allocated VFS POSIX ACL with
      the correct k{g,u}id_t values.
      
      The posix_acl_from_xattr() helper can then be implemented as a simple
      call to make_posix_acl() with callbacks that generate the correct
      k{g,u}id_t from the raw {g,u}id values in ACL_{GROUP,USER} entries in
      the uapi POSIX ACL format as read from the backing store.
      
      For setxattr() we add a new helper vfs_set_acl_prepare() which has
      callbacks to map the POSIX ACLs from the uapi format with the k{g,u}id_t
      values stored in raw {g,u}id format in ACL_{GROUP,USER} entries into the
      correct k{g,u}id_t values in the filesystem idmapping. In contrast to
      posix_acl_from_xattr() the vfs_set_acl_prepare() helper needs to take
      the mount idmapping into account. The differences are explained in more
      detail in the kernel doc for the new functions.
      
      In follow up patches we will remove all abuses of posix_acl_from_xattr()
      for setxattr() operations and replace it with calls to vfs_set_acl_prepare().
      
      The new vfs_set_acl_prepare() helper allows us to deal with the
      ambiguity in how the POSI ACL uapi struct stores {g,u}id values
      depending on whether this is a getxattr() or setxattr() operation.
      
      This also allows us to remove the posix_acl_setxattr_idmapped_mnt()
      helper reducing the abuse of the POSIX ACL uapi format to pass values
      that should be distinct types in {g,u}id values stored as
      ACL_{GROUP,USER} entries.
      
      The removal of posix_acl_setxattr_idmapped_mnt() in turn allows us to
      re-constify the value parameter of vfs_setxattr() which in turn allows
      us to avoid the nasty cast from a const void pointer to a non-const void
      pointer on ovl_do_setxattr().
      
      Ultimately, the plan is to get rid of the type violations completely and
      never pass the values from k{g,u}id_t as raw {g,u}id in ACL_{GROUP,USER}
      entries in uapi POSIX ACL format. But that's a longer way to go and this
      is a preparatory step.
      
      Link: https://lore.kernel.org/all/20220801145520.1532837-1-brauner@kernel.org [1]
      Co-Developed-by: default avatarSeth Forshee <sforshee@digitalocean.com>
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      6b70fe06
    • Christian Brauner's avatar
      acl: return EOPNOTSUPP in posix_acl_fix_xattr_common() · 985a6d0b
      Christian Brauner authored
      Return EOPNOTSUPP when the POSIX ACL version doesn't match and zero if
      there are no entries. This will allow us to reuse the helper in
      posix_acl_from_xattr(). This change will have no user visible effects.
      
      Fixes: 0c5fd887 ("acl: move idmapped mount fixup into vfs_{g,s}etxattr()")
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Reviewed-by: default avatarSeth Forshee (DigitalOcean) <sforshee@kernel.org&gt;>
      985a6d0b
    • Christian Brauner's avatar
      ntfs3: rework xattr handlers and switch to POSIX ACL VFS helpers · a26aa123
      Christian Brauner authored
      The xattr code in ntfs3 is currently a bit confused. For example, it
      defines a POSIX ACL i_op->set_acl() method but instead of relying on the
      generic POSIX ACL VFS helpers it defines its own set of xattr helpers
      with the consequence that i_op->set_acl() is currently dead code.
      
      Switch ntfs3 to rely on the VFS POSIX ACL xattr handlers. Also remove
      i_op->{g,s}et_acl() methods from symlink inode operations. Symlinks
      don't support xattrs.
      
      This is a preliminary change for the following patches which move
      handling idmapped mounts directly in posix_acl_xattr_set().
      
      This survives POSIX ACL xfstests.
      
      Fixes: be71b5cb ("fs/ntfs3: Add attrib operations")
      Signed-off-by: default avatarChristian Brauner (Microsoft) <brauner@kernel.org>
      Reviewed-by: default avatarSeth Forshee (DigitalOcean) <sforshee@kernel.org&gt;>
      a26aa123
  2. 28 Aug, 2022 25 commits
  3. 27 Aug, 2022 9 commits
    • Linus Torvalds's avatar
      Merge tag 'thermal-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 10d4879f
      Linus Torvalds authored
      Pull thermal control fixes from Rafael Wysocki:
       "Fix two issues introduced recently and one driver problem leading to a
        NULL pointer dereference in some cases.
      
        Specifics:
      
         - Add missing EXPORT_SYMBOL_GPL in the thermal core and add back the
           required 'trips' property to the thermal zone DT bindings (Daniel
           Lezcano)
      
         - Prevent the int340x_thermal driver from crashing when a package
           with a buffer of 0 length is returned by an ACPI control method
           evaluated by it (Lee, Chun-Yi)"
      
      * tag 'thermal-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        thermal/int340x_thermal: handle data_vault when the value is ZERO_SIZE_PTR
        dt-bindings: thermal: Fix missing required property
        thermal/core: Add missing EXPORT_SYMBOL_GPL
      10d4879f
    • Linus Torvalds's avatar
      Merge tag 'pm-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · b98f602d
      Linus Torvalds authored
      Pull power management fix from Rafael Wysocki:
       "Make __resolve_freq() check the presence of the frequency table
        instead of checking whether or not the ->target_index() callback is
        implemented by the driver, because that need not be the case when
        __resolve_freq() is used (Lukasz Luba)"
      
      * tag 'pm-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        cpufreq: check only freq_table in __resolve_freq()
      b98f602d
    • Linus Torvalds's avatar
      Merge tag 'acpi-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm · 2b1ddb59
      Linus Torvalds authored
      Pull ACPI fixes from Rafael Wysocki:
       "These fix issues introduced by recent changes related to the handling
        of ACPI device properties and a coding mistake in the exit path of the
        ACPI processor driver.
      
        Specifics:
      
         - Prevent acpi_thermal_cpufreq_exit() from attempting to remove
           the same frequency QoS request multiple times (Riwen Lu)
      
         - Fix type detection for integer ACPI device properties (Stefan
           Binding)
      
         - Avoid emitting false-positive warnings when processing ACPI
           device properties and drop the useless default case from the
           acpi_copy_property_array_uint() macro (Sakari Ailus)"
      
      * tag 'acpi-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
        ACPI: property: Remove default association from integer maximum values
        ACPI: property: Ignore already existing data node tags
        ACPI: property: Fix type detection of unified integer reading functions
        ACPI: processor: Remove freq Qos request for all CPUs
      2b1ddb59
    • Linus Torvalds's avatar
      Merge tag 's390-6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux · dee18737
      Linus Torvalds authored
      Pull s390 fixes from Vasily Gorbik:
      
       - Fix double free of guarded storage and runtime instrumentation
         control blocks on fork() failure
      
       - Fix triggering write fault when VMA does not allow VM_WRITE
      
      * tag 's390-6.0-2' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
        s390/mm: do not trigger write fault when vma does not allow VM_WRITE
        s390: fix double free of GS and RI CBs on fork() failure
      dee18737
    • Linus Torvalds's avatar
      Merge tag 'for-linus-6.0-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip · 05519f24
      Linus Torvalds authored
      Pull xen fixes from Juergen Gross:
      
       - two minor cleanups
      
       - a fix of the xen/privcmd driver avoiding a possible NULL dereference
         in an error case
      
      * tag 'for-linus-6.0-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/xen/tip:
        xen/privcmd: fix error exit of privcmd_ioctl_dm_op()
        xen: move from strlcpy with unused retval to strscpy
        xen: x86: remove setting the obsolete config XEN_MAX_DOMAIN_MEMORY
      05519f24
    • Linus Torvalds's avatar
      Merge tag 'audit-pr-20220826' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit · 17b28d42
      Linus Torvalds authored
      Pull audit fix from Paul Moore:
       "Another small audit patch, this time to fix a bug where the return
        codes were not properly set before the audit filters were run,
        potentially resulting in missed audit records"
      
      * tag 'audit-pr-20220826' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/audit:
        audit: move audit_return_fixup before the filters
      17b28d42
    • Linus Torvalds's avatar
      Merge tag 'fbdev-for-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev · 89b749d8
      Linus Torvalds authored
      Pull fbdev fixes and updates from Helge Deller:
       "Mostly just small patches, with the exception of the bigger indenting
        cleanups in the sisfb and radeonfb drivers.
      
        Two patches should be mentioned though: A fix-up for fbdev if the
        screen resize fails (by Shigeru Yoshida), and a potential divide by
        zero fix in fb_pm2fb (by Letu Ren).
      
        Summary:
      
        Major fixes:
         - Revert the changes for fbcon console when vc_resize() fails
           [Shigeru Yoshida]
         - Avoid a potential divide by zero error in fb_pm2fb [Letu Ren]
      
        Minor fixes:
         - Add missing pci_disable_device() in chipsfb_pci_init() [Yang
           Yingliang]
         - Fix tests for platform_get_irq() failure in omapfb [Yu Zhe]
         - Destroy mutex on freeing struct fb_info in fbsysfs [Shigeru
           Yoshida]
      
        Cleanups:
         - Move fbdev drivers from strlcpy to strscpy [Wolfram Sang]
         - Indenting fixes, comment fixes, ... [Jiapeng Chong & Jilin Yuan]"
      
      * tag 'fbdev-for-6.0-rc3' of git://git.kernel.org/pub/scm/linux/kernel/git/deller/linux-fbdev:
        fbdev: fbcon: Properly revert changes when vc_resize() failed
        fbdev: Move fbdev drivers from strlcpy to strscpy
        fbdev: omap: Remove unnecessary print function dev_err()
        fbdev: chipsfb: Add missing pci_disable_device() in chipsfb_pci_init()
        fbdev: fbcon: Destroy mutex on freeing struct fb_info
        fbdev: radeon: Clean up some inconsistent indenting
        fbdev: sisfb: Clean up some inconsistent indenting
        fbdev: fb_pm2fb: Avoid potential divide by zero error
        fbdev: ssd1307fb: Fix repeated words in comments
        fbdev: omapfb: Fix tests for platform_get_irq() failure
      89b749d8
    • Mikulas Patocka's avatar
      provide arch_test_bit_acquire for architectures that define test_bit · d6ffe606
      Mikulas Patocka authored
      Some architectures define their own arch_test_bit and they also need
      arch_test_bit_acquire, otherwise they won't compile.  We also clean up
      the code by using the generic test_bit if that is equivalent to the
      arch-specific version.
      Signed-off-by: default avatarMikulas Patocka <mpatocka@redhat.com>
      Cc: stable@vger.kernel.org
      Fixes: 8238b457 ("wait_on_bit: add an acquire memory barrier")
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      d6ffe606
    • Zhengjun Xing's avatar
      perf stat: Capitalize topdown metrics' names · 48648548
      Zhengjun Xing authored
      Capitalize topdown metrics' names to follow the intel SDM.
      
      Before:
      
       # ./perf stat -a  sleep 1
      
       Performance counter stats for 'system wide':
      
              228,094.05 msec cpu-clock                        #  225.026 CPUs utilized
                     842      context-switches                 #    3.691 /sec
                     224      cpu-migrations                   #    0.982 /sec
                      70      page-faults                      #    0.307 /sec
              23,164,105      cycles                           #    0.000 GHz
              29,403,446      instructions                     #    1.27  insn per cycle
               5,268,185      branches                         #   23.097 K/sec
                  33,239      branch-misses                    #    0.63% of all branches
             136,248,990      slots                            #  597.337 K/sec
              32,976,450      topdown-retiring                 #     24.2% retiring
               4,651,918      topdown-bad-spec                 #      3.4% bad speculation
              26,148,695      topdown-fe-bound                 #     19.2% frontend bound
              72,515,776      topdown-be-bound                 #     53.2% backend bound
               6,008,540      topdown-heavy-ops                #      4.4% heavy operations       #     19.8% light operations
               3,934,049      topdown-br-mispredict            #      2.9% branch mispredict      #      0.5% machine clears
              16,655,439      topdown-fetch-lat                #     12.2% fetch latency          #      7.0% fetch bandwidth
              41,635,972      topdown-mem-bound                #     30.5% memory bound           #     22.7% Core bound
      
             1.013634593 seconds time elapsed
      
      After:
      
       # ./perf stat -a  sleep 1
      
       Performance counter stats for 'system wide':
      
              228,081.94 msec cpu-clock                        #  225.003 CPUs utilized
                     824      context-switches                 #    3.613 /sec
                     224      cpu-migrations                   #    0.982 /sec
                      67      page-faults                      #    0.294 /sec
              22,647,423      cycles                           #    0.000 GHz
              28,870,551      instructions                     #    1.27  insn per cycle
               5,167,099      branches                         #   22.655 K/sec
                  32,383      branch-misses                    #    0.63% of all branches
             133,411,074      slots                            #  584.926 K/sec
              32,352,607      topdown-retiring                 #     24.3% Retiring
               4,456,977      topdown-bad-spec                 #      3.3% Bad Speculation
              25,626,487      topdown-fe-bound                 #     19.2% Frontend Bound
              70,955,316      topdown-be-bound                 #     53.2% Backend Bound
               5,834,844      topdown-heavy-ops                #      4.4% Heavy Operations       #     19.9% Light Operations
               3,738,781      topdown-br-mispredict            #      2.8% Branch Mispredict      #      0.5% Machine Clears
              16,286,803      topdown-fetch-lat                #     12.2% Fetch Latency          #      7.0% Fetch Bandwidth
              40,802,069      topdown-mem-bound                #     30.6% Memory Bound           #     22.6% Core Bound
      
             1.013683125 seconds time elapsed
      Reviewed-by: default avatarKan Liang <kan.liang@linux.intel.com>
      Signed-off-by: default avatarXing Zhengjun <zhengjun.xing@linux.intel.com>
      Acked-by: default avatarIan Rogers <irogers@google.com>
      Cc: Alexander Shishkin <alexander.shishkin@intel.com>
      Cc: Andi Kleen <ak@linux.intel.com>
      Cc: Ingo Molnar <mingo@redhat.com>
      Cc: Jiri Olsa <jolsa@kernel.org>
      Cc: Namhyung Kim <namhyung@kernel.org>
      Cc: Peter Zijlstra <peterz@infradead.org>
      Link: https://lore.kernel.org/r/20220825015458.3252239-1-zhengjun.xing@linux.intel.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
      48648548