aboutsummaryrefslogtreecommitdiff
path: root/include/rdma/ib.h
diff options
context:
space:
mode:
authorAlex Shi <alex.shi@linaro.org>2016-05-24 12:17:46 +0800
committerAlex Shi <alex.shi@linaro.org>2016-05-24 12:17:46 +0800
commitb5db8c3eefa4d7b7ca7934610356969fa1a4547b (patch)
treefb2cc37b4da4b4611eb9920789a130a6c41af1e7 /include/rdma/ib.h
parent14c737514d0953f05e91103c05e975b3b5c1e469 (diff)
parent6c1be3bf831c5b1f2ba51425315287df2c350633 (diff)
Merge branch 'linux-linaro-lsk-v3.18' into linux-linaro-lsk-v3.18-androidlsk-v3.18-16.05-android
Diffstat (limited to 'include/rdma/ib.h')
-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 */