Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 122160ed authored by Tony Truong's avatar Tony Truong
Browse files

msm: pcie: add bounds check for debugfs register write



Via debugfs nodes, users have the option to read and write to
any PCIe register. To ensure clients do not access registers
outside the PCIe range, add checks to validate the offset clients
provide.

Change-Id: Ia35cd04c57f01c21a47962be596bca395b5ca247
Signed-off-by: default avatarTony Truong <truong@codeaurora.org>
parent 2af5d1b0
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
/* Copyright (c) 2014-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -2362,6 +2362,14 @@ static void msm_pcie_sel_debug_testcase(struct msm_pcie_dev_t *dev,
			dev->res[base_sel - 1].base,
			wr_offset, wr_mask, wr_value);

		base_sel_size = resource_size(dev->res[base_sel - 1].resource);

		if (wr_offset >  base_sel_size - 4 ||
			msm_pcie_check_align(dev, wr_offset))
			PCIE_DBG_FS(dev,
				"PCIe: RC%d: Invalid wr_offset: 0x%x. wr_offset should be no more than 0x%x\n",
				dev->rc_idx, wr_offset, base_sel_size - 4);
		else
			msm_pcie_write_reg_field(dev->res[base_sel - 1].base,
				wr_offset, wr_mask, wr_value);