Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3702030imu; Mon, 28 Jan 2019 09:17:18 -0800 (PST) X-Google-Smtp-Source: ALg8bN71EO9DbVk39IwDl6A3QRWLAELSutnwZ4efOzXilXPILKvMN0tOodPBnfoFmvqAo5Vmw8Qh X-Received: by 2002:a63:381c:: with SMTP id f28mr20557937pga.330.1548695838635; Mon, 28 Jan 2019 09:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548695838; cv=none; d=google.com; s=arc-20160816; b=ZtIHFResO5CdIGQyxEv/GI5+G+E2IpS1uHEAti20tIFJDhgx7Ltf6JeRuEQHrQA2Jq yc3uCPaq9bDibby+zekOQuTcXfCWGrt6MWah+cuxHMJojjjvCwOJBfOk2cfARELOcT51 cbDH0+etEebqsarWxSjsD6D6uhynylINu4RITqw3/nWZWlutVhYsEiTy2J7G4LYJtaB9 yWMK6aynFsU/TGFE/ptIe9I4QNK2/0TRU1R8VC1NNc+j1+r+G+ajaeXY0zfwFSF84OH/ Y4lwe6a0blcwEKjIv6jBXJ5AKgKpdYMJDpdY51kAk3b0ni0fhIAIfyQ4SbWhl77hf+Mb dtQA== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=GeNjfeW5ec8Ps3bmDXNGCRyXUxZTORdlBgJUpBme7s4=; b=pADLJPqc4NTs1g+/zqrQUM3CkFTVBFSWWvfo7wKUGxkfhjjSgVxQBxS8YTEBCkXSo8 yuVxCnoixOyst0bRF8EgDAPtV9m1/C9cd+QYDdJOF+E5dMtE9NIfJvXRLq5e2wmF0Zez jChs7cYh1atHVYpQdvXFVUbdgP4SWP/FJIgXPbG2FSx5hN4yAh+WkHsC8/+wzq1y+ftE kmJOUG7dLEhy7NcUwHHhzW5RjxJnHmi75RA2brBCF8ylix4kaSn8f9mPqX8aGiUssiQW I7h0o1rmHgPHT7TjzXyWPufNK0arnS9Is9HZoGD6UGNq20D4puA+/kcboe5KfpUsukXm S9Ug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=gGbZp3Wt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e15si32784870pgm.25.2019.01.28.09.17.03; Mon, 28 Jan 2019 09:17:18 -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=gGbZp3Wt; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731164AbfA1RQp (ORCPT + 99 others); Mon, 28 Jan 2019 12:16:45 -0500 Received: from mail.kernel.org ([198.145.29.99]:54366 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731469AbfA1QGJ (ORCPT ); Mon, 28 Jan 2019 11:06:09 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 90A652171F; Mon, 28 Jan 2019 16:06:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1548691568; bh=TxB9m43FZ8LrvCUf0ywSNbFnMvsOpUJCKQVR5eeEn0o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gGbZp3WtYdClSgT78VajDk89SLf44GTdk9CC5nObJIbj3WzoJ0qLo1ucg30O/Oeth w0u239wBDcbYr6/fKn3p8zhEH0FM8Qa+O+2jzOdf67geV2uID3OxPG4EZouJPlFzL8 i/E7mYsIFRTtsqUn6XPDGqVY/wmMkDRVCZ0LbLKU= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Joey Zhang , Wesley Sheng , Bjorn Helgaas , Sasha Levin , linux-pci@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 145/258] switchtec: Fix SWITCHTEC_IOCTL_EVENT_IDX_ALL flags overwrite Date: Mon, 28 Jan 2019 10:57:31 -0500 Message-Id: <20190128155924.51521-145-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190128155924.51521-1-sashal@kernel.org> References: <20190128155924.51521-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joey Zhang [ 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