Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3548795pxb; Mon, 1 Mar 2021 13:01:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNruWKwMAgOVC+hxmTso3tphU2MOiyVhRzDMH6qMxnaWSZSZr3CSZdan7iUNSD5vfA+2Jy X-Received: by 2002:a17:906:2bc2:: with SMTP id n2mr17307192ejg.381.1614632519616; Mon, 01 Mar 2021 13:01:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614632519; cv=none; d=google.com; s=arc-20160816; b=FXiazan8Rs0w75c8/DZiWqCznypaKUTdg176xc7m3/v9DOXD/5kH7Tc993WPfNkU0b XEuU8ERIcn95nnRFq915iB2wFLU/ErK724KQ5vg+6Nl2fRI7ZPSmYlXRwCCn0scFS0v4 Jrm2itdUiaooVXVnzw1TmCwqwPvFUDdxJpwhzwWz0pGM5Mr0kPq0Wu/SMWVnUvlqQXop uCbjBOPLkRwBBgM5iS6e6shMucA9xclDqBB1jl2OtBG69mBPHCsGi9t9GIYI4YFvddnJ mVQxmV3+3Cjfwad7aWLj82GWDcE/eGQ7HJItq8+8AFn+eP/sh8qzu7bpmnZ4sSUERNO+ yrqg== 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=4psL31PRg1S753JT+2tiIuamgQ2XKdJrv0u6ZAxqIxg=; b=RKegBJX62K2LA/ES0o2WoUKNtg6VliI2zofMjJMu1Kyi4fx/EZlURAkQflMMcI3Xkx oAQB5qBaCf3s2j1jLYxi+Ex6OBpsaVBydBYECviE7ym7YCc39tH1ZOsBUbl8qHc9UNfi 10tb57Zby+KrOhZMe23yedONUHVTv9IswsVZqn3MYtsl+DzE8VyVfMEI8dd5Co0cgggd yVUv4yO96MXWZLerzmnEfbqJiw4WF2WJgVhDzH8ySjF735AlMXNt3o/kkV9caV+L1mNH xlp4J1LYopqvqvkngZgSKHOA11Qz3KpD5AnHLsXGkjBEdBeYGxPJa6+txDXkRSk1JJmb 0Iiw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OwBYGbXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m24si4158892edp.422.2021.03.01.13.01.36; Mon, 01 Mar 2021 13:01:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=OwBYGbXo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.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: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243881AbhCAU56 (ORCPT + 99 others); Mon, 1 Mar 2021 15:57:58 -0500 Received: from mail.kernel.org ([198.145.29.99]:37784 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237304AbhCARLQ (ORCPT ); Mon, 1 Mar 2021 12:11:16 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8E54664EDE; Mon, 1 Mar 2021 16:43:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614616982; bh=Xq5hv6j2ZYDoZ0J2KXhUahGbS9/qEVyJnd0G4B4ZfY0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=OwBYGbXoRjYq4QZcmLqT80ecDHZWSp89aZGzAVkALFKTa/6xJ8OK2WaFXEOd932ek 6T6cRErCMluJnqZ0FCMKpnTPRnou+6KTWg17siknGVcb9WY2sJLkvC535zjYzkOE27 SqbgzMwwHK3s4fIywvwSLUVOsg/j4dJhQIMUsXvM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shay Drory , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 4.19 131/247] IB/umad: Return EIO in case of when device disassociated Date: Mon, 1 Mar 2021 17:12:31 +0100 Message-Id: <20210301161038.087873524@linuxfoundation.org> X-Mailer: git-send-email 2.30.1 In-Reply-To: <20210301161031.684018251@linuxfoundation.org> References: <20210301161031.684018251@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Shay Drory [ Upstream commit 4fc5461823c9cad547a9bdfbf17d13f0da0d6bb5 ] MAD message received by the user has EINVAL error in all flows including when the device is disassociated. That makes it impossible for the applications to treat such flow differently. Change it to return EIO, so the applications will be able to perform disassociation recovery. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Link: https://lore.kernel.org/r/20210125121339.837518-2-leon@kernel.org Signed-off-by: Shay Drory Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/user_mad.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/user_mad.c b/drivers/infiniband/core/user_mad.c index a18f3f8ad77fe..db2ac5218c371 100644 --- a/drivers/infiniband/core/user_mad.c +++ b/drivers/infiniband/core/user_mad.c @@ -366,6 +366,11 @@ static ssize_t ib_umad_read(struct file *filp, char __user *buf, mutex_lock(&file->mutex); + if (file->agents_dead) { + mutex_unlock(&file->mutex); + return -EIO; + } + while (list_empty(&file->recv_list)) { mutex_unlock(&file->mutex); @@ -508,7 +513,7 @@ static ssize_t ib_umad_write(struct file *filp, const char __user *buf, agent = __get_agent(file, packet->mad.hdr.id); if (!agent) { - ret = -EINVAL; + ret = -EIO; goto err_up; } -- 2.27.0