pty04: Fix build for kernel headers < v4.2-rc1
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
---
https://travis-ci.org/github/pevik/ltp/builds/683787204
configure.ac | 1 + include/lapi/tty.h | 17 +++++++++++++++++ testcases/kernel/pty/pty04.c | 17 ++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 include/lapi/tty.h
configure.ac +1 -0
@@ -55,6 +55,7 @@ AC_CHECK_HEADERS([ \ linux/netlink.h \ linux/seccomp.h \ linux/securebits.h \ + linux/tty.h \ linux/types.h \ linux/userfaultfd.h \ mm.h \
include/lapi/tty.h new file +17 -0
@@ -0,0 +1,17 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* +* Copyright (c) 2020 Petr Vorel <[email protected]> +*/ + +#ifndef LAPI_TTY_H +#define LAPI_TTY_H + +#ifdef HAVE_LINUX_TTY_H +# include <linux/tty.h> +#endif + +#ifndef N_SLCAN +# define N_SLCAN 17/* Serial / USB serial CAN Adaptors */ +#endif + +#endif /* LAPI_TTY_H */
testcases/kernel/pty/pty04.c +10 -7
@@ -34,9 +34,10 @@*/ #define _GNU_SOURCE +#include "config.h" #include "tst_test.h" #include "tst_buffers.h" -#include "config.h" +#include "lapi/tty.h" #if defined(HAVE_LINUX_IF_PACKET_H ) && defined(HAVE_LINUX_IF_ETHER_H )
@@ -44,11 +45,14 @@#include <linux/if_ether.h> #include <linux/tty.h> -#ifdef HAVE_LINUX_CAN_H -# include <linux/can.h> -#else -# define CAN_MTU 16 -# define CAN_MAX_DLEN 8 +/* +* define instead of including <linux/can.h> to support kernel headers +* before change from v4.2-rc1 +* a2f11835994e ("can.h: make padding given by gcc explicit"). +*/ + +#define CAN_MTU 16 +#define CAN_MAX_DLEN 8typedef uint32_t canid_t ;
@@ -60,7 +64,6 @@ struct can_frame {uint32_t __res1; uint32_t data[CAN_MAX_DLEN] __attribute__((aligned(8))); }; -#endif #include <stddef.h> #include <stdlib.h>
Signature · 1 line
2.26.2
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
Hi!
Looks good, acked.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
In reply to Petr Vorel----- Original Message -----
Quoted 10 lines
Signed-off-by Petr Vorel <[email protected]>---
https://travis-ci.org/github/pevik/ltp/builds/683787204configure.ac | 1 + include/lapi/tty.h | 17 +++++++++++++++++ testcases/kernel/pty/pty04.c | 17 ++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 include/lapi/tty.h
Works for me (rhel6/7), thanks Petr.
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
Quoted 6 lines
----- Original Message -----
Quoted 3 lines
Signed-off-by Petr Vorel <[email protected]>
Quoted 8 lines
Quoted 5 lines
configure.ac | 1 + include/lapi/tty.h | 17 +++++++++++++++++ testcases/kernel/pty/pty04.c | 17 ++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 include/lapi/tty.hWorks for me (rhel6/7), thanks Petr.
OK, I'll merge with your ack and Cyril's and Richard's suggestion.
I want to fix minimal version as well. Works well on our 3.0 kernel. Other kernel has a problem 2.6.32-696.el6.x86_64, but IMHO that does not mean that the test is not valid for this kernel.
./pty04
tst_test.c:1246: INFO: Timeout per run is 0h 05m 00s pty04.c:95: INFO: PTS path is /dev/pts/1
pty04.c:149: INFO: Netdev is sl0
pty04.c:158: INFO: Netdev MTU is 8192 (we set 8192) pty04.c:175: INFO: Bound netdev 5 to socket 5 pty04.c:208: INFO: Reading from socket 5
pty04.c:123: PASS: Wrote PTY 1
pty04.c:133: PASS: Wrote PTY 2
pty04.c:213: PASS: Read netdev 1
pty04.c:217: PASS: Read netdev 2
pty04.c:249: BROK: ioctl(4,TIOCVHANGUP,...) failed: EINVAL (22) tst_test.c:373: BROK: Reported by child (12112)
Can please anybody double check, that with this patch it should be possible to run this test even on v2.6.25 (which added can module)?
Kind regards,
Petr
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
In reply to Jan StancekHi all,
Quoted 5 lines
----- Original Message -----
Quoted 3 lines
Signed-off-by Petr Vorel <[email protected]>
Quoted 8 lines
Quoted 5 lines
configure.ac | 1 + include/lapi/tty.h | 17 +++++++++++++++++ testcases/kernel/pty/pty04.c | 17 ++++++++++------- 3 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 include/lapi/tty.hWorks for me (rhel6/7), thanks Petr.
Thanks, Jan, Cyril, pushed.
Kind regards,
Petr
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
In reply to Petr VorelHi all,
The struct added in 6b6b56cf3 ("pty04: Add SLCAN ldisc and check for CVE-2020-11494") uses uint32_t, kernel version always used __u8. Richie, any reason to use uint32_t instead of uint8_t? I does not fixes the problem, I'm just asking, whether different size affect test coverage.
struct can_frame {
canid_t can_id;
uint32_t can_dlc;
uint32_t __pad;
uint32_t __res0;
uint32_t __res1;
uint32_t data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};struct can_frame {
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
__u8 __pad; /* padding */
__u8 __res0; /* reserved / padding */
__u8 __res1; /* reserved / padding */
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};Kind regards,
Petr
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
Hi!
Quoted 14 lines
The struct added in
6b6b56cf3("pty04: Add SLCAN ldisc and check for CVE-2020-11494") usesuint32_t, kernel version always used__u8. Richie, any reason to useuint32_tinstead ofuint8_t? I does not fixes the problem, I'm just asking, whether different size affect test coverage.struct can_frame { canid_t can_id; uint32_t can_dlc; uint32_t __pad; uint32_t __res0; uint32_t __res1; uint32_t data[CAN_MAX_DLEN] __attribute__((aligned(8))); };
Quoted 8 lines
struct can_frame {
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
__u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
__u8 __pad; /* padding */
__u8 __res0; /* reserved / padding */
__u8 __res1; /* reserved / padding */
__u8 data[CAN_MAX_DLEN] __attribute__((aligned(8)));
};These two structures are for sure incompatible, that should be uint8_t instead uint32_t.
Signature · 2 lines
Cyril Hrubis [email protected]
PATCH 1/1 pty04: Fix build for kernel headers < v4.2-rc1
Quoted 24 lines
Hi!
Quoted 14 lines
The struct added in
6b6b56cf3("pty04: Add SLCAN ldisc and check for CVE-2020-11494") usesuint32_t, kernel version always used__u8. Richie, any reason to useuint32_tinstead ofuint8_t? I does not fixes the problem, I'm just asking, whether different size affect test coverage.struct can_frame { canid_t can_id; uint32_t can_dlc; uint32_t __pad; uint32_t __res0; uint32_t __res1; uint32_t data[CAN_MAX_DLEN] __attribute__((aligned(8))); };Quoted 8 lines
struct can_frame { canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */ __u8 can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */ __u8 __pad; /* padding */ __u8 __res0; /* reserved / padding */ __u8 __res1; /* reserved / padding */ __u8 data[CAN_MAX_DLEN] __attribute__((aligned(8))); };
Quoted 2 lines
These two structures are for sure incompatible, that should be
uint8_tinsteaduint32_t.
OK I'll fix it.
I also add #define CAN_MTU (sizeof(struct can_frame)), instead of 16 (which
is now correct, but for uint32_t should be 56).
Kind regards,
Petr