From: Dan Carpenter <dan.carpenter@linaro.org>
To: oe-kbuild@lists.linux.dev,
Siddharth Chintamaneni <sidchintamaneni@gmail.com>,
bpf@vger.kernel.org
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
alexei.starovoitov@gmail.com, daniel@iogearbox.net,
olsajiri@gmail.com, andrii@kernel.org, yonghong.song@linux.dev,
rjsu26@vt.edu, sairoop@vt.edu,
Siddharth Chintamaneni <sidchintamaneni@vt.edu>,
syzbot+8bdfc2c53fb2b63e1871@syzkaller.appspotmail.com
Subject: Re: [PATCH bpf-next 1/2] Patch to Fix deadlocks in queue and stack maps
Date: Sat, 4 May 2024 15:22:21 +0300 [thread overview]
Message-ID: <e5286af1-53cb-40f1-a0c9-601e2a368114@moroto.mountain> (raw)
In-Reply-To: <20240429165658.1305969-1-sidchintamaneni@gmail.com>
Hi Siddharth,
kernel test robot noticed the following build warnings:
url: https://github.com/intel-lab-lkp/linux/commits/Siddharth-Chintamaneni/Added-selftests-to-check-deadlocks-in-queue-and-stack-map/20240430-142201
base: https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git master
patch link: https://lore.kernel.org/r/20240429165658.1305969-1-sidchintamaneni%40gmail.com
patch subject: [PATCH bpf-next 1/2] Patch to Fix deadlocks in queue and stack maps
config: i386-randconfig-141-20240504 (https://download.01.org/0day-ci/archive/20240504/202405041108.2Up5HT0H-lkp@intel.com/config)
compiler: clang version 18.1.4 (https://github.com/llvm/llvm-project e6c3289804a67ea0bb6a86fadbe454dd93b8d855)
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@intel.com>
| Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
| Closes: https://lore.kernel.org/r/202405041108.2Up5HT0H-lkp@intel.com/
smatch warnings:
kernel/bpf/queue_stack_maps.c:273 queue_stack_map_push_elem() warn: inconsistent returns 'irq_flags'.
vim +/irq_flags +273 kernel/bpf/queue_stack_maps.c
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 219
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 220 /* Called from syscall or from eBPF program */
d7ba4cc900bf1e JP Kobryn 2023-03-22 221 static long queue_stack_map_push_elem(struct bpf_map *map, void *value,
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 222 u64 flags)
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 223 {
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 224 struct bpf_queue_stack *qs = bpf_queue_stack(map);
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 225 unsigned long irq_flags;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 226 int err = 0;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 227 void *dst;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 228
568ce03b978beb Siddharth Chintamaneni 2024-04-29 229 preempt_disable();
568ce03b978beb Siddharth Chintamaneni 2024-04-29 230 local_irq_save(irq_flags);
568ce03b978beb Siddharth Chintamaneni 2024-04-29 231 if (unlikely(__this_cpu_inc_return(*(qs->map_locked)) != 1)) {
568ce03b978beb Siddharth Chintamaneni 2024-04-29 232 __this_cpu_dec(*(qs->map_locked));
568ce03b978beb Siddharth Chintamaneni 2024-04-29 233 local_irq_restore(irq_flags);
568ce03b978beb Siddharth Chintamaneni 2024-04-29 234 preempt_enable();
568ce03b978beb Siddharth Chintamaneni 2024-04-29 235 return -EBUSY;
568ce03b978beb Siddharth Chintamaneni 2024-04-29 236 }
568ce03b978beb Siddharth Chintamaneni 2024-04-29 237 preempt_enable();
568ce03b978beb Siddharth Chintamaneni 2024-04-29 238
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 239 /* BPF_EXIST is used to force making room for a new element in case the
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 240 * map is full
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 241 */
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 242 bool replace = (flags & BPF_EXIST);
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 243
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 244 /* Check supported flags for queue and stack maps */
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 245 if (flags & BPF_NOEXIST || flags > BPF_EXIST)
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 246 return -EINVAL;
local_irq_restore(irq_flags) before returning.
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 247
a34a9f1a19afe9 Toke Høiland-Jørgensen 2023-09-11 248 if (in_nmi()) {
a34a9f1a19afe9 Toke Høiland-Jørgensen 2023-09-11 249 if (!raw_spin_trylock_irqsave(&qs->lock, irq_flags))
_irqsave can't be nested. Has this code been tested? Perhaps it works
because the callers always call this with IRQs disabled.
a34a9f1a19afe9 Toke Høiland-Jørgensen 2023-09-11 250 return -EBUSY;
a34a9f1a19afe9 Toke Høiland-Jørgensen 2023-09-11 251 } else {
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 252 raw_spin_lock_irqsave(&qs->lock, irq_flags);
a34a9f1a19afe9 Toke Høiland-Jørgensen 2023-09-11 253 }
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 254
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 255 if (queue_stack_map_is_full(qs)) {
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 256 if (!replace) {
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 257 err = -E2BIG;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 258 goto out;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 259 }
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 260 /* advance tail pointer to overwrite oldest element */
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 261 if (unlikely(++qs->tail >= qs->size))
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 262 qs->tail = 0;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 263 }
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 264
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 265 dst = &qs->elements[qs->head * qs->map.value_size];
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 266 memcpy(dst, value, qs->map.value_size);
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 267
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 268 if (unlikely(++qs->head >= qs->size))
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 269 qs->head = 0;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 270
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 271 out:
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 272 raw_spin_unlock_irqrestore(&qs->lock, irq_flags);
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 @273 return err;
f1a2e44a3aeccb Mauricio Vasquez B 2018-10-18 274 }
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
prev parent reply other threads:[~2024-05-04 12:22 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-29 16:56 [PATCH bpf-next 1/2] Patch to Fix deadlocks in queue and stack maps Siddharth Chintamaneni
2024-04-29 16:56 ` [PATCH bpf-next 2/2] Added selftests to check deadlocks in queue and stack map Siddharth Chintamaneni
2024-04-29 17:54 ` Kumar Kartikeya Dwivedi
2024-04-29 18:07 ` Siddharth Chintamaneni
2024-04-29 17:46 ` [PATCH bpf-next 1/2] Patch to Fix deadlocks in queue and stack maps Kumar Kartikeya Dwivedi
2024-04-29 17:51 ` Siddharth Chintamaneni
2024-05-04 12:22 ` Dan Carpenter [this message]
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=e5286af1-53cb-40f1-a0c9-601e2a368114@moroto.mountain \
--to=dan.carpenter@linaro.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=olsajiri@gmail.com \
--cc=rjsu26@vt.edu \
--cc=sairoop@vt.edu \
--cc=sidchintamaneni@gmail.com \
--cc=sidchintamaneni@vt.edu \
--cc=syzbot+8bdfc2c53fb2b63e1871@syzkaller.appspotmail.com \
--cc=yonghong.song@linux.dev \
/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 read-only IMAP folder(s) and NNTP newsgroup(s).