Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp585901iog; Mon, 13 Jun 2022 08:37:28 -0700 (PDT) X-Google-Smtp-Source: AGRyM1vMWimPJ+vt9DUgd5Ulu65TWaxcXKw34p/8lw/jIWskUTI+8GLvQkPCY24DMB1wXPdQ2sUX X-Received: by 2002:a17:907:88c3:b0:711:c65d:ff43 with SMTP id rq3-20020a17090788c300b00711c65dff43mr414117ejc.182.1655134648360; Mon, 13 Jun 2022 08:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655134648; cv=none; d=google.com; s=arc-20160816; b=m6hxLydsi4T71Ny2CFbwoUjwgbATXmZPs0c86DtnVZPDcUIJ67IunxXFBFC2KYBHnk TK9S7eEhdHkfPLrke+PdxB7X13W68rM4J6xGD+VDfHg8DB/b6qfmXnUhqj/H6zqlYYTi vLoNHajzR9XdftWpVsPxgWnlqA32G50FfM613HesSEc/HzvpTyX3wIDW6VDZ27E56D2S wZCCBoJAHEZNwr4YEC3H8G0r7f4cGKgP1Mv/84+miG+50bJHhEeinxTp5+QMmsxcn6M/ vmArXHNb4pdGwPx5SgY0Z2wDftFGdWgYRmNoXh3ySTGw0ffNUjoREvnytlQKivVSHHGM MK3A== 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=6YqA/VZRyCeAk/ceb1EXz9+FQvLlghyWs3QABwfPYfw=; b=V+4QDORrY5TAM0iRRujtM14K8uXDZNOajBB+nNrVK8hMoACiEv78iQA8oaVma9ZiBU YSWZVzpTV7nt1hGHS0Pn5Q5Yjw7x3TyDdD1ej+aICLtKnHJxqhho2SEXxd7LFyUI5uR3 YJ35Pr98gUOcjHf3cajWl+W98Of+D2Pd5hsKFRoYfuzLydb6Xv4H6lqnIR/TSYbmEBwp 6TU6a8fWBhvNQ6L1rn1FXCALrJ/hDQ28nfN05hJeygypeIwe7jbPI/E5Kckl5Fl3I67l KJV4/lVAxigzuhytEtwbvwJfKvVEtXiyEqFV47m5e8F10S+50JeWorlTIzcpikKL3B8E hdCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rUr8HLB+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id nc12-20020a1709071c0c00b007117f5643c5si9556468ejc.267.2022.06.13.08.37.03; Mon, 13 Jun 2022 08:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=rUr8HLB+; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356775AbiFMLta (ORCPT + 99 others); Mon, 13 Jun 2022 07:49:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357411AbiFMLqG (ORCPT ); Mon, 13 Jun 2022 07:46:06 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62FEA4B42C; Mon, 13 Jun 2022 03:52:17 -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 dfw.source.kernel.org (Postfix) with ESMTPS id 673B761346; Mon, 13 Jun 2022 10:52:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 749D4C34114; Mon, 13 Jun 2022 10:52:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1655117535; bh=c/sh0ADfc8YO6RjUcVirxMAJQkJ6AkcflF2WlJjEjmA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rUr8HLB+Yu96A2B2WkI49S8g0OhnhBEXqmOHuVH/QDBejtjmroCdnYfFd452lxRGT cXbwHEeqb0it/R6/12nUHH9IrMOBjEtwJ2f4CYYOtrbxx7UlWwEheW/f/MIbvo284B NKzHIsLGY49ZtfAUn25j6tVbFcs2FmZOW/aFuxtI= 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 4.19 056/287] RDMA/hfi1: Prevent panic when SDMA is disabled Date: Mon, 13 Jun 2022 12:08:00 +0200 Message-Id: <20220613094925.566240775@linuxfoundation.org> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220613094923.832156175@linuxfoundation.org> References: <20220613094923.832156175@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=-8.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 adeb259458de..64ee11542a56 100644 --- a/drivers/infiniband/hw/hfi1/file_ops.c +++ b/drivers/infiniband/hw/hfi1/file_ops.c @@ -308,6 +308,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