Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp2288732iof; Wed, 8 Jun 2022 01:31:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTlPZZgrwCcAfXrsx6gkPf3hA4seiQ6KQePLF2tgkYudpVxX72sfHYPiQY9xe3YQJgJXYp X-Received: by 2002:a63:7e4e:0:b0:3db:945a:2575 with SMTP id o14-20020a637e4e000000b003db945a2575mr28859941pgn.227.1654677089917; Wed, 08 Jun 2022 01:31:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654677089; cv=none; d=google.com; s=arc-20160816; b=vyXXc/+xs9bwSEr+HnEX1JnrkHIauYaUefUzfE2gmn6EzUAEa2Fzolz0OXcsjgkUn0 6trkLdNzTuO6lAFvWn9kMgNF18wVOhvru3irOCc1sOSF6dSni50ua/tPDXUYAkUpQVhP LsJMhMps2NSoO+x4kok7lTnDdvRSpFywcQiohs1PlWS52IOrpcnIF4aGpjrg8SD9SqN9 wYboOqFoIv4rXwp6hUbUF5JEFqpV5JBfccIwFMPrEsGasuFkSS7sH54NS8xsshA4rus5 vREX0algXUhJfOEGsjqtX0OEKCVZ1YEjfIcnRTHjk+6lgRViVzvInac0tOlvjTWHAquM RLew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JDKjy/e5I1eh2KIHEZq3b8pzIUsUgPFWOnVpxClKfFs=; b=j7TIiQYYwNfxqqzA1hV/EfUlHYZCDLtP81sS1rBi8+7g7dkDoyPDfBLERX7drvUApK y6JimuN3puEcWg+dm5Bz25EX8KPglZSgb0Gm1TKlKydmxMJ5TIdC8JQgdS/RrJMDeX3v ySbu9yXqT8u20OPJEhYWUvg+IS5Fw1i4THoS4khAoPV+xept9gl9KvwGT9H/oTNC/dnQ Yw9K1h2HXeOKwN4GYjKusH+E7HMBnh4fN0sMiyOiHo8ewoRAWepmDLmxB611ydnnyBFp xtG5UckTChlQOWdo6Ga7J3Dv7qRzo5Gjdomabm/swPpQdJCRy3TxoD7QXdqLkRFLeUH1 m1Xw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wfPBOVWS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id w8-20020a17090a8a0800b001cd5b0dcab5si29470439pjn.12.2022.06.08.01.31.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 08 Jun 2022 01:31:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=wfPBOVWS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id CC3FD5BD3B; Wed, 8 Jun 2022 00:59:44 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347166AbiFGRiR (ORCPT + 99 others); Tue, 7 Jun 2022 13:38:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347007AbiFGR34 (ORCPT ); Tue, 7 Jun 2022 13:29:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84CF653B46; Tue, 7 Jun 2022 10:25:24 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 42C77B82239; Tue, 7 Jun 2022 17:25:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AA7ECC385A5; Tue, 7 Jun 2022 17:25:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1654622722; bh=7935UyMVAnT3dXYvLzTRTvC+kabYaDndD1293erSu68=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wfPBOVWSICUlfK1QoZPUgGfDE6Bre3X0KMLcWL4OEWbq+uZIaknu5OK/O7l6Swxxj MNRZv0LenMI76HcX/UMAhlRfQ2xLCNJzqDUBT1YhY6Q+TcS9U2tRNFXpAL1O0SeXOz lk+QMzvth/TrzljhWGHj8iSXFx0vKmad2S981X88= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Douglas Miller , Dennis Dalessandro , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.10 119/452] RDMA/hfi1: Prevent panic when SDMA is disabled Date: Tue, 7 Jun 2022 18:59:36 +0200 Message-Id: <20220607164912.105330054@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220607164908.521895282@linuxfoundation.org> References: <20220607164908.521895282@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Douglas Miller [ Upstream commit 629e052d0c98e46dde9f0824f0aa437f678d9b8f ] If the hfi1 module is loaded with HFI1_CAP_SDMA off, a call to hfi1_write_iter() will dereference a NULL pointer and panic. A typical stack frame is: sdma_select_user_engine [hfi1] hfi1_user_sdma_process_request [hfi1] hfi1_write_iter [hfi1] do_iter_readv_writev do_iter_write vfs_writev do_writev do_syscall_64 The fix is to test for SDMA in hfi1_write_iter() and fail the I/O with EINVAL. Link: https://lore.kernel.org/r/20220520183706.48973.79803.stgit@awfm-01.cornelisnetworks.com Signed-off-by: Douglas Miller Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/hw/hfi1/file_ops.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/infiniband/hw/hfi1/file_ops.c b/drivers/infiniband/hw/hfi1/file_ops.c index 329ee4f48d95..cfc2110fc38a 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c @@ -306,6 +306,8 @@ static ssize_t hfi1_write_iter(struct kiocb *kiocb, struct iov_iter *from) unsigned long dim = from->nr_segs; int idx; + if (!HFI1_CAP_IS_KSET(SDMA)) + return -EINVAL; idx = srcu_read_lock(&fd->pq_srcu); pq = srcu_dereference(fd->pq, &fd->pq_srcu); if (!cq || !pq) { -- 2.35.1