On Mon, Mar 04, 2019 at 08:53:42AM -0600, Andrew F. Davis wrote:
On 3/1/19 6:06 AM, Brian Starkey wrote:
Am I right in thinking "cmd" comes from userspace? It might be a good idea to not trust _IOC_SIZE(cmd) and use our own. I'm looking at Documentation/ioctl/botching-up-ioctls.txt and drm_ioctl()
Yes cmd is from userspace, but we are in a switch-case that has already matched cmd == DMA_HEAP_IOC_ALLOC which is sized correctly.
Ah yeah, sorry I missed that. It's fine until the struct gets extended, which can be handled if/when.
[snip]
For me, the main thing that's missing is a way to unregister a heap. If drivers/modules are registering heaps, then they also need to be able to remove them again when they go away (rmmod or whatever).
I think that starts to be quite a can of worms, as you might end up with buffers which outlive their allocator (that's true today as well afaik, but is in drivers rather than something more central).
Yeah, was wanting to avoid dealing with all that, at least to start out with. At a high level memory shouldn't ever just disappear, we should block removing a heap driver until all buffers have been released.
Correct me if I'm wrong, but I don't think there's a mechanism in the kernel to do that right now is there? If my DRM driver registers a heap, and then gets rmmod-ed, then kaboom. Just not exporting the symbol might be OK to start with.
Thanks, -Brian