kernel/kprobes.c:145: warning: Function parameter or member 'c' not described in '__get_insn_slot'

From: kernel test robot
Date: Sun Mar 31 2024 - 23:09:17 EST


Hi Tiezhu,

First bad commit (maybe != root cause):

tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 39cd87c4eb2b893354f3b850f916353f2658ae6f
commit: 6d4cc40fb5f58147defc6c0e9d86e6232fe31616 LoongArch: Add kprobes support
date: 1 year, 1 month ago
config: loongarch-randconfig-r034-20230511 (https://download.01.org/0day-ci/archive/20240401/202404011027.QGLZE6SP-lkp@xxxxxxxxx/config)
compiler: loongarch64-linux-gcc (GCC) 12.3.0
reproduce: (https://download.01.org/0day-ci/archive/20240401/202404011027.QGLZE6SP-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202404011027.QGLZE6SP-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

>> kernel/kprobes.c:145: warning: Function parameter or member 'c' not described in '__get_insn_slot'


vim +145 kernel/kprobes.c

b4c6c34a530b4d1 Masami Hiramatsu 2006-12-06 139
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 140 /**
129415607845d4d Masami Hiramatsu 2009-01-06 141 * __get_insn_slot() - Find a slot on an executable page for an instruction.
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 142 * We allocate an executable page if there's no room on existing ones.
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 143 */
55479f64756fc50 Masami Hiramatsu 2014-04-17 144 kprobe_opcode_t *__get_insn_slot(struct kprobe_insn_cache *c)
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 @145 {
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 146 struct kprobe_insn_page *kip;
c802d64a356b5cf Heiko Carstens 2013-09-11 147 kprobe_opcode_t *slot = NULL;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 148
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 149 /* Since the slot array is not protected by rcu, we need a mutex */
c802d64a356b5cf Heiko Carstens 2013-09-11 150 mutex_lock(&c->mutex);
b4c6c34a530b4d1 Masami Hiramatsu 2006-12-06 151 retry:
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 152 rcu_read_lock();
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 153 list_for_each_entry_rcu(kip, &c->pages, list) {
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 154 if (kip->nused < slots_per_page(c)) {
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 155 int i;
223a76b268c9cfa Masami Hiramatsu 2021-09-14 156
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 157 for (i = 0; i < slots_per_page(c); i++) {
ab40c5c6b6861ee Masami Hiramatsu 2007-01-30 158 if (kip->slot_used[i] == SLOT_CLEAN) {
ab40c5c6b6861ee Masami Hiramatsu 2007-01-30 159 kip->slot_used[i] = SLOT_USED;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 160 kip->nused++;
c802d64a356b5cf Heiko Carstens 2013-09-11 161 slot = kip->insns + (i * c->insn_size);
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 162 rcu_read_unlock();
c802d64a356b5cf Heiko Carstens 2013-09-11 163 goto out;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 164 }
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 165 }
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 166 /* kip->nused is broken. Fix it. */
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 167 kip->nused = slots_per_page(c);
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 168 WARN_ON(1);
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 169 }
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 170 }
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 171 rcu_read_unlock();
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 172
b4c6c34a530b4d1 Masami Hiramatsu 2006-12-06 173 /* If there are any garbage slots, collect it and try again. */
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 174 if (c->nr_garbage && collect_garbage_slots(c) == 0)
b4c6c34a530b4d1 Masami Hiramatsu 2006-12-06 175 goto retry;
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 176
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 177 /* All out of space. Need to allocate a new page. */
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 178 kip = kmalloc(KPROBE_INSN_PAGE_SIZE(slots_per_page(c)), GFP_KERNEL);
6f716acd5fa20ae Christoph Hellwig 2007-05-08 179 if (!kip)
c802d64a356b5cf Heiko Carstens 2013-09-11 180 goto out;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 181
af96397de860023 Heiko Carstens 2013-09-11 182 kip->insns = c->alloc();
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 183 if (!kip->insns) {
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 184 kfree(kip);
c802d64a356b5cf Heiko Carstens 2013-09-11 185 goto out;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 186 }
c5cb5a2d8d7dc87 Masami Hiramatsu 2009-06-30 187 INIT_LIST_HEAD(&kip->list);
4610ee1d3638fa0 Masami Hiramatsu 2010-02-25 188 memset(kip->slot_used, SLOT_CLEAN, slots_per_page(c));
ab40c5c6b6861ee Masami Hiramatsu 2007-01-30 189 kip->slot_used[0] = SLOT_USED;
9ec4b1f356b3bad Ananth N Mavinakayanahalli 2005-06-27 190 kip->nused = 1;
b4c6c34a530b4d1 Masami Hiramatsu 2006-12-06 191 kip->ngarbage = 0;
af96397de860023 Heiko Carstens 2013-09-11 192 kip->cache = c;
5b485629ba0d5d0 Masami Hiramatsu 2017-01-08 193 list_add_rcu(&kip->list, &c->pages);
c802d64a356b5cf Heiko Carstens 2013-09-11 194 slot = kip->insns;
69e49088692899d Adrian Hunter 2020-05-12 195
69e49088692899d Adrian Hunter 2020-05-12 196 /* Record the perf ksymbol register event after adding the page */
69e49088692899d Adrian Hunter 2020-05-12 197 perf_event_ksymbol(PERF_RECORD_KSYMBOL_TYPE_OOL, (unsigned long)kip->insns,
69e49088692899d Adrian Hunter 2020-05-12 198 PAGE_SIZE, false, c->sym);
c802d64a356b5cf Heiko Carstens 2013-09-11 199 out:
c802d64a356b5cf Heiko Carstens 2013-09-11 200 mutex_unlock(&c->mutex);
c802d64a356b5cf Heiko Carstens 2013-09-11 201 return slot;
129415607845d4d Masami Hiramatsu 2009-01-06 202 }
129415607845d4d Masami Hiramatsu 2009-01-06 203

:::::: The code at line 145 was first introduced by commit
:::::: 9ec4b1f356b3bad928ae8e2aa9caebfa737d52df [PATCH] kprobes: fix single-step out of line - take2

:::::: TO: Ananth N Mavinakayanahalli <ananth@xxxxxxxxxx>
:::::: CC: Linus Torvalds <torvalds@xxxxxxxxxxxxxxx>

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki