Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2761940imj; Mon, 11 Feb 2019 08:06:11 -0800 (PST) X-Google-Smtp-Source: AHgI3IboMsELWXf3A+37778GxxEKMjOkguucacpmYO+RBCJjMSmVQvimTNvuh3qIzWWsShv9IoyO X-Received: by 2002:a17:902:b114:: with SMTP id q20mr33753510plr.48.1549901171907; Mon, 11 Feb 2019 08:06:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549901171; cv=none; d=google.com; s=arc-20160816; b=W/MNUfX70r1myYAJfh7k//H5ImW92luukeZNNvVTGD8O9z+FveQT7et81Y1OvxMk1L SMbRz6+s0eZMzdC9z9T5wUmmuDW5jyLPiXGzQsJS2n+wMp50gHOjG+tKaKHVGUX/71oS ZyqpBHrCYw+8blC8RQzcBDIbCxQA5dNNGulKD1mgdoLU0CdWF5YQeSvrzXhLfWihY2Sa WXdGKFCOs7jr+54c6iKm8+K/P0mfEmwlxdDqGbvO5Z5x2Wl8SrMfDRElBsqWi0CsHhq4 BpKK5mwzA7kbL3Yt1j2PPRL315BAusVCcKoVbsEF+t5UwilbZfc/pbo6FUFZZsaWNILV rayg== 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=zvknMSjMVpU/U0qWQozgvy7l2P/bJxfc19d+CNHJ1DE=; b=bBrbf13LybxYCAAX5yAGYMgaVIb1h/TKY3vheCRERoqQoawQxjE5FQquABG6mbZmLO si1XdSUewIcsTFjEk6Q2UXuTvH3M8Lx1IUIUYyHKavi2SUF+OzOnGUFqI01Y7NiaEthe QZJq3/yRkplwS216r0DZ3aL4Apd1sJS+PHT9a5dNDwZkA5Evgf3xlOJfShPqFYoGIXx1 Q8v9ry/qYh2ZqcoSiXb3SooXfgq0VhqdR9s8DIsffmozDeSPilzvP0GRDlD1oLqhhSSa 3lYSlO5IDkHEFkZQmvs8R63ii172sXdxNz1mcU+10Yc/xtulbEWwpQBiPyBwkhnTkXPD wR4g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=oNogGCA4; 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 b21si10395218pls.31.2019.02.11.08.05.42; Mon, 11 Feb 2019 08:06:11 -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=oNogGCA4; 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 S1729864AbfBKO2Z (ORCPT + 99 others); Mon, 11 Feb 2019 09:28:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:34276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728991AbfBKO2U (ORCPT ); Mon, 11 Feb 2019 09:28:20 -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 388E720821; Mon, 11 Feb 2019 14:28:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549895299; bh=BChTxnJKbpaGDSxm3qWTT/lfgwai3R5tyWZncbdPCKI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oNogGCA4YwQoCsEZJ1KK5ZfirYNSGlIfCA3daEqT0FteqTtZd0XyN9G1uzzweYNOz eOvuG38um1wU5gyz0AZrkal1iviO32p2MwaamN/M5t6SBI/bLeYLwWzaefVpJIVPdR nHYqTGG7d3vBzZBpqoDixtZIA+kb+dYP3/6XfSpU= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Joey Zhang , Wesley Sheng , Bjorn Helgaas , Logan Gunthorpe , Sasha Levin Subject: [PATCH 4.20 160/352] switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite Date: Mon, 11 Feb 2019 15:16:27 +0100 Message-Id: <20190211141857.063936593@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141846.543045703@linuxfoundation.org> References: <20190211141846.543045703@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.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e4a7dca5de625018b29417ecc39dc5037d9a5a36 ] In the ioctl_event_ctl() SWITCHTEC_IOCTL_EVENT_IDX_ALL case, we call event_ctl() several times with the same "ctl" struct. Each call clobbers ctl.flags, which leads to the problem that we may not actually enable or disable all events as the user requested. Preserve the event flag value with a temporary variable. Fixes: 52eabba5bcdb ("switchtec: Add IOCTLs to the Switchtec driver") Signed-off-by: Joey Zhang Signed-off-by: Wesley Sheng [bhelgaas: changelog] Signed-off-by: Bjorn Helgaas Reviewed-by: Logan Gunthorpe Signed-off-by: Sasha Levin --- drivers/pci/switch/switchtec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c index 54a8b30dda38..37d0c15c9eeb 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -800,6 +800,7 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev, { int ret; int nr_idxs; + unsigned int event_flags; struct switchtec_ioctl_event_ctl ctl; if (copy_from_user(&ctl, uctl, sizeof(ctl))) @@ -821,7 +822,9 @@ static int ioctl_event_ctl(struct switchtec_dev *stdev, else return -EINVAL; + event_flags = ctl.flags; for (ctl.index = 0; ctl.index < nr_idxs; ctl.index++) { + ctl.flags = event_flags; ret = event_ctl(stdev, &ctl); if (ret < 0) return ret; -- 2.19.1