A couple of times, I have asked security on the ship AND on my way through the terminal about returning with food.
Saint John and Halifax: I asked port security if I could bring back my lobster roll. They looked at me strangely and told me it would be fine.
In Japan, I asked if I could bring back dried abalone to the ship and back into the US. They told me I would be able to. Just to be sure, I used a translating app to ask the Japanese official. Unfortunately, I could not find any abalone.
It is written in NCL policy that you are not allowed to bring back food (just found this out recently).
I do it all the time from island to island (on a cruise ship). That may be a little different since we remained in the same state. Coco Puffs, mochi, lilikoi pie, cookies, etc.
Meats, dairy, raw fruits/vegetables, raw eggs, and plants with soil are restricted items when leaving the ship and entering a foreign country. It has more to do with agricultural restrictions.
I am not an expert, but do check websites or ask official personnel when traveling. I don't see rice as being an issue. And that is easy to purchase as a sealed product. I suggest that you freeze the bag of rice to kill any insects that were in the bag.