And I had concern about your approach:
If I read it correctly, with the patch we would ignore locking
failure inside shm_open() and mmap will succeed in this case. So
the idea is to have shm_close() no-op and therefore symmetrical.
That's look fragile to me. We would silently miss some other
broken open/close pattern.
o My shm_check_vma_validity() also deals with IPC_RMID as we do the
ipc_valid_object() check.
Mine too:
shm_mmap()
__shm_open()
shm_lock()
ipc_lock()
ipc_valid_object()
Or I miss something?
o We have a new WARN where necessary, instead of having one now is shm_open.
I'm not sure why you think that shm_close() which was never paired with
successful shm_open() doesn't deserve WARN().
o My no-ops explicitly pair.
As I said before, I don't think we should ignore locking error in
shm_open(). If we propagate the error back to caller shm_close() should
never happen, therefore no-op is unneeded in shm_close(): my patch trigger
WARN() there.
> ret = sfd->file->f_op->mmap(sfd->file, vma);
>- if (ret != 0)
>+ if (ret) {
>+ shm_close(vma);
> return ret;
>+ }
Hmm what's this shm_close() about?
Undo shp->shm_nattch++ in successful __shm_open().
I've got impression that I miss something important about how locking in
IPC/SHM works, but I cannot grasp what.. Hm?.