Forum | Documentation | Website | Blog

Skip to content
Snippets Groups Projects
  1. Apr 05, 2024
  2. Jan 22, 2024
    • Nikita Zhandarovich's avatar
      do_sys_name_to_handle(): use kzalloc() to fix kernel-infoleak · 3948abaa
      Nikita Zhandarovich authored
      syzbot identified a kernel information leak vulnerability in
      do_sys_name_to_handle() and issued the following report [1].
      
      [1]
      "BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
      BUG: KMSAN: kernel-infoleak in _copy_to_user+0xbc/0x100 lib/usercopy.c:40
       instrument_copy_to_user include/linux/instrumented.h:114 [inline]
       _copy_to_user+0xbc/0x100 lib/usercopy.c:40
       copy_to_user include/linux/uaccess.h:191 [inline]
       do_sys_name_to_handle fs/fhandle.c:73 [inline]
       __do_sys_name_to_handle_at fs/fhandle.c:112 [inline]
       __se_sys_name_to_handle_at+0x949/0xb10 fs/fhandle.c:94
       __x64_sys_name_to_handle_at+0xe4/0x140 fs/fhandle.c:94
       ...
      
      Uninit was created at:
       slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
       slab_alloc_node mm/slub.c:3478 [inline]
       __kmem_cache_alloc_node+0x5c9/0x970 mm/slub.c:3517
       __do_kmalloc_node mm/slab_common.c:1006 [inline]
       __kmalloc+0x121/0x3c0 mm/slab_common.c:1020
       kmalloc include/linux/slab.h:604 [inline]
       do_sys_name_to_handle fs/fhandle.c:39 [inline]
       __do_sys_name_to_handle_at fs/fhandle.c:112 [inline]
       __se_sys_name_to_handle_at+0x441/0xb10 fs/fhandle.c:94
       __x64_sys_name_to_handle_at+0xe4/0x140 fs/fhandle.c:94
       ...
      
      Bytes 18-19 of 20 are uninitialized
      Memory access of size 20 starts at ffff888128a46380
      Data copied to user address 0000000020000240"
      
      Per Chuck Lever's suggestion, use kzalloc() instead of kmalloc() to
      solve the problem.
      
      Fixes: 990d6c2d
      
       ("vfs: Add name to file handle conversion support")
      Suggested-by: default avatarChuck Lever III <chuck.lever@oracle.com>
      Reported-and-tested-by: default avatar <syzbot+09b349b3066c2e0b1e96@syzkaller.appspotmail.com>
      Signed-off-by: default avatarNikita Zhandarovich <n.zhandarovich@fintech.ru>
      Link: https://lore.kernel.org/r/20240119153906.4367-1-n.zhandarovich@fintech.ru
      
      
      Reviewed-by: default avatarJan Kara <jack@suse.cz>
      Signed-off-by: default avatarChristian Brauner <brauner@kernel.org>
      3948abaa
  3. Oct 24, 2023
  4. Jun 12, 2023
    • Amir Goldstein's avatar
      fsnotify: move fsnotify_open() hook into do_dentry_open() · 7b8c9d7b
      Amir Goldstein authored
      
      fsnotify_open() hook is called only from high level system calls
      context and not called for the very many helpers to open files.
      
      This may makes sense for many of the special file open cases, but it is
      inconsistent with fsnotify_close() hook that is called for every last
      fput() of on a file object with FMODE_OPENED.
      
      As a result, it is possible to observe ACCESS, MODIFY and CLOSE events
      without ever observing an OPEN event.
      
      Fix this inconsistency by replacing all the fsnotify_open() hooks with
      a single hook inside do_dentry_open().
      
      If there are special cases that would like to opt-out of the possible
      overhead of fsnotify() call in fsnotify_open(), they would probably also
      want to avoid the overhead of fsnotify() call in the rest of the fsnotify
      hooks, so they should be opening that file with the __FMODE_NONOTIFY flag.
      
      However, in the majority of those cases, the s_fsnotify_connectors
      optimization in fsnotify_parent() would be sufficient to avoid the
      overhead of fsnotify() call anyway.
      
      Signed-off-by: default avatarAmir Goldstein <amir73il@gmail.com>
      Signed-off-by: default avatarJan Kara <jack@suse.cz>
      Message-Id: <20230611122429.1499617-1-amir73il@gmail.com>
      7b8c9d7b
  5. May 25, 2023
  6. Sep 01, 2022
  7. Apr 07, 2021
  8. Feb 24, 2021
  9. Aug 07, 2019
  10. Jan 15, 2018
    • David Windsor's avatar
      vfs: Copy struct mount.mnt_id to userspace using put_user() · 6391af6f
      David Windsor authored
      
      The mnt_id field can be copied with put_user(), so there is no need to
      use copy_to_user(). In both cases, hardened usercopy is being bypassed
      since the size is constant, and not open to runtime manipulation.
      
      This patch is verbatim from Brad Spengler/PaX Team's PAX_USERCOPY
      whitelisting code in the last public patch of grsecurity/PaX based on my
      understanding of the code. Changes or omissions from the original code are
      mine and don't reflect the original grsecurity/PaX code.
      
      Signed-off-by: default avatarDavid Windsor <dave@nullcore.net>
      [kees: adjust commit log]
      Cc: Alexander Viro <viro@zeniv.linux.org.uk>
      Cc: linux-fsdevel@vger.kernel.org
      Signed-off-by: default avatarKees Cook <keescook@chromium.org>
      6391af6f
  11. Nov 02, 2017
    • Greg Kroah-Hartman's avatar
      License cleanup: add SPDX GPL-2.0 license identifier to files with no license · b2441318
      Greg Kroah-Hartman authored
      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...
      b2441318
  12. Oct 14, 2017
  13. Apr 17, 2017
  14. Dec 24, 2016
  15. Mar 22, 2016
    • Jann Horn's avatar
      fs/coredump: prevent fsuid=0 dumps into user-controlled directories · 378c6520
      Jann Horn authored
      
      This commit fixes the following security hole affecting systems where
      all of the following conditions are fulfilled:
      
       - The fs.suid_dumpable sysctl is set to 2.
       - The kernel.core_pattern sysctl's value starts with "/". (Systems
         where kernel.core_pattern starts with "|/" are not affected.)
       - Unprivileged user namespace creation is permitted. (This is
         true on Linux >=3.8, but some distributions disallow it by
         default using a distro patch.)
      
      Under these conditions, if a program executes under secure exec rules,
      causing it to run with the SUID_DUMP_ROOT flag, then unshares its user
      namespace, changes its root directory and crashes, the coredump will be
      written using fsuid=0 and a path derived from kernel.core_pattern - but
      this path is interpreted relative to the root directory of the process,
      allowing the attacker to control where a coredump will be written with
      root privileges.
      
      To fix the security issue, always interpret core_pattern for dumps that
      are written under SUID_DUMP_ROOT relative to the root directory of init.
      
      Signed-off-by: default avatarJann Horn <jann@thejh.net>
      Acked-by: default avatarKees Cook <keescook@chromium.org>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: "Eric W. Biederman" <ebiederm@xmission.com>
      Cc: Andy Lutomirski <luto@kernel.org>
      Cc: Oleg Nesterov <oleg@redhat.com>
      Cc: <stable@vger.kernel.org>
      Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      378c6520
  16. Jun 02, 2015
    • Sasha Levin's avatar
      vfs: read file_handle only once in handle_to_path · 161f873b
      Sasha Levin authored
      
      We used to read file_handle twice.  Once to get the amount of extra
      bytes, and once to fetch the entire structure.
      
      This may be problematic since we do size verifications only after the
      first read, so if the number of extra bytes changes in userspace between
      the first and second calls, we'll have an incoherent view of
      file_handle.
      
      Instead, read the constant size once, and copy that over to the final
      structure without having to re-read it again.
      
      Signed-off-by: default avatarSasha Levin <sasha.levin@oracle.com>
      Cc: Al Viro <viro@zeniv.linux.org.uk>
      Cc: stable@vger.kernel.org
      Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
      161f873b
  17. Nov 19, 2012
  18. Nov 07, 2012
  19. Sep 26, 2012
  20. Jan 06, 2012
  21. Jan 03, 2012
  22. Apr 14, 2011
  23. Mar 15, 2011