linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Qian Cai <quic_qiancai@quicinc.com>
To: "Eric W. Biederman" <ebiederm@xmission.com>,
	Alexey Gladkov <legion@kernel.org>
Cc: Yu Zhao <yuzhao@google.com>, <linux-kernel@vger.kernel.org>
Subject: BUG: KASAN: use-after-free in dec_rlimit_ucounts
Date: Wed, 17 Nov 2021 17:00:07 -0500	[thread overview]
Message-ID: <YZV7Z+yXbsx9p3JN@fixkernel.com> (raw)

Hi there, I can still reproduce this quickly on today's linux-next and all
the way back to 5.15-rc6 by running a syscall fuzzer for a while. The trace
points out to this line,

        for (iter = ucounts; iter; iter = iter->ns->ucounts) {

It looks KASAN indicated that that "ns" had already been freed. Is that
possible or perhaps this is more of refcount issue? 

 BUG: KASAN: use-after-free in dec_rlimit_ucounts
 Read of size 8 at addr ffff0008c0739860 by task trinity-c27/10924

 CPU: 27 PID: 10924 Comm: trinity-c27 Not tainted 5.15.0-next-20211115-dirty #192
 Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
 Call trace:
  dump_backtrace
  show_stack
  dump_stack_lvl
  print_address_description.constprop.0
  kasan_report
  __asan_report_load8_noabort
  dec_rlimit_ucounts
  dec_rlimit_ucounts at kernel/ucount.c:284
  mqueue_evict_inode
  mqueue_evict_inode at ipc/mqueue.c:544
  evict
  iput.part.0
  iput
  __arm64_sys_mq_unlink
  invoke_syscall
  el0_svc_common.constprop.0
  do_el0_svc
  el0_svc
  el0t_64_sync_handler
  el0t_64_sync

 Allocated by task 10615:
  kasan_save_stack
  __kasan_slab_alloc
  slab_post_alloc_hook
  kmem_cache_alloc
  create_user_ns
  unshare_userns
  ksys_unshare
  __arm64_sys_unshare
  invoke_syscall
  el0_svc_common.constprop.0
  do_el0_svc
  el0_svc
  el0t_64_sync_handler
  el0t_64_sync

 Freed by task 8660:
  kasan_save_stack
  kasan_set_track
  kasan_set_free_info
  __kasan_slab_free
  slab_free_freelist_hook
  kmem_cache_free
  free_user_ns
  process_one_work
  worker_thread
  kthread
  ret_from_fork

 Last potentially related work creation:
  kasan_save_stack
  __kasan_record_aux_stack
  kasan_record_aux_stack_noalloc
  insert_work
  __queue_work
  queue_work_on
  __put_user_ns
  put_cred_rcu
  rcu_do_batch
  rcu_core
  rcu_core_si
  __do_softirq

 The buggy address belongs to the object at ffff0008c07395e8
  which belongs to the cache user_namespace of size 768
 The buggy address is located 632 bytes inside of
  768-byte region [ffff0008c07395e8, ffff0008c07398e8)
 The buggy address belongs to the page:
 page:fffffc002301ce00 refcount:1 mapcount:0 mapping:0000000000000000 index:0xffff0008c073cec8 pfn:0x940738
 head:fffffc002301ce00 order:3 compound_mapcount:0 compound_pincount:0
 memcg:ffff0008b9b5f101
 flags: 0xbfffc0000010200(slab|head|node=0|zone=2|lastcpupid=0xffff)
 raw: 0bfffc0000010200 ffff000800f3e9c8 ffff000800f3e9c8 ffff000802e69b80
 raw: ffff0008c073cec8 00000000001d0012 00000001ffffffff ffff0008b9b5f101
 page dumped because: kasan: bad access detected

 Memory state around the buggy address:
  ffff0008c0739700: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
  ffff0008c0739780: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
 >ffff0008c0739800: fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb fb
                                                        ^
  ffff0008c0739880: fb fb fb fb fb fb fb fb fb fb fb fb fb fc fc fc
  ffff0008c0739900: fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc fc

             reply	other threads:[~2021-11-17 22:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-17 22:00 Qian Cai [this message]
2021-11-18 19:46 ` BUG: KASAN: use-after-free in dec_rlimit_ucounts Eric W. Biederman
2021-11-18 20:32   ` Qian Cai
2021-11-18 20:57     ` Eric W. Biederman
2021-11-19 13:32       ` Qian Cai
2021-11-24 21:49       ` Qian Cai
2021-11-26  5:34         ` Qian Cai
2021-12-20  5:58           ` Eric W. Biederman
2021-12-21 13:09             ` Alexey Gladkov
2021-12-27 15:22               ` Eric W. Biederman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YZV7Z+yXbsx9p3JN@fixkernel.com \
    --to=quic_qiancai@quicinc.com \
    --cc=ebiederm@xmission.com \
    --cc=legion@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=yuzhao@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).