The general rule, according to Maimonides (Laws of Rebels 2:2-3), is that the Sanhedrin would have to be greater in wisdom and number in order to reverse a previous decree:
בֵּית דִּין שֶׁגָּזְרוּ גְּזֵרָה אוֹ תִּקְּנוּ תַּקָּנָה וְהִנְהִיגוּ מִנְהָג וּפָשַׁט הַדָּבָר בְּכָל יִשְׂרָאֵל. וְעָמַד אַחֲרֵיהֶם בֵּית דִּין אַחֵר וּבִקֵּשׁ לְבַטֵּל דְּבָרִים הָרִאשׁוֹנִים וְלַעֲקֹר אוֹתָהּ הַתַּקָּנָה וְאוֹתָהּ הַגְּזֵרָה וְאוֹתוֹ הַמִּנְהָג. אֵינוֹ יָכוֹל עַד שֶׁיִּהְיֶה גָּדוֹל מִן הָרִאשׁוֹנִים בְּחָכְמָה וּבְמִנְיָן. הָיָה גָּדוֹל בְּחָכְמָה אֲבָל לֹא בְּמִנְיָן. בְּמִנְיָן אֲבָל לֹא בְּחָכְמָה. אֵינוֹ יָכוֹל לְבַטֵּל אֶת דְּבָרָיו. אֲפִלּוּ בָּטַל הַטַּעַם שֶׁבִּגְלָלוֹ גָּזְרוּ הָרִאשׁוֹנִים אוֹ הִתְקִינוּ אֵין הָאַחֲרוֹנִים יְכוֹלִין לְבַטֵּל עַד שֶׁיְּהוּ גְּדוֹלִים מֵהֶם. וְהֵיאַךְ יִהְיוּ גְּדוֹלִים מֵהֶם בְּמִנְיָן הוֹאִיל וְכָל בֵּית דִּין וּבֵית דִּין שֶׁל שִׁבְעִים וְאֶחָד הוּא. זֶה מִנְיַן חַכְמֵי הַדּוֹר שֶׁהִסְכִּימוּ וְקִבְּלוּ הַדָּבָר שֶׁאָמְרוּ בֵּית דִּין הַגָּדוֹל וְלֹא חָלְקוּ בּוֹ:
If a Supreme Court issued a decree or enacted an ordinance or introduced a custom, which has become widespread throughout Israel, and a subsequent court desires to abolish the instructions of the predecessors and to eradicate that particular ordinance, decree or custom, it cannot do so, unless it is superior both in wisdom and in number. If it exceeds the other court in wisdom but not in number, or in number but not in wisdom, it cannot annul its instructions. Even if the reason for which the predecessors introduced the decree or ordinance exists no more, the successors cannot revoke anything introduced by the predecessors unless they exceed them. But how can any Supreme Court exceed another in number when each Supreme Court consists of seventy-one members? The reference is to the number of contemporary sages who have agreed to accept the decision of the Supreme Court, or have not opposed it.
בַּמֶּה דְּבָרִים אֲמוּרִים? בִּדְבָרִים שֶׁלֹּא אָסְרוּ אוֹתָן כְּדֵי לַעֲשׂוֹת סְיָג לַתּוֹרָה אֶלָּא כִּשְׁאָר דִּינֵי תּוֹרָה. אֲבָל דְּבָרִים שֶׁרָאוּ בֵּית דִּין לִגְזֹר וּלְאָסְרָן לַעֲשׂוֹת סְיָג אִם פָּשַׁט אִסּוּרָן בְּכָל [יִשְׂרָאֵל] אֵין בֵּית דִּין גָּדוֹל אַחֵר יָכוֹל לְעָקְרָן וּלְהַתִּירָן אֲפִלּוּ הָיָה גָּדוֹל מִן הָרִאשׁוֹנִים:
With what case are we dealing? With matters that they did not prohibit in order to create a fence [protecting from violating the laws] of the Torah, rather like the other laws of the Torah. However, matters that the court saw to decree and prohibit in order to create [such] a fence, if their prohibition has spread in all of Israel, another high court can not uproot and allow [the decreed safeguards] even if it is greater than the original [court that created the safeguard].
Accordingly, according to Maimonides, a greater court can override general enactments as they see fit. Notably, Maimonides concludes his Yad Hachazaka describing the anticipated heights of wisdom reached in the messianic age (Laws of Kings and their Wars 12:5), so the court of that time should qualify for this ability.
Furthermore, in terms of deriving halachos, even a later, lesser court can argue with the judicial interpretation of an earlier, greater one (Rebels 2:1).
With regard to Maimonides' qualifier of Rebels 2:3, it seems possible that he is referring only to the more limited case of a סייג enacted explicitly for all generations. See for instance Avoda Zara 36a which Rav Yosef Kairo in his Kesef Mishna suggests is the Rambam's source for this ruling:
אמר רבה בר בר חנה אמר ר' יוחנן בכל יכול לבטל בית דין דברי בית דין חבירו חוץ משמונה עשר דבר שאפילו יבא אליהו ובית דינו אין שומעין לו
...Rabba bar bar Ḥana said that Rabbi Yoḥanan says: With regard to all issues, a court can void the statements of another court, except the eighteen matters decreed by the students of Beit Shammai, as, even if Elijah and his court were to come and rescind them, one would not listen to him.
My understanding is that these "18 matters" were explicitly and (very) atypically decreed in a manner to prevent their later reversal by a greater court (upon their acceptance by most of Israel). See Tosafoth s.v. והתנן citing the Jerusalem Talmud.