Skip to content
  • Aleksandar Markovic's avatar
    da2c8ad7
    linux-user: Fix syslog() syscall support · da2c8ad7
    Aleksandar Markovic authored
    There are currently several problems related to syslog() support.
    
    For example, if the second argument "bufp" of target syslog() syscall
    is NULL, the current implementation always returns error code EFAULT.
    However, NULL is a perfectly valid value for the second argument for
    many use cases of this syscall. This is, for example, visible from
    this excerpt of man page for syslog(2):
    
    > EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
    >        NULL, or len is less than zero; or for type 8, the level is
    >        outside the range 1 to 8).
    
    Moreover, the argument "bufp" is ignored for all cases of values of the
    first argument, except 2, 3 and 4. This means that for such cases
    (the first argument is not 2, 3 or 4), there is no need to pass "buf"
    between host and target, and it can be set to NULL while calling host's
    syslog(), without loss of emulation accuracy.
    
    Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the
    correct returned error code is EINVAL, not EFAULT.
    
    All these details are reflected in this patch.
    
    "#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
    
    Support for Qemu's "-strace" switch for syslog() syscall is included too.
    
    LTP tests syslog11 and syslog12 pass with this patch (while fail without
    it), on any platform.
    
    Changes to original patch by Riku Voipio:
    
     fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match
    
    http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335
    
    Should fix also the build error in:
    
    https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html
    
    
    
    Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
    Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
    da2c8ad7
    linux-user: Fix syslog() syscall support
    Aleksandar Markovic authored
    There are currently several problems related to syslog() support.
    
    For example, if the second argument "bufp" of target syslog() syscall
    is NULL, the current implementation always returns error code EFAULT.
    However, NULL is a perfectly valid value for the second argument for
    many use cases of this syscall. This is, for example, visible from
    this excerpt of man page for syslog(2):
    
    > EINVAL Bad arguments (e.g., bad type; or for type 2, 3, or 4, buf is
    >        NULL, or len is less than zero; or for type 8, the level is
    >        outside the range 1 to 8).
    
    Moreover, the argument "bufp" is ignored for all cases of values of the
    first argument, except 2, 3 and 4. This means that for such cases
    (the first argument is not 2, 3 or 4), there is no need to pass "buf"
    between host and target, and it can be set to NULL while calling host's
    syslog(), without loss of emulation accuracy.
    
    Note also that if "bufp" is NULL and the first argument is 2, 3 or 4, the
    correct returned error code is EINVAL, not EFAULT.
    
    All these details are reflected in this patch.
    
    "#ifdef TARGET_NR_syslog" is also proprerly inserted when needed.
    
    Support for Qemu's "-strace" switch for syslog() syscall is included too.
    
    LTP tests syslog11 and syslog12 pass with this patch (while fail without
    it), on any platform.
    
    Changes to original patch by Riku Voipio:
    
     fixed error paths in TARGET_SYSLOG_ACTION_READ_ALL to match
    
    http://lxr.free-electrons.com/source/kernel/printk/printk.c?v=4.7#L1335
    
    Should fix also the build error in:
    
    https://lists.gnu.org/archive/html/qemu-devel/2016-10/msg03721.html
    
    
    
    Signed-off-by: default avatarAleksandar Markovic <aleksandar.markovic@imgtec.com>
    Signed-off-by: default avatarRiku Voipio <riku.voipio@linaro.org>
Loading