Conditional varargs processing for system calls is bad. It causes an ongoing maintenance headache, and weird application issues. For example, Linux 5.7 added MREMAP_DONTUNMAP, and it can use the address argument just like MREMAP_FIXED. But the current mremap implementation always passes NULL as a system call argument. Regression in 2.35 caused by: commit 5b3e31e3124bf89710e5c25176c70fdf66c2a212 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Wed Jun 17 09:29:07 2020 -0300 linux: Implement mremap in C Variadic function calls in syscalls.list does not work for all ABIs (for instance where the argument are passed on the stack instead of registers) and might have underlying issues depending of the variadic type (for instance if a 64-bit argument is used). Checked on x86_64-linux-gnu.
Patch posted: [PATCH] Revert "linux: Implement mremap in C" (bug 31968) <https://inbox.sourceware.org/libc-alpha/87msmqzk2m.fsf@oldenburg.str.redhat.com/>
(In reply to Florian Weimer from comment #1) > Patch posted: > > [PATCH] Revert "linux: Implement mremap in C" (bug 31968) > <https://inbox.sourceware.org/libc-alpha/87msmqzk2m.fsf@oldenburg.str.redhat. > com/> Don't we need a test for MREMAP_DONTUNMAP?
Created attachment 15615 [details] A different patch
A different patch set with tests is at https://patchwork.sourceware.org/project/glibc/list/?series=36193
The master branch has been updated by H.J. Lu <hjl@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=6c40cb0e9f893d49dc7caee580a055de53562206 commit 6c40cb0e9f893d49dc7caee580a055de53562206 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
The release/2.39/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=9f349d02c6065f77b485526b3d76a637f6f079dc commit 9f349d02c6065f77b485526b3d76a637f6f079dc Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
The release/2.40/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=3433a358428bcec2d203fa408b85f442c9a465ca commit 3433a358428bcec2d203fa408b85f442c9a465ca Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
The release/2.38/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=0301637b9931766ee389aedf3899cde756b37283 commit 0301637b9931766ee389aedf3899cde756b37283 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
The release/2.37/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=40fb943e12041190ec38706b1d098fa0ff0910d3 commit 40fb943e12041190ec38706b1d098fa0ff0910d3 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
The release/2.36/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ab482a557d4a34a913b49fad4b3bd3bf7f1d70bd commit ab482a557d4a34a913b49fad4b3bd3bf7f1d70bd Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
The release/2.35/master branch has been updated by Florian Weimer <fw@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=7459b6fe4773ff36d20e6f0890d6e40fbd803ea2 commit 7459b6fe4773ff36d20e6f0890d6e40fbd803ea2 Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Jul 24 14:05:13 2024 -0700 linux: Update the mremap C implementation [BZ #31968] Update the mremap C implementation to support the optional argument for MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct to implement a variadic function as a non-variadic function on all Linux targets. Return MAP_FAILED and set errno to EINVAL for unknown flag bits. This fixes BZ #31968. Note: A test must be added when a new flag bit is introduced. Signed-off-by: H.J. Lu <hjl.tools@gmail.com> Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org> (cherry picked from commit 6c40cb0e9f893d49dc7caee580a055de53562206)
Fixed.