[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1415289393-30008-1-git-send-email-jslaby@suse.cz>
Date: Thu, 6 Nov 2014 16:56:33 +0100
From: Jiri Slaby <jslaby@...e.cz>
To: gregkh@...uxfoundation.org
Cc: linux-serial@...r.kernel.org, linux-kernel@...r.kernel.org,
Jiri Slaby <jslaby@...e.cz>,
Peter Hurley <peter@...leysoftware.com>,
Alan Cox <gnomes@...rguk.ukuu.org.uk>
Subject: [PATCH 1/1] tty: warn on deprecated serial flags
When somebody calls TIOCSSERIAL ioctl with serial flags to set one of
* ASYNC_SESSION_LOCKOUT
* ASYNC_PGRP_LOCKOUT
* ASYNC_CALLOUT_NOHUP
* ASYNC_AUTOPROBE
nothing happens. We actually ignore the flags for over a decade at
least (I checked 2.6.0).
So start yelling at users who use those flags, that they shouldn't.
Signed-off-by: Jiri Slaby <jslaby@...e.cz>
Cc: Peter Hurley <peter@...leysoftware.com>
Cc: Alan Cox <gnomes@...rguk.ukuu.org.uk>
---
drivers/tty/tty_io.c | 21 +++++++++++++++++++++
include/uapi/linux/tty_flags.h | 2 ++
2 files changed, 23 insertions(+)
diff --git a/drivers/tty/tty_io.c b/drivers/tty/tty_io.c
index 1107398a545c..95f330282046 100644
--- a/drivers/tty/tty_io.c
+++ b/drivers/tty/tty_io.c
@@ -2728,6 +2728,24 @@ struct tty_struct *tty_pair_get_pty(struct tty_struct *tty)
}
EXPORT_SYMBOL(tty_pair_get_pty);
+static void tty_warn_deprecated_flags(struct serial_struct __user *ss)
+{
+ static DEFINE_RATELIMIT_STATE(depr_flags,
+ DEFAULT_RATELIMIT_INTERVAL,
+ DEFAULT_RATELIMIT_BURST);
+ char comm[TASK_COMM_LEN];
+ int flags;
+
+ if (get_user(flags, &ss->flags))
+ return;
+
+ flags &= ASYNC_DEPRECATED;
+
+ if (flags && __ratelimit(&depr_flags))
+ pr_warning("%s: '%s' is using deprecated serial flags (with no effect): %.8x\n",
+ __func__, get_task_comm(comm, current), flags);
+}
+
/*
* Split this up, as gcc can choke on it otherwise..
*/
@@ -2859,6 +2877,9 @@ long tty_ioctl(struct file *file, unsigned int cmd, unsigned long arg)
break;
}
break;
+ case TIOCSSERIAL:
+ tty_warn_deprecated_flags(p);
+ break;
}
if (tty->ops->ioctl) {
retval = (tty->ops->ioctl)(tty, cmd, arg);
diff --git a/include/uapi/linux/tty_flags.h b/include/uapi/linux/tty_flags.h
index eefcb483a2c0..879b91713e7c 100644
--- a/include/uapi/linux/tty_flags.h
+++ b/include/uapi/linux/tty_flags.h
@@ -59,6 +59,8 @@
#define ASYNC_AUTOPROBE (1U << ASYNCB_AUTOPROBE)
#define ASYNC_FLAGS ((1U << (ASYNCB_LAST_USER + 1)) - 1)
+#define ASYNC_DEPRECATED (ASYNC_SESSION_LOCKOUT | ASYNC_PGRP_LOCKOUT | \
+ ASYNC_CALLOUT_NOHUP | ASYNC_AUTOPROBE)
#define ASYNC_USR_MASK (ASYNC_SPD_MASK|ASYNC_CALLOUT_NOHUP| \
ASYNC_LOW_LATENCY)
#define ASYNC_SPD_CUST (ASYNC_SPD_HI|ASYNC_SPD_VHI)
--
2.1.2
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists