summaryrefslogtreecommitdiff
path: root/include/rdma
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2016-04-28 15:16:32 -0400
committerDoug Ledford <dledford@redhat.com>2016-04-28 15:16:32 -0400
commite29bff46b9b8663e1789fbcd65d0ba05a52f08af (patch)
treecce17191cf20c60dc917c62f01d96f6b571a47d4 /include/rdma
parentd53e181c85effdfdec97a760622330626c922d81 (diff)
parente6bd18f57aad1a2d1ef40e646d03ed0f2515c9e3 (diff)
Merge branch 'k.o/for-4.6-rc' into testing/4.6
Diffstat (limited to 'include/rdma')
-rw-r--r--include/rdma/ib.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/include/rdma/ib.h b/include/rdma/ib.h
index cf8f9e700e48..a6b93706b0fc 100644
--- a/include/rdma/ib.h
+++ b/include/rdma/ib.h
@@ -34,6 +34,7 @@
#define _RDMA_IB_H
#include <linux/types.h>
+#include <linux/sched.h>
struct ib_addr {
union {
@@ -86,4 +87,19 @@ struct sockaddr_ib {
__u64 sib_scope_id;
};
+/*
+ * The IB interfaces that use write() as bi-directional ioctl() are
+ * fundamentally unsafe, since there are lots of ways to trigger "write()"
+ * calls from various contexts with elevated privileges. That includes the
+ * traditional suid executable error message writes, but also various kernel
+ * interfaces that can write to file descriptors.
+ *
+ * This function provides protection for the legacy API by restricting the
+ * calling context.
+ */
+static inline bool ib_safe_file_access(struct file *filp)
+{
+ return filp->f_cred == current_cred() && segment_eq(get_fs(), USER_DS);
+}
+
#endif /* _RDMA_IB_H */