What is the best way to close gaps between a chimney and roof from the inside?
Pretty much any fix that you attempt from the inside has the potential to create issues in addition to the primary problem, which is that your chimney isn't properly flashed.  Spraying foam or shooting caulking/tar into the gap is very likely to create water traps somewhere in the roof decking, most likely underneath the existing flashing. You would basically be hiding the problem more than correcting it, and could also make it more difficult to fix the underlying issue in future. I would strongly recommend having the flashing corrected.