Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2684557imj; Mon, 11 Feb 2019 07:01:05 -0800 (PST) X-Google-Smtp-Source: AHgI3Ib915r/7vDb1zpngQYGtzmfVuaWDqH5h1tqBODeFked78aLmTpcK+F5J2nXtbaxlBFvA+RR X-Received: by 2002:a63:2013:: with SMTP id g19mr24126338pgg.451.1549897265277; Mon, 11 Feb 2019 07:01:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1549897265; cv=none; d=google.com; s=arc-20160816; b=D+/xAevxlFW6m8IEvU+5upnJn578PyJdESjDbWItsmGTG8CnKtPs8pgzcQlxsbWgwE 9YCRyGKX2axgZDfloYXw2SQ8D4BM+sMjndF0GP8AtnG8NlG8gNPCcatMgxq/niYH6THd UNNhsbag79LFvUqKd9ioycwdEYHxx+s3aXGIIOtc1meD4sXoELU6bDb87NecNO3ZU+mT wI3A/nnXVZUDCYlRkDYasRz85knaLNR10XcaipYi1hXhDMdZveqzJvd+KM91VZXHgb3K 2S/K+NnRF27yu6imhB52/a7HdG37rbVb8WAkErGpWfxRnav0lXUYu2ATEM+GA3+IE7ZE CzFg== 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=yGN9NhStVBRFN3ltNlkkuseXwPmNCmb7JDph7+X9410=; b=gzJn8E79szTvyFSlcUcTJkf2sMNWea7AJMGVXpRHqmKLzZZqcMKkjdZHpm1N/Q5Km6 zCWz2SExzKLuYCRfLgdkcMZPWVKx3THXV8/+Tu5RTWCjLacaFE39DHrwavQmf8YBka39 GQkTlaYNKG4TmsdL8NKqNszBj4+aOS1Mzy31k0fZckF3y+cRd4aVKjVIAhwvwm9wZtQb rhamKsBJKfsWszaBCGL1WIqUol54zY24LXoMrJGxh1GpRdf1AAFla9UOGu9T/eJzBJny mJx+f/3L7EbXTqllp8E8EX1wlC4tnztDZTSuN/wdloCryrCq60qjCnvWsbx7Nct2eIfk EbMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=qTd2hzIm; 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 h6si9443957pgc.589.2019.02.11.07.00.44; Mon, 11 Feb 2019 07:01:05 -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=qTd2hzIm; 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 S2389868AbfBKO7q (ORCPT + 99 others); Mon, 11 Feb 2019 09:59:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:47572 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730023AbfBKO7p (ORCPT ); Mon, 11 Feb 2019 09:59:45 -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 0251C21773; Mon, 11 Feb 2019 14:59:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1549897184; bh=VQPdIR/HvETPUS8wQBYYLerSU9x7EwZzYHXp2DAmhyw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qTd2hzImE9UYNt9fbrMxv9ajjC0UE/QgSFImm3Bf20HpYq+V4vJkZe0e4PMQypmLN feZuNOOOTkxWlvo07NojgL/uPD81g+sN6g5vc7eSbR6JYPHJi2sZNUFPlydeQfDtom BorS5lVTDsizzAc+/kEXPIJh1EWA7Of7/O550wp0= 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.14 089/205] switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite Date: Mon, 11 Feb 2019 15:18:07 +0100 Message-Id: <20190211141834.484314302@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190211141827.214852402@linuxfoundation.org> References: <20190211141827.214852402@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.14-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 620f5b995a12..e3aefdafae89 100644 --- a/drivers/pci/switch/switchtec.c +++ b/drivers/pci/switch/switchtec.c @@ -1064,6 +1064,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))) @@ -1085,7 +1086,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