From: Greg Kroah-Hartman Date: Thu, 29 Nov 2018 11:51:44 +0000 (+0100) Subject: 4.19-stable patches X-Git-Tag: v4.19.6~21 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=f6d40d499c8577cc2ab698a05579c89b9a445fca;p=thirdparty%2Fkernel%2Fstable-queue.git 4.19-stable patches added patches: include-linux-pfn_t.h-force-to-be-parsed-as-an-unary-operator.patch tty-wipe-buffer-if-not-echoing-data.patch tty-wipe-buffer.patch --- diff --git a/queue-4.19/include-linux-pfn_t.h-force-to-be-parsed-as-an-unary-operator.patch b/queue-4.19/include-linux-pfn_t.h-force-to-be-parsed-as-an-unary-operator.patch new file mode 100644 index 00000000000..7ea9a656ea9 --- /dev/null +++ b/queue-4.19/include-linux-pfn_t.h-force-to-be-parsed-as-an-unary-operator.patch @@ -0,0 +1,70 @@ +From 4d54954a197175c0dcb3c82af0c0740d0c5f827a Mon Sep 17 00:00:00 2001 +From: Sebastien Boisvert +Date: Fri, 26 Oct 2018 15:02:23 -0700 +Subject: include/linux/pfn_t.h: force '~' to be parsed as an unary operator + +From: Sebastien Boisvert + +commit 4d54954a197175c0dcb3c82af0c0740d0c5f827a upstream. + +Tracing the event "fs_dax:dax_pmd_insert_mapping" with perf produces this +warning: + + [fs_dax:dax_pmd_insert_mapping] unknown op '~' + +It is printed in process_op (tools/lib/traceevent/event-parse.c) because +'~' is parsed as a binary operator. + +perf reads the format of fs_dax:dax_pmd_insert_mapping ("print fmt") from +/sys/kernel/debug/tracing/events/fs_dax/dax_pmd_insert_mapping/format . + +The format contains: + +~(((u64) ~(~(((1UL) << 12)-1))) + ^ + \ interpreted as a binary operator by process_op(). + +This part is generated in the declaration of the event class +dax_pmd_insert_mapping_class in include/trace/events/fs_dax.h : + + __print_flags_u64(__entry->pfn_val & PFN_FLAGS_MASK, "|", + PFN_FLAGS_TRACE), + +This patch adds a pair of parentheses in the declaration of PFN_FLAGS_MASK +to make sure that '~' is parsed as a unary operator by perf. + +The part of the format that was problematic is now: + +~(((u64) (~(~(((1UL) << 12)-1)))) + +Now, all the '~' are parsed as unary operators. + +Link: http://lkml.kernel.org/r/20181021145939.8760-1-sebhtml@videotron.qc.ca +Signed-off-by: Sebastien Boisvert +Acked-by: Dan Williams +Cc: "Steven Rostedt (VMware)" +Cc: Arnaldo Carvalho de Melo +Cc: "Tzvetomir Stoyanov (VMware)" +Cc: Namhyung Kim +Cc: Ross Zwisler +Cc: Elenie Godzaridis +Cc: +Signed-off-by: Andrew Morton +Signed-off-by: Linus Torvalds +Signed-off-by: Greg Kroah-Hartman + +--- + include/linux/pfn_t.h | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +--- a/include/linux/pfn_t.h ++++ b/include/linux/pfn_t.h +@@ -10,7 +10,7 @@ + * PFN_DEV - pfn is not covered by system memmap by default + * PFN_MAP - pfn has a dynamic page mapping established by a device driver + */ +-#define PFN_FLAGS_MASK (((u64) ~PAGE_MASK) << (BITS_PER_LONG_LONG - PAGE_SHIFT)) ++#define PFN_FLAGS_MASK (((u64) (~PAGE_MASK)) << (BITS_PER_LONG_LONG - PAGE_SHIFT)) + #define PFN_SG_CHAIN (1ULL << (BITS_PER_LONG_LONG - 1)) + #define PFN_SG_LAST (1ULL << (BITS_PER_LONG_LONG - 2)) + #define PFN_DEV (1ULL << (BITS_PER_LONG_LONG - 3)) diff --git a/queue-4.19/series b/queue-4.19/series index 57906a7b759..e0d5ff8017b 100644 --- a/queue-4.19/series +++ b/queue-4.19/series @@ -97,3 +97,6 @@ mm-memory_hotplug-check-zone_movable-in-has_unmovabl.patch tmpfs-make-lseek-seek_data-sek_hole-return-enxio-wit.patch mm-page_alloc-check-for-max-order-in-hot-path.patch dax-avoid-losing-wakeup-in-dax_lock_mapping_entry.patch +include-linux-pfn_t.h-force-to-be-parsed-as-an-unary-operator.patch +tty-wipe-buffer.patch +tty-wipe-buffer-if-not-echoing-data.patch diff --git a/queue-4.19/tty-wipe-buffer-if-not-echoing-data.patch b/queue-4.19/tty-wipe-buffer-if-not-echoing-data.patch new file mode 100644 index 00000000000..6cf96f28fb3 --- /dev/null +++ b/queue-4.19/tty-wipe-buffer-if-not-echoing-data.patch @@ -0,0 +1,83 @@ +From b97b3d9fb57860a60592859e332de7759fd54c2e Mon Sep 17 00:00:00 2001 +From: Greg KH +Date: Thu, 4 Oct 2018 11:06:14 -0700 +Subject: tty: wipe buffer if not echoing data + +From: Greg Kroah-Hartman + +commit b97b3d9fb57860a60592859e332de7759fd54c2e upstream. + +If we are not echoing the data to userspace or the console is in icanon +mode, then perhaps it is a "secret" so we should wipe it once we are +done with it. + +This mirrors the logic that the audit code has. + +Reported-by: aszlig +Tested-by: Milan Broz +Tested-by: Daniel Zatovic +Tested-by: aszlig +Cc: Willy Tarreau +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/n_tty.c | 20 +++++++++++++++++--- + 1 file changed, 17 insertions(+), 3 deletions(-) + +--- a/drivers/tty/n_tty.c ++++ b/drivers/tty/n_tty.c +@@ -152,17 +152,28 @@ static inline unsigned char *echo_buf_ad + return &ldata->echo_buf[i & (N_TTY_BUF_SIZE - 1)]; + } + ++/* If we are not echoing the data, perhaps this is a secret so erase it */ ++static void zero_buffer(struct tty_struct *tty, u8 *buffer, int size) ++{ ++ bool icanon = !!L_ICANON(tty); ++ bool no_echo = !L_ECHO(tty); ++ ++ if (icanon && no_echo) ++ memset(buffer, 0x00, size); ++} ++ + static int tty_copy_to_user(struct tty_struct *tty, void __user *to, + size_t tail, size_t n) + { + struct n_tty_data *ldata = tty->disc_data; + size_t size = N_TTY_BUF_SIZE - tail; +- const void *from = read_buf_addr(ldata, tail); ++ void *from = read_buf_addr(ldata, tail); + int uncopied; + + if (n > size) { + tty_audit_add_data(tty, from, size); + uncopied = copy_to_user(to, from, size); ++ zero_buffer(tty, from, size - uncopied); + if (uncopied) + return uncopied; + to += size; +@@ -171,7 +182,9 @@ static int tty_copy_to_user(struct tty_s + } + + tty_audit_add_data(tty, from, n); +- return copy_to_user(to, from, n); ++ uncopied = copy_to_user(to, from, n); ++ zero_buffer(tty, from, n - uncopied); ++ return uncopied; + } + + /** +@@ -1960,11 +1973,12 @@ static int copy_from_read_buf(struct tty + n = min(head - ldata->read_tail, N_TTY_BUF_SIZE - tail); + n = min(*nr, n); + if (n) { +- const unsigned char *from = read_buf_addr(ldata, tail); ++ unsigned char *from = read_buf_addr(ldata, tail); + retval = copy_to_user(*b, from, n); + n -= retval; + is_eof = n == 1 && *from == EOF_CHAR(tty); + tty_audit_add_data(tty, from, n); ++ zero_buffer(tty, from, n); + smp_store_release(&ldata->read_tail, ldata->read_tail + n); + /* Turn single EOF into zero-length read */ + if (L_EXTPROC(tty) && ldata->icanon && is_eof && diff --git a/queue-4.19/tty-wipe-buffer.patch b/queue-4.19/tty-wipe-buffer.patch new file mode 100644 index 00000000000..1f10567fec3 --- /dev/null +++ b/queue-4.19/tty-wipe-buffer.patch @@ -0,0 +1,41 @@ +From c9a8e5fce009e3c601a43c49ea9dbcb25d1ffac5 Mon Sep 17 00:00:00 2001 +From: Linus Torvalds +Date: Thu, 4 Oct 2018 11:06:13 -0700 +Subject: tty: wipe buffer. + +From: Linus Torvalds + +commit c9a8e5fce009e3c601a43c49ea9dbcb25d1ffac5 upstream. + +After we are done with the tty buffer, zero it out. + +Reported-by: aszlig +Tested-by: Milan Broz +Tested-by: Daniel Zatovic +Tested-by: aszlig +Cc: Willy Tarreau +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/tty/tty_buffer.c | 6 +++++- + 1 file changed, 5 insertions(+), 1 deletion(-) + +--- a/drivers/tty/tty_buffer.c ++++ b/drivers/tty/tty_buffer.c +@@ -468,11 +468,15 @@ receive_buf(struct tty_port *port, struc + { + unsigned char *p = char_buf_ptr(head, head->read); + char *f = NULL; ++ int n; + + if (~head->flags & TTYB_NORMAL) + f = flag_buf_ptr(head, head->read); + +- return port->client_ops->receive_buf(port, p, f, count); ++ n = port->client_ops->receive_buf(port, p, f, count); ++ if (n > 0) ++ memset(p, 0, n); ++ return n; + } + + /**