From patchwork Wed Aug 11 09:21:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dimitri John Ledkov X-Patchwork-Id: 1515717 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.ubuntu.com (client-ip=91.189.94.19; helo=huckleberry.canonical.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=canonical.com header.i=@canonical.com header.a=rsa-sha256 header.s=20210705 header.b=l89klIks; dkim-atps=neutral Received: from huckleberry.canonical.com (huckleberry.canonical.com [91.189.94.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4Gl47y1lwDz9sRN; Wed, 11 Aug 2021 19:21:33 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=huckleberry.canonical.com) by huckleberry.canonical.com with esmtp (Exim 4.86_2) (envelope-from ) id 1mDkQQ-00054z-GF; Wed, 11 Aug 2021 09:21:26 +0000 Received: from smtp-relay-canonical-1.internal ([10.131.114.174] helo=smtp-relay-canonical-1.canonical.com) by huckleberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1mDkQL-00054o-Tb for kernel-team@lists.ubuntu.com; Wed, 11 Aug 2021 09:21:21 +0000 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-canonical-1.canonical.com (Postfix) with ESMTPS id B18563F045 for ; Wed, 11 Aug 2021 09:21:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1628673681; bh=QaHo7WFp6kXnwqIsrPxsyg0rlMTcorvsLDcuQEpYiYg=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=l89klIksUq5aQGNOaX8AbIbpdxeecjVNeZPDXo7WodbvhoI7XLrmzMNXc4EqjBgls uLCvoOP4PQO8EU7SZPoi5bcnqcK4N2Lu+kxY+Yq7BGNXzUOfFFIMkE+oYntXMiRXIQ PFcx/xF1yzRuMJHmXzxQnXs20WrNLVg4W8SJDwBaF6B/msNbgdcvKfN6oK6a0H62Tq sb3+jdXJCI+0f776YfY6hNCnGvG5RNZQwIMWnWV4X8cC6DdRbn7SJidnhn73tXfvEY TEvAQ8xVBOLGQVT79ueAlabN+DvQBmTtVoAKWhZemsthfXDithVhujjky+Q9lD03Bw R1In3AYyIkGnw== Received: by mail-wr1-f69.google.com with SMTP id d12-20020a056000186cb02901548bff164dso494320wri.18 for ; Wed, 11 Aug 2021 02:21:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=QaHo7WFp6kXnwqIsrPxsyg0rlMTcorvsLDcuQEpYiYg=; b=LZATRue5MePgj0pE+CU8OzodPWbXjHm050weOhNDEJ0J6XJUM0iEeoC22Or69sXS1e e11nepaXFmcXiLbVVCLXpo6B1n9D9mtcsq5tcgrcqlFyv9MR8fWXPfAY5LbZx8lS4uNX 6hDToujPgt9k1nVoB+qOEdqOtlb4cFQ99VjC28eveKdT6muokfhhNoOmhRyciXodqIc1 /Xw4YGhBl7r2Cg+GDCwtqN6cDIpX7O0od0hD2scgDQeJDwOgK1Y9/g7Wx+LQZgwgDf+s Ovd1x7dTcwoi2MXMRi9KYKlysi2W8p7SpBcn2n71icwE2/j0u87DyQRVhpncDgL1azvj X1NQ== X-Gm-Message-State: AOAM5319/HmlHIQGxjo+q3VsI4tU3esPwn/0tyiMpydaLFEoMIN8JGUm y4T8HqZzOOqT2SHTxsiRx7xRkutIU5nVHU/SwXmmt6AoJWsr39+nnNxDMjFWdjeIudYqSqH8B9E IitS6+2BFPVPKKdCisX6tZxjL+u4F3s7TVgKCyqxTQg== X-Received: by 2002:a1c:791a:: with SMTP id l26mr8991390wme.179.1628673681085; Wed, 11 Aug 2021 02:21:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJ7OOL/FAi2dvxD8bvODQMFpMhe3TYr8ECjKs55Id48T03vZ/Uav7DLpE9oTGNvaH7nPC+FQ== X-Received: by 2002:a1c:791a:: with SMTP id l26mr8991369wme.179.1628673680800; Wed, 11 Aug 2021 02:21:20 -0700 (PDT) Received: from localhost ([2a01:4b00:85fd:d700:af19:b72a:8970:43b5]) by smtp.gmail.com with ESMTPSA id l18sm6224438wmc.30.2021.08.11.02.21.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Aug 2021 02:21:20 -0700 (PDT) From: Dimitri John Ledkov To: kernel-team@lists.ubuntu.com Subject: [PATCH] UBUNTU: SAUCE: RISC-V: prevent sbi_send_cpumask_ipi race with ftrace Date: Wed, 11 Aug 2021 10:21:17 +0100 Message-Id: <20210811092117.183501-1-dimitri.ledkov@canonical.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Thadeu Lima de Souza Cascardo ftrace will patch instructions in sbi_send_cpumask_ipi, which is going to be used by flush_icache_range, leading to potential races and crashes like this: [ 0.000000] ftrace: allocating 38893 entries in 152 pages [ 0.000000] Oops - illegal instruction [#1] [ 0.000000] Modules linked in: [ 0.000000] CPU: 0 PID: 0 Comm: swapper Not tainted 5.11.0-1014-generic #14-Ubuntu [ 0.000000] epc: ffffffe00000920e ra : ffffffe000009384 sp : ffffffe001803d30 [ 0.000000] gp : ffffffe001a14240 tp : ffffffe00180f440 t0 : ffffffe07fe38000 [ 0.000000] t1 : ffffffe0019cd338 t2 : 0000000000000000 s0 : ffffffe001803d70 [ 0.000000] s1 : 0000000000000000 a0 : ffffffe0000095aa a1 : 0000000000000001 [ 0.000000] a2 : 0000000000000002 a3 : 0000000000000000 a4 : 0000000000000000 [ 0.000000] a5 : 0000000000000000 a6 : 0000000000000004 a7 : 0000000052464e43 [ 0.000000] s2 : 0000000000000002 s3 : 0000000000000001 s4 : 0000000000000000 [ 0.000000] s5 : 0000000000000000 s6 : 0000000000000000 s7 : 0000000000000000 [ 0.000000] s8 : ffffffe001a170c0 s9 : 0000000000000001 s10: 0000000000000001 [ 0.000000] s11: 00000000fffcc5d0 t3 : 0000000000000068 t4 : 000000000000000b [ 0.000000] t5 : ffffffe0019cd3e0 t6 : ffffffe001803cd8 [ 0.000000] status: 0000000200000100 badaddr: 000000000513f187 cause: 0000000000000002 [ 0.000000] ---[ end trace f67eb9af4d8d492b ]--- [ 0.000000] Kernel panic - not syncing: Attempted to kill the idle task! [ 0.000000] ---[ end Kernel panic - not syncing: Attempted to kill the idle task! ]--- Where ffffffe00000920e lies in the middle of sbi_send_cpumask_ipi. Signed-off-by: Thadeu Lima de Souza Cascardo --- arch/riscv/kernel/sbi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/riscv/kernel/sbi.c b/arch/riscv/kernel/sbi.c index b8f82c73deb7..9f85f0656f71 100644 --- a/arch/riscv/kernel/sbi.c +++ b/arch/riscv/kernel/sbi.c @@ -562,7 +562,7 @@ long sbi_get_impid(void) return __sbi_base_ecall(SBI_EXT_BASE_GET_MIMPID); } -static void sbi_send_cpumask_ipi(const struct cpumask *target) +static void notrace sbi_send_cpumask_ipi(const struct cpumask *target) { struct cpumask hartid_mask;