-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
linux.c: don't use pread64 #2048
Conversation
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
Yes, as explained in #2005, this change would break the "glibc, x86, LFS not enabled" case. There is a bit in musl explaining a bit the differences with glibc here: https://wiki.musl-libc.org/faq#Q:-Do-I-need-to-define-%3Ccode%3E_LARGEFILE64_SOURCE%3C/code%3E-to-get-64bit-%3Ccode%3Eoff_t%3C/code%3E? From what I can gather, we have:
The pread64 function is in posix for support of large files, but musl seems to want to deprecate this. This leaves us in a bit of an weird situation:
As detailed in #2005, the issue isn't so much when compiling yara using autotools (since it should set this properly), but rather when using other tools that compile yara, such as yara-rust. If it breaks, it is completely silent as it will still compile, and it can be very annoying to debug. I wonder if the best solution couldn't be something like this:
|
Maybe I'm missing something, but shouldn't |
Yes, it seems yara doesn't use |
I force pushed with two new commits, the first to add a description to This needs testing to be sure |
839d5ee
to
7547f5f
Compare
Adding a config.h does not solve the points i raised about avoiding the use of the 32-bits pread function when autotools is not used. @plusvic any opinions on the changes i suggested? |
Is it possible to test it? Check out the documentation for https://www.gnu.org/software/autoconf/manual/autoconf-2.67/html_node/System-Services.html
These defines get added to |
The issue that I raised is that if autotools are not used, it is very easy to forget to define The config.h is generated by autotools, so this actually reinforces the coupling with autotools. That would force people that do not use autotools (like |
Thanks for elaborating, I understand your concern now and yes another build system would have to replicate the defines and autoconf tests. I am not certain if setting Unfortunately this is not something easily solved outside of using autoconf regardless... |
Regarding your link, it also leads to this: jarun/nnn@db8b618 And defining it in |
I prefer not having to deal with a |
Starting with musl-1.2.4 all LFS64 APIs have been removed since musl is always 64-bit and yara now fails with implicit function declarations for pread64.
Its your call, I removed the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the change. There is still an issue but moving the define should be enough.
I still think adding a static assert would be best to add a safety net. _Static_assert
is C11 though, i don't know if this is an issue. There are tricks to have static asserts without depending on C11, but I don't know where @plusvic stands on this addition or not
@@ -46,6 +46,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |||
#include <yara/proc.h> | |||
#include <yara/strutils.h> | |||
|
|||
#define _FILE_OFFSET_BITS 64 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This does not work, it must be defined before any include for it to have an effect.
This can be confirmed by:
- removing the AC_SYS_LARGEFILE
- adding a
_Static_assert(sizeof(off_t) == 8);
- compiling with
-m32
the static assert fails, indicating the scanning would be invalid.
That's why i was suggesting adding a static assert, it is very easy to break the fix without realizing it.
@@ -145,7 +145,7 @@ AC_ARG_ENABLE([profiling], | |||
AC_ARG_WITH([debug-verbose], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
minor: Since the _FILE_OFFSET_BITS=64
value is defined, we could remove AC_SYS_LARGEFILE from the configure.ac file now
Fixed in 833a580 |
Thank you! And sorry for forgetting about this PR, I had other things distracting me and lost track of it... |
Starting with
musl-1.2.4
all LFS64 APIs have been removed since musl is always 64-bit and yara now fails with implicit function declarations forpread64
.However
configure.ac
already setsAC_SYS_LARGEFILE
so changing them all topread
will work with both glibc and musl.