Apparently, flour can (should?) be frozen for long-term storage, and would keep indefinitely: https://cooking.stackexchange.com/questions/33890/is-it-okay... (unfortunately that link to University of Nebraska is 404 now).
Long-term grain storage concerns: https://www.agriculture.com/machinery/grain-handling-and-equ... ; as a non-expert, this begs the question of why more climate control is not done, to create indefinite/permanent storage (probably just not economical to do so, but given disruptions like COVID-19, maybe this will change?).