From patchwork Wed Dec 29 15:32:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Padmanabha Srinivasaiah X-Patchwork-Id: 12700994 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 20E22C433EF for ; Wed, 29 Dec 2021 15:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:List-Subscribe:List-Help: List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date:Subject:Cc:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=3Ca7Db5YruGgYbbEYeA6Y1RjRtqAh8KlarZjBfBAsGw=; b=LozPABJNr83bVI kiSX60NdjWhm/6wOR5r9M7f4lZtI+nnnzYUBUXBl3abyMZj8qTsN/Cjm5g5Ofko0CqNrIc1M6hP4v sx28b6P31uwi8IwGpfYAmuRnHrglxhoM0Ml07Vcwjj+sgtLlxjnfpuKjrXle2jzcAepIz0ZLaw71u 4INjSs7axUWZdcxtJRzLkvZarGQIrD2fudiP3dL+Vz1s94PEhxW4jSHBOAYiONRZU7Jf526wZYT6i z+W9FbSvQy144ktj6iK90vTj16/Q8tFcpiePAE0FK8GejdjohmzgZGsSJmAZZG/UUhXpoAQ6fBiAS YqsAfxZlFrpr976T7x8g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2axa-0031km-Q4; Wed, 29 Dec 2021 15:33:50 +0000 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n2axX-0031jr-Aj; Wed, 29 Dec 2021 15:33:48 +0000 Received: by mail-wr1-x42b.google.com with SMTP id a9so45060745wrr.8; Wed, 29 Dec 2021 07:33:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id; bh=yaFPtv68FbWYXGv8VLXk7KGh6SEfuXe5S0bPe1jKtfY=; b=jk3C/jHTfzsqW+Hy0loflhYtDDtvEBT1DbQxyp9C1LBXQ035oUqiFLlEDD4T2wYXZT SCmD1VlLZyOj3aL5xF81F0v5KDmA36PJYj/2Jfm4rTSNCk7TeHtcFgmDWzzgoWdsJwdU xLumxBO11BthYZoeqFrA/+gSaY6UvZLmDY2joWg6jKogL6Y12sdkYp2LgxIke7u52ros ZpvOZlPvJFIVdJtzWPn1xDZNkBjnsbIDkhaKj+AcXwwQpi6ydMp1lBfFd6YI3oRtasCl B+B0kCbfyDflM7pC9gDTWfisOc0AvXuRcCMWGv6Ljq3z8hC4ricTVwoQ+Zv+JhrlPf+a ZT0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=yaFPtv68FbWYXGv8VLXk7KGh6SEfuXe5S0bPe1jKtfY=; b=Nn9qgM7uTkOqFR7d9umCsrRXxbonhPhT1EYhOB/pNs2dsZkIqiPAyH3FtvsuzbJHX9 h+68xIZdwxiwI0mzqqnK5l81cYaxuOJnZOnq2gKrVVk3TXGjsWPPB5FezqVbpLpv0jj/ QljhtnJ7JBR5nKkAJkPSFfEiHULV0qaAC8AZ/kHEMRrxaIhGdaxt9xB0Jg6oIsJoQTPu 4FyJbcWFnj6bgXPvDnX7k1WkFl3tLT8SXdOD1MfJ4sBTyI+7muhAzPyS88Vcgi4odPCN BRD/LlFiaW/eAg0As8Uy8wc+4GRSTF8tDxqJR9u4RBWCMG2WL/lKhIoAEseZ3o6fGCZO 62mw== X-Gm-Message-State: AOAM530aWKq6rYu6Iksb/0QiqYknlfw5u1rd97sXDoI0Nx512lok8BOg Eo3gCBXTgeKV5+WCh3OJJNAZkqv766Tiyg+g X-Google-Smtp-Source: ABdhPJxHX/R+GnbR8HnzoKbDUijAmc3zIEpe+luqaDUulZ5jxVlaVvrMbn4pLGtC37tYfdBm/4Y1Tg== X-Received: by 2002:adf:e8cd:: with SMTP id k13mr21643961wrn.10.1640792025183; Wed, 29 Dec 2021 07:33:45 -0800 (PST) Received: from pswork.fritz.box (i5E86B42B.versanet.de. [94.134.180.43]) by smtp.gmail.com with ESMTPSA id l10sm6801522wmq.7.2021.12.29.07.33.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 29 Dec 2021 07:33:44 -0800 (PST) From: Padmanabha Srinivasaiah To: linux-rpi-kernel@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Cc: gregkh@linuxfoundation.org, nsaenz@kernel.org, treasure4paddy@gmail.com, Stefan Wahren , Gaston Gonzalez , Ojaswin Mujoo , Arnd Bergmann , Phil Elwell , bcm-kernel-feedback-list@broadcom.com Subject: [PATCH] staging: vc04_services: Fix RCU dereference check Date: Wed, 29 Dec 2021 16:32:40 +0100 Message-Id: <20211229153243.6064-1-treasure4paddy@gmail.com> X-Mailer: git-send-email 2.17.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211229_073347_404737_E5EE9338 X-CRM114-Status: UNSURE ( 8.10 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org In service_callback path RCU dereference done without rcu_read_[lock/unlock] pair, fixing same by using them. [ 32.201659] ============================= [ 32.201664] WARNING: suspicious RCU usage [ 32.201670] 5.15.11-rt24-v8+ #3 Not tainted [ 32.201680] ----------------------------- [ 32.201685] drivers/staging/vc04_services/interface/vchiq_arm/vchiq_core.h:529 suspicious rcu_dereference_check() usage! [ 32.201695] [ 32.201695] other info that might help us debug this: [ 32.201695] [ 32.201700] [ 32.201700] rcu_scheduler_active = 2, debug_locks = 1 [ 32.201708] no locks held by vchiq-slot/0/98. [ 32.201715] [ 32.201715] stack backtrace: [ 32.201723] CPU: 1 PID: 98 Comm: vchiq-slot/0 Not tainted 5.15.11-rt24-v8+ #3 [ 32.201733] Hardware name: Raspberry Pi 4 Model B Rev 1.4 (DT) [ 32.201739] Call trace: [ 32.201742] dump_backtrace+0x0/0x1b8 [ 32.201772] show_stack+0x20/0x30 [ 32.201784] dump_stack_lvl+0x8c/0xb8 [ 32.201799] dump_stack+0x18/0x34 [ 32.201808] lockdep_rcu_suspicious+0xe4/0xf8 [ 32.201817] service_callback+0x124/0x400 [ 32.201830] slot_handler_func+0xf60/0x1e20 [ 32.201839] kthread+0x19c/0x1a8 [ 32.201849] ret_from_fork+0x10/0x20 Signed-off-by: Padmanabha Srinivasaiah --- drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c index 6759a6261500..ee1b48db9681 100644 --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c @@ -1058,7 +1058,10 @@ service_callback(enum vchiq_reason reason, struct vchiq_header *header, DEBUG_TRACE(SERVICE_CALLBACK_LINE); + rcu_read_lock(); service = handle_to_service(handle); + rcu_read_unlock(); + if (WARN_ON(!service)) return VCHIQ_SUCCESS;