Hi all, Here is the refcount_t patch and some related bits that I hacked up the past few days while playing with it in order to make it generate less aweful code (on x86_64).
I think we can start by merging the refcount_t and kref patches, the rest can come later if so desired. New here is the Kconfig knob to turn warnings off -- it significantly reduces the generated code while still avoiding the UAF. I added David Howells because both he and hpa have suggested something like try_cmpxchg() in the past.