An inmate has confessed in court to fatally attacking a convicted child sex offender inside a Queensland jail.