Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3511593imu; Mon, 7 Jan 2019 04:51:57 -0800 (PST) X-Google-Smtp-Source: ALg8bN4BRA1PHHIh4+fKe11LZ37FiAMsisZO3EfnolkIathgbsu9vQxQ0Jgew0VRAY6BJJZ5QMVt X-Received: by 2002:a63:c0f:: with SMTP id b15mr10964672pgl.314.1546865517836; Mon, 07 Jan 2019 04:51:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546865517; cv=none; d=google.com; s=arc-20160816; b=dih1GtlxHH47MzZEpWtGLFj1uyqek+yS1hCwN2+LDSf8S94GzVQ55l/ycorBjI3qrl Ixyt8HWvtgp20eNzgKz495NLU/xAb3G0QmZSy4z/P3fAnHBFhazsCgdg4ZJBXpfwlJsl zXaMvGtMH/BfhaLjND8NF5ct4+E0Gsn+PzIvTBmhRBDKNziz46OgneAbb1LydhrnZDp7 c+d9GRtvbvMbBnbfnA5MHEdlVN4iWwBCT59zCdNvHIl/ndhrd/q6SLqLlsc68eufwzuj g0S3ypcE0UInWi/Ls9tGxI6C5ss3ZqFHrWw37IAze1N9a25/QZM2GQLeHe3bNUhQaDfN aDjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E0W1ay7nPaQgOU1IWzluTQWow7cPls5KG82bKXbPE0A=; b=lwOm8HrF34KzcflhUH8M8L/CGbrzQsJNrLdJFB7ZedEEo7cVqm/ynp/eND5wpbmT6y 48VeY6lmEGsTqIMRIWieW0JjMcBnkwse9Tv5kfW7m+bvoANF6/CGSZILxJd9qQLrGvg2 /2IuiOurEHF8aYUz8OhecsjQXLfte5WkESskNM/jhPa5j4MoHkI/L8mto0Us6aT+LYDe mx1HnmswrRRPSzpjwvjwB258LpI2J+oehoAdBPOphSWUgeX6JDNlQIwYBODodIokk+sH wNFrpiBt2rZM/QJrYEMJd5P9Eh7L4gbRG/9XKFlaoD/PApf8iqnc/aDWn0ZQiChrAH2Q gpKg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a9GLGhlF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m3si3313024pgc.232.2019.01.07.04.51.42; Mon, 07 Jan 2019 04:51:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=a9GLGhlF; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729282AbfAGMs7 (ORCPT + 99 others); Mon, 7 Jan 2019 07:48:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:39790 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728274AbfAGMs5 (ORCPT ); Mon, 7 Jan 2019 07:48:57 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6AC4020651; Mon, 7 Jan 2019 12:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1546865337; bh=Mz+RnP/LNzC2uBbiJrF1l63r+EFUM2wj1ePC8fONfRw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a9GLGhlFFKDPo9UJlWOevGmkfOmWU1sul7xSE3prDKAFIsatIxLq4g3zdkxPFnVI7 cQopekmI0vFYOJz0BhBBfq44kwRCwMyBzbb6+0mcWMAIEdyERb/RLyyT7Mai9z8H/p ysNyd/P0HwoTHRHy+tvJ8u/t6J0q7E1Hd+wzsSjM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mike Marciniszyn , "Michael J. Ruhl" , Dennis Dalessandro , Jason Gunthorpe Subject: [PATCH 4.19 059/170] IB/hfi1: Incorrect sizing of sge for PIO will OOPs Date: Mon, 7 Jan 2019 13:31:26 +0100 Message-Id: <20190107104500.035981734@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190107104452.953560660@linuxfoundation.org> References: <20190107104452.953560660@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.19-stable review patch. If anyone has any objections, please let me know. ------------------ From: Michael J. Ruhl commit dbc2970caef74e8ff41923d302aa6fb5a4812d0e upstream. An incorrect sge sizing in the HFI PIO path will cause an OOPs similar to this: BUG: unable to handle kernel NULL pointer dereference at (null) IP: [] hfi1_verbs_send_pio+0x3d8/0x530 [hfi1] PGD 0 Oops: 0000 1 SMP Call Trace: ? hfi1_verbs_send_dma+0xad0/0xad0 [hfi1] hfi1_verbs_send+0xdf/0x250 [hfi1] ? make_rc_ack+0xa80/0xa80 [hfi1] hfi1_do_send+0x192/0x430 [hfi1] hfi1_do_send_from_rvt+0x10/0x20 [hfi1] rvt_post_send+0x369/0x820 [rdmavt] ib_uverbs_post_send+0x317/0x570 [ib_uverbs] ib_uverbs_write+0x26f/0x420 [ib_uverbs] ? security_file_permission+0x21/0xa0 vfs_write+0xbd/0x1e0 ? mntput+0x24/0x40 SyS_write+0x7f/0xe0 system_call_fastpath+0x16/0x1b Fix by adding the missing sizing check to correctly determine the sge length. Fixes: 7724105686e7 ("IB/hfi1: add driver files") Reviewed-by: Mike Marciniszyn Signed-off-by: Michael J. Ruhl Signed-off-by: Dennis Dalessandro Signed-off-by: Jason Gunthorpe Signed-off-by: Greg Kroah-Hartman --- drivers/infiniband/hw/hfi1/verbs.c | 2 ++ 1 file changed, 2 insertions(+) --- a/drivers/infiniband/hw/hfi1/verbs.c +++ b/drivers/infiniband/hw/hfi1/verbs.c @@ -1141,6 +1141,8 @@ int hfi1_verbs_send_pio(struct rvt_qp *q if (slen > len) slen = len; + if (slen > ss->sge.sge_length) + slen = ss->sge.sge_length; rvt_update_sge(ss, slen, false); seg_pio_copy_mid(pbuf, addr, slen); len -= slen;