Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2708889pxj; Mon, 31 May 2021 08:46:46 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwHbiTYOcx3jxMz9lYq6Iq75CEgoufrbnpmfTbdzheGbXSL3hHGmAekXpWV7SeI3N86BWpl X-Received: by 2002:a92:d4c2:: with SMTP id o2mr5576190ilm.123.1622476006416; Mon, 31 May 2021 08:46:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622476006; cv=none; d=google.com; s=arc-20160816; b=uN6Cf1dpLIjJ88QWJncRm+zhPOXIHqcY3y/00J8agsPmggXSmod4nCkwsMTis1gAQe CKkhP/4M9zFyuXoWYFnmM2f6tJ7ka+ggNwnUUJgW/9tn2cUIiioTwuWjN8QGH39VnXFE pTlEYqecYVn1oQZUJ3oJy3wJSNgwzjAooFsxGOhNVxsaKE1Xn++l0HqiqSL+er7usoZS Eu2wysKpGbSTPbqZq0bhAAih1CHJ9zkrVSBfTIqhqS5mLHqV2ug+za93yQiwTS2UerYp yrTdjvcd2buCzgvbLs+tRsRApHMEKfeWFvVCKSEfDBBSbrK103Wnm1RPTiWR1WXMAIgE 0g1g== 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=ZktECMqUCodPXcWgMK2A7G19/kqV/bRMsrDraVYX06c=; b=fJzAG8IIfqiSUr5BMp0mX147181Lt8wWc3CggEP+e7/92gOkjoVY7qWIRnJ5q0rldp MSLw9Yi2kP3SXOZrTmg1m7bNHWq+L2NCQvNU0VEk+dtoZQFa4MaDprPZqUfvZgVpUIhU lec+JSYMoLENyLfuR/nnk+rw2NGYgOnrN4b2kPGCndeezR3enoxmNsrI5r4MijXdHEpX n5b3xXYPacV13tIawh+wFbJXjQMdL5CVfkWGepsFXkolJZ483ygSYw2LVZK6okKzplj0 KjyB5/hYQZLmTd+D36jucCD9UqdcmrvTK6M4Yt4ahMIfwmH9SyoAD7xVHWeGcVMKuH2o XX6g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="qtQcX3/o"; 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 h3si14357078jal.79.2021.05.31.08.46.33; Mon, 31 May 2021 08:46:46 -0700 (PDT) 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="qtQcX3/o"; 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 S231836AbhEaPq1 (ORCPT + 99 others); Mon, 31 May 2021 11:46:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:48848 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232719AbhEaOZd (ORCPT ); Mon, 31 May 2021 10:25:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0F6D561584; Mon, 31 May 2021 13:46:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468810; bh=HoD3XkrZGR7Nh9gEQTWIAdrxvzsPYzGy9RtVq6srMV8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qtQcX3/omxz9XHZTTgwVkZcBdl+ISz+u9GpHLXmI1GCNRA1Xi/ZMApTrszpSA4NYe TOtvTc8Wy6n/wUtX6YnDaT9CZ8QHLefFEqlsIYEsXjwXSrOEKYx1iGNlGVFBG/rk/M uC527DaOhpdE41fuCTkxz92cetVYyCYzzEKKOY5A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Eric Farman , Cornelia Huck , Matthew Rosato , Sasha Levin Subject: [PATCH 5.4 138/177] vfio-ccw: Check initialized flag in cp_init() Date: Mon, 31 May 2021 15:14:55 +0200 Message-Id: <20210531130652.698988179@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130647.887605866@linuxfoundation.org> References: <20210531130647.887605866@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: Eric Farman [ Upstream commit c6c82e0cd8125d30f2f1b29205c7e1a2f1a6785b ] We have a really nice flag in the channel_program struct that indicates if it had been initialized by cp_init(), and use it as a guard in the other cp accessor routines, but not for a duplicate call into cp_init(). The possibility of this occurring is low, because that flow is protected by the private->io_mutex and FSM CP_PROCESSING state. But then why bother checking it in (for example) cp_prefetch() then? Let's just be consistent and check for that in cp_init() too. Fixes: 71189f263f8a3 ("vfio-ccw: make it safe to access channel programs") Signed-off-by: Eric Farman Reviewed-by: Cornelia Huck Acked-by: Matthew Rosato Message-Id: <20210511195631.3995081-2-farman@linux.ibm.com> Signed-off-by: Cornelia Huck Signed-off-by: Sasha Levin --- drivers/s390/cio/vfio_ccw_cp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/s390/cio/vfio_ccw_cp.c b/drivers/s390/cio/vfio_ccw_cp.c index 3645d1720c4b..9628e0f3add3 100644 --- a/drivers/s390/cio/vfio_ccw_cp.c +++ b/drivers/s390/cio/vfio_ccw_cp.c @@ -636,6 +636,10 @@ int cp_init(struct channel_program *cp, struct device *mdev, union orb *orb) { int ret; + /* this is an error in the caller */ + if (cp->initialized) + return -EBUSY; + /* * XXX: * Only support prefetch enable mode now. -- 2.30.2