]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] cec: add flag to cec_log_addrs to enable RC passthrough
authorHans Verkuil <hans.verkuil@cisco.com>
Tue, 1 Nov 2016 09:59:34 +0000 (07:59 -0200)
committerMauro Carvalho Chehab <mchehab@s-opensource.com>
Wed, 16 Nov 2016 17:32:07 +0000 (15:32 -0200)
By default the CEC_MSG_USER_CONTROL_PRESSED/RELEASED messages
are passed on to the follower(s) only. If the new
CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU flag is set in the
flags field of struct cec_log_addrs then these messages are also
passed on to the remote control input subsystem and they will appear
as keystrokes.

This used to be the default behavior, but now you have to explicitly
enable it. This is done to force the caller to think about possible
security issues (e.g. if these messages are used to enter passwords).

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@s-opensource.com>
Documentation/media/uapi/cec/cec-ioc-adap-g-log-addrs.rst
drivers/staging/media/cec/TODO
drivers/staging/media/cec/cec-adap.c
drivers/staging/media/cec/cec-api.c
include/linux/cec.h

index af35f71854396a332fc1437c51777c0521632324..571ae57b75aea7da56d6a749f40544c59c0b0d63 100644 (file)
@@ -166,6 +166,16 @@ logical address types are already defined will return with error ``EBUSY``.
        it will go back to the unconfigured state. If this flag is set, then it will
        fallback to the Unregistered logical address. Note that if the Unregistered
        logical address was explicitly requested, then this flag has no effect.
+    * .. _`CEC-LOG-ADDRS-FL-ALLOW-RC-PASSTHRU`:
+
+      - ``CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU``
+      - 2
+      - By default the ``CEC_MSG_USER_CONTROL_PRESSED`` and ``CEC_MSG_USER_CONTROL_RELEASED``
+        messages are only passed on to the follower(s), if any. If this flag is set,
+       then these messages are also passed on to the remote control input subsystem
+       and will appear as keystrokes. This features needs to be enabled explicitly.
+       If CEC is used to enter e.g. passwords, then you may not want to enable this
+       to avoid trivial snooping of the keystrokes.
 
 .. tabularcolumns:: |p{6.6cm}|p{2.2cm}|p{8.7cm}|
 
index 13224694a8aef5e8bf5f48dc57cb40e9b70ae6b0..084120687d0635016a2ca9e261676352d440b60e 100644 (file)
@@ -13,8 +13,6 @@ Hopefully this will happen later in 2016.
 Other TODOs:
 
 - There are two possible replies to CEC_MSG_INITIATE_ARC. How to handle that?
-- Add a flag to inhibit passing CEC RC messages to the rc subsystem.
-  Applications should be able to choose this when calling S_LOG_ADDRS.
 - If the reply field of cec_msg is set then when the reply arrives it
   is only sent to the filehandle that transmitted the original message
   and not to any followers. Should this behavior change or perhaps
index 611e07b78bfec4a353271e1e9b57ead057dc1137..589e4576fbe965bd996a9d7c2976fdc5ac44dae1 100644 (file)
@@ -1478,7 +1478,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
        }
 
        case CEC_MSG_USER_CONTROL_PRESSED:
-               if (!(adap->capabilities & CEC_CAP_RC))
+               if (!(adap->capabilities & CEC_CAP_RC) ||
+                   !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
                        break;
 
 #if IS_REACHABLE(CONFIG_RC_CORE)
@@ -1515,7 +1516,8 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
                break;
 
        case CEC_MSG_USER_CONTROL_RELEASED:
-               if (!(adap->capabilities & CEC_CAP_RC))
+               if (!(adap->capabilities & CEC_CAP_RC) ||
+                   !(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
                        break;
 #if IS_REACHABLE(CONFIG_RC_CORE)
                rc_keyup(adap->rc);
index e274e2f223986bc4ed075447c9a17186b5de0dae..040ca7ddf2b00f40978eec31b1886fb02f5a293b 100644 (file)
@@ -162,7 +162,8 @@ static long cec_adap_s_log_addrs(struct cec_adapter *adap, struct cec_fh *fh,
                return -ENOTTY;
        if (copy_from_user(&log_addrs, parg, sizeof(log_addrs)))
                return -EFAULT;
-       log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK;
+       log_addrs.flags &= CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK |
+                          CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU;
        mutex_lock(&adap->lock);
        if (!adap->is_configuring &&
            (!log_addrs.num_log_addrs || !adap->is_configured) &&
index 851968e803fa416b996bb32b8417b82c312a7ff2..825455fae3ccdb1393c3eb9fe44e9e90860c2a02 100644 (file)
@@ -391,6 +391,8 @@ struct cec_log_addrs {
 
 /* Allow a fallback to unregistered */
 #define CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK  (1 << 0)
+/* Passthrough RC messages to the input subsystem */
+#define CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU     (1 << 1)
 
 /* Events */