Law 7.1 - Periods of play:
A match lasts for two equal halves of 45 minutes which may only be reduced if agreed between the referee and the two teams before the start of the match and is in accordance with competition rules.
The referee should only extend the half for time lost during that half due to actions listed under Law 7.3 - Allowance for time lost:
Allowance is made by the referee in each half for all time lost in that half through:
- substitutions
- assessment and/or removal of injured players
- wasting time
- disciplinary sanctions
- stoppages for drinks or other medical reasons permitted by competition rules
- any other cause, including any significant delay to a restart (e.g. goal celebrations)
However, it also states:
The fourth official indicates the minimum additional time decided by the referee at the end of the final minute of each half. The additional time may be increased by the referee but not reduced.
To answer your question:
As far as the Laws of the Game are concerned, the referee may only extend the duration of the match for time lost. Further extensions may only be made if the referee decides that further time has been lost during additional time.