X-Git-Url: https://gerrit.opnfv.org/gerrit/gitweb?a=blobdiff_plain;f=kernel%2Finclude%2Frdma%2Fib.h;fp=kernel%2Finclude%2Frdma%2Fib.h;h=a6b93706b0fc96494d7de3d7408c26fb57436a02;hb=52f993b8e89487ec9ee15a7fb4979e0f09a45b27;hp=cf8f9e700e48939b7633a97df7f815486e0fb8a8;hpb=c189ccac5702322ed843fe17057035b7222a59b6;p=kvmfornfv.git diff --git a/kernel/include/rdma/ib.h b/kernel/include/rdma/ib.h index cf8f9e700..a6b93706b 100644 --- a/kernel/include/rdma/ib.h +++ b/kernel/include/rdma/ib.h @@ -34,6 +34,7 @@ #define _RDMA_IB_H #include +#include 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 */