From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B894AC4360C for ; Thu, 10 Oct 2019 06:19:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 884DF218DE for ; Thu, 10 Oct 2019 06:19:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=fb.com header.i=@fb.com header.b="N+An6FkB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732881AbfJJGT1 (ORCPT ); Thu, 10 Oct 2019 02:19:27 -0400 Received: from mx0a-00082601.pphosted.com ([67.231.145.42]:5216 "EHLO mx0a-00082601.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726840AbfJJGT1 (ORCPT ); Thu, 10 Oct 2019 02:19:27 -0400 Received: from pps.filterd (m0044012.ppops.net [127.0.0.1]) by mx0a-00082601.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id x9A6Aamm032481 for ; Wed, 9 Oct 2019 23:19:26 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fb.com; h=from : to : cc : subject : date : message-id : mime-version : content-type; s=facebook; bh=fQdwDnCPngz+0vM6jXWTh2YHwn4lEhUtF8/NVMQtnMY=; b=N+An6FkB8vi+UKXE4fPt0yehTc97qXxWrw4grcNh7LvlQ87QJoQvqF9iq0jcHfAxKYZw PDtHNzxGVpzomzBNe2JQkMxejdHdd1+BWgRfOgdgqJGGXKEfpe+mMgRrtQamYnsBslMi oh3znn5Mh7BFciLL89RujEpM0kY16rwe9ew= Received: from mail.thefacebook.com (mailout.thefacebook.com [199.201.64.23]) by mx0a-00082601.pphosted.com with ESMTP id 2vhhyvuee0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Wed, 09 Oct 2019 23:19:26 -0700 Received: from 2401:db00:2050:5076:face:0:1f:0 (2620:10d:c081:10::13) by mail.thefacebook.com (2620:10d:c081:35::127) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA) id 15.1.1713.5; Wed, 9 Oct 2019 23:19:25 -0700 Received: by devbig006.ftw2.facebook.com (Postfix, from userid 4523) id E4AD262E3559; Wed, 9 Oct 2019 23:19:22 -0700 (PDT) Smtp-Origin-Hostprefix: devbig From: Song Liu Smtp-Origin-Hostname: devbig006.ftw2.facebook.com To: , , CC: , Song Liu Smtp-Origin-Cluster: ftw2c04 Subject: [PATCH bpf-next 0/2] bpf/stackmap: fix A-A deadlock in bpf_get_stack() Date: Wed, 9 Oct 2019 23:19:14 -0700 Message-ID: <20191010061916.198761-1-songliubraving@fb.com> X-Mailer: git-send-email 2.17.1 X-FB-Internal: Safe MIME-Version: 1.0 Content-Type: text/plain X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.95,1.0.8 definitions=2019-10-10_03:2019-10-08,2019-10-10 signatures=0 X-Proofpoint-Spam-Details: rule=fb_default_notspam policy=fb_default score=0 phishscore=0 mlxlogscore=963 suspectscore=0 bulkscore=0 impostorscore=0 mlxscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 adultscore=0 lowpriorityscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-1908290000 definitions=main-1910100058 X-FB-Internal: deliver Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org bpf stackmap with build-id lookup (BPF_F_STACK_BUILD_ID) can trigger A-A deadlock on rq_lock(): rcu: INFO: rcu_sched detected stalls on CPUs/tasks: [...] Call Trace: try_to_wake_up+0x1ad/0x590 wake_up_q+0x54/0x80 rwsem_wake+0x8a/0xb0 bpf_get_stack+0x13c/0x150 bpf_prog_fbdaf42eded9fe46_on_event+0x5e3/0x1000 bpf_overflow_handler+0x60/0x100 __perf_event_overflow+0x4f/0xf0 perf_swevent_overflow+0x99/0xc0 ___perf_sw_event+0xe7/0x120 __schedule+0x47d/0x620 schedule+0x29/0x90 futex_wait_queue_me+0xb9/0x110 futex_wait+0x139/0x230 do_futex+0x2ac/0xa50 __x64_sys_futex+0x13c/0x180 do_syscall_64+0x42/0x100 entry_SYSCALL_64_after_hwframe+0x44/0xa9 For more details on how to reproduce this is error, please refer to 2/2. Fix this issue by checking a new helper this_rq_is_locked(). If the rq_lock is already locked, postpone up_read() in irq_work, just like the in_nmi() case. Song Liu (2): sched: introduce this_rq_is_locked() bpf/stackmap: fix A-A deadlock in bpf_get_stack() include/linux/sched.h | 1 + kernel/bpf/stackmap.c | 2 +- kernel/sched/core.c | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) -- 2.17.1