All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
@ 2020-05-06 13:48 Petr Vorel
  2020-05-06 13:55 ` Cyril Hrubis
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Petr Vorel @ 2020-05-06 13:48 UTC (permalink / raw)
  To: ltp

Signed-off-by: Petr Vorel <pvorel@suse.cz>
---
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

diff --git a/configure.ac b/configure.ac
index e1069b57e..e352e18e8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 \
diff --git a/include/lapi/tty.h b/include/lapi/tty.h
new file mode 100644
index 000000000..353a103f1
--- /dev/null
+++ b/include/lapi/tty.h
@@ -0,0 +1,17 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ * Copyright (c) 2020 Petr Vorel <pvorel@suse.cz>
+ */
+
+#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 */
diff --git a/testcases/kernel/pty/pty04.c b/testcases/kernel/pty/pty04.c
index eaf172504..239d2a870 100644
--- a/testcases/kernel/pty/pty04.c
+++ b/testcases/kernel/pty/pty04.c
@@ -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 8
 
 typedef 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>
-- 
2.26.2


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 13:48 [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1 Petr Vorel
@ 2020-05-06 13:55 ` Cyril Hrubis
  2020-05-06 14:00 ` Jan Stancek
  2020-05-06 15:47 ` Petr Vorel
  2 siblings, 0 replies; 8+ messages in thread
From: Cyril Hrubis @ 2020-05-06 13:55 UTC (permalink / raw)
  To: ltp

Hi!
Looks good, acked.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 13:48 [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1 Petr Vorel
  2020-05-06 13:55 ` Cyril Hrubis
@ 2020-05-06 14:00 ` Jan Stancek
  2020-05-06 14:14   ` Petr Vorel
  2020-05-06 14:45   ` Petr Vorel
  2020-05-06 15:47 ` Petr Vorel
  2 siblings, 2 replies; 8+ messages in thread
From: Jan Stancek @ 2020-05-06 14:00 UTC (permalink / raw)
  To: ltp


----- Original Message -----
> Signed-off-by: Petr Vorel <pvorel@suse.cz>
> ---
> 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
> 

Works for me (rhel6/7), thanks Petr.


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 14:00 ` Jan Stancek
@ 2020-05-06 14:14   ` Petr Vorel
  2020-05-06 14:45   ` Petr Vorel
  1 sibling, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2020-05-06 14:14 UTC (permalink / raw)
  To: ltp


> ----- Original Message -----
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > 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


> Works 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 14:00 ` Jan Stancek
  2020-05-06 14:14   ` Petr Vorel
@ 2020-05-06 14:45   ` Petr Vorel
  1 sibling, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2020-05-06 14:45 UTC (permalink / raw)
  To: ltp

Hi all,

> ----- Original Message -----
> > Signed-off-by: Petr Vorel <pvorel@suse.cz>
> > ---
> > 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


> Works for me (rhel6/7), thanks Petr.

Thanks, Jan, Cyril, pushed.

Kind regards,
Petr

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 13:48 [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1 Petr Vorel
  2020-05-06 13:55 ` Cyril Hrubis
  2020-05-06 14:00 ` Jan Stancek
@ 2020-05-06 15:47 ` Petr Vorel
  2020-05-06 15:56   ` Cyril Hrubis
  2 siblings, 1 reply; 8+ messages in thread
From: Petr Vorel @ 2020-05-06 15:47 UTC (permalink / raw)
  To: ltp

Hi 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

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 15:47 ` Petr Vorel
@ 2020-05-06 15:56   ` Cyril Hrubis
  2020-05-06 16:01     ` Petr Vorel
  0 siblings, 1 reply; 8+ messages in thread
From: Cyril Hrubis @ 2020-05-06 15:56 UTC (permalink / raw)
  To: ltp

Hi!
> 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)));
> };

These two structures are for sure incompatible, that should be uint8_t
instead uint32_t.

-- 
Cyril Hrubis
chrubis@suse.cz

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1
  2020-05-06 15:56   ` Cyril Hrubis
@ 2020-05-06 16:01     ` Petr Vorel
  0 siblings, 0 replies; 8+ messages in thread
From: Petr Vorel @ 2020-05-06 16:01 UTC (permalink / raw)
  To: ltp

> Hi!
> > 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)));
> > };

> These two structures are for sure incompatible, that should be uint8_t
> instead uint32_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

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2020-05-06 16:01 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-06 13:48 [LTP] [PATCH 1/1] pty04: Fix build for kernel headers < v4.2-rc1 Petr Vorel
2020-05-06 13:55 ` Cyril Hrubis
2020-05-06 14:00 ` Jan Stancek
2020-05-06 14:14   ` Petr Vorel
2020-05-06 14:45   ` Petr Vorel
2020-05-06 15:47 ` Petr Vorel
2020-05-06 15:56   ` Cyril Hrubis
2020-05-06 16:01     ` Petr Vorel

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.