I've invariably found my problem to arise from some sort of mismatch in the field(s) of a file's ID3v1 & ID3v2 tags.
Here's the manual workaround that's worked for me since my music files come from multiple sources. Not all steps were always required, but if you do them all, I have not seen this fix fail yet so it's been universal.
1) Make sure iTunes currently shows the song to have the genre you want. For example, if iTunes shows the genre to be '17', right click on the song and select 'Get Info' to manually change the genre to 'Rock' or whatever you want it to be.
2) Save a copy of the music file in question. For example, left click hold and drag it to your desktop to make a copy of the song there.
3) Delete the file from iTunes.
4) Use a program of your choice that allows you to edit the tags of the file on your desktop so that the ID3v1 tag fields all match the ID3v2 files EXACTLY and save your edits. (I use WinAmp for one off songs because it has a simple tag copy button for this, but you can search for mp3 bulk tag editors if you need to fix many songs).
5) Left click-drag the file back into your open iTunes program (or manually from iTunes by left-clicking "File->Add File to Library..." or Control-o).
6) You can now delete the edited file copy from your desktop, if you wish, once you've imported the fixed file into iTunes.
7) If the genre now displays the correct genre, try playing the mp3 in iTunes to see if iTunes doesnt change the genre again. I've seen it change the fixed file genre from 'Rock' to '17' still upon the first play after doing all this. If it does change the genre to '17' or if it displayed as '17' when you first imported the new fixed file, all you need to do is left-click the file and choose 'Get Info' and change the genre from '17' to 'Rock' and try playing it again. You should find it will not change it back to '17' ever again even if it had the initial bad genre.
You could probably update your entirely library at once if you have the patience or not many songs, but I have so many mp3 songs that I just fix them as I find them. It's usually a one off song or an entire album that needs fixing.
Like I said, some steps may not be completely necessary depending on your file & its tag issue, but doing all the steps guarantees you dont have to go back and keep figuring out which steps you do or do not need and so it's covered all cases I've come across in my library.