Re: [PATCH] PCI: Prevent out of bounds access in numa_node override - part 2

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 11/09/2015 01:56 AM, Mathias Krause wrote:

> 
>> Can you point to the code that does node_states[pci_dev->numa_node] without
>> doing a bounds check?  IMO that's the code that is broken.
> 
> It's the node_state() inline for MAX_NUMNODES > 1.

In drivers/pci/pci-sysfs.c: numa_node_store()

	if (node >= MAX_NUMNODES || !node_online(node))

needs to be broken out into a range and separate online check.

	/* range check */
	if (node < NUMA_NO_NODE || node >= MAX_NUMNODES)
		return -EINVAL;

	/* Is the specific node online? */
	if (node != NUMA_NO_NODE && !node_online(node))
		return -EINVAL; /* perhaps -ENODEV ? */

which will fix the problem.

P.

> 
>>
>> FWIW: I think the idea of your patch is still correct.  Checking for -1 to
>> MAX_NUMNODES is not a bad idea.
> 
> It is. As it prevents userland from triggering the out of bounds read. ;)
> 
> 
> Thanks,
> Mathias
> --
> To unsubscribe from this list: send the line "unsubscribe linux-pci" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux