Message ID | 20220207113338.214748-4-jiaxun.yang@flygoat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | backports: Backport some ath11k runtime dependencies | expand |
On 2/7/22 12:33, Jiaxun Yang wrote: > Backport them from 5.15, they are required by QRTR. > > Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> > --- > backport/backport-include/linux/netdevice.h | 5 +++ > backport/compat/Makefile | 1 + > backport/compat/backport-5.15.c | 47 +++++++++++++++++++++ > 3 files changed, 53 insertions(+) > create mode 100644 backport/compat/backport-5.15.c > > diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h > index 22942398..4e553791 100644 > --- a/backport/backport-include/linux/netdevice.h > +++ b/backport/backport-include/linux/netdevice.h > @@ -152,6 +152,11 @@ bp_dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s); > #endif /* < 4.11 */ > > #if LINUX_VERSION_IS_LESS(5,15,0) > +#define get_user_ifreq LINUX_BACKPORT(get_user_ifreq) > +int get_user_ifreq(struct ifreq *ifr, void __user **ifrdata, void __user *arg); > +#define put_user_ifreq LINUX_BACKPORT(put_user_ifreq) > +int put_user_ifreq(struct ifreq *ifr, void __user *arg); > + > static inline void backport_dev_put(struct net_device *dev) > { > if (dev) > diff --git a/backport/compat/Makefile b/backport/compat/Makefile > index 2761e5f5..b9f1dee9 100644 > --- a/backport/compat/Makefile > +++ b/backport/compat/Makefile > @@ -20,6 +20,7 @@ compat-$(CPTCFG_KERNEL_5_5) += backport-5.5.o > compat-$(CPTCFG_KERNEL_5_10) += backport-5.10.o > compat-$(CPTCFG_KERNEL_5_11) += backport-5.11.o > compat-$(CPTCFG_KERNEL_5_13) += backport-5.13.o > +compat-$(CPTCFG_KERNEL_5_15) += backport-5.15.o > > compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/verify.o > compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7.asn1.o > diff --git a/backport/compat/backport-5.15.c b/backport/compat/backport-5.15.c > new file mode 100644 > index 00000000..cc0a48fd > --- /dev/null > +++ b/backport/compat/backport-5.15.c > @@ -0,0 +1,47 @@ > +// SPDX-License-Identifier: GPL-2.0 > + > +#include <linux/compat.h> > +#include <linux/export.h> > +#include <linux/uaccess.h> > +#include <linux/netdevice.h> > + > +#include <uapi/linux/if.h> > + > +int get_user_ifreq(struct ifreq *ifr, void __user **ifrdata, void __user *arg) > +{ > + if (in_compat_syscall()) { in_compat_syscall() is not available on kernel <= 4.5 and the compilation fails. get_user_ifreq() and put_user_ifreq() are only needed for QRTR which is only added for kernel >= 5.2. Please add "#if LINUX_VERSION_IS_GEQ(4,6,0)" here and "#if LINUX_VERSION_IN_RANGE(4,6,0, 5,15,0)" to the header file. I will do it when applying the patch. Hauke -- To unsubscribe from this list: send the line "unsubscribe backports" in
diff --git a/backport/backport-include/linux/netdevice.h b/backport/backport-include/linux/netdevice.h index 22942398..4e553791 100644 --- a/backport/backport-include/linux/netdevice.h +++ b/backport/backport-include/linux/netdevice.h @@ -152,6 +152,11 @@ bp_dev_get_tstats64(struct net_device *dev, struct rtnl_link_stats64 *s); #endif /* < 4.11 */ #if LINUX_VERSION_IS_LESS(5,15,0) +#define get_user_ifreq LINUX_BACKPORT(get_user_ifreq) +int get_user_ifreq(struct ifreq *ifr, void __user **ifrdata, void __user *arg); +#define put_user_ifreq LINUX_BACKPORT(put_user_ifreq) +int put_user_ifreq(struct ifreq *ifr, void __user *arg); + static inline void backport_dev_put(struct net_device *dev) { if (dev) diff --git a/backport/compat/Makefile b/backport/compat/Makefile index 2761e5f5..b9f1dee9 100644 --- a/backport/compat/Makefile +++ b/backport/compat/Makefile @@ -20,6 +20,7 @@ compat-$(CPTCFG_KERNEL_5_5) += backport-5.5.o compat-$(CPTCFG_KERNEL_5_10) += backport-5.10.o compat-$(CPTCFG_KERNEL_5_11) += backport-5.11.o compat-$(CPTCFG_KERNEL_5_13) += backport-5.13.o +compat-$(CPTCFG_KERNEL_5_15) += backport-5.15.o compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/verify.o compat-$(CPTCFG_BPAUTO_BUILD_SYSTEM_DATA_VERIFICATION) += verification/pkcs7.asn1.o diff --git a/backport/compat/backport-5.15.c b/backport/compat/backport-5.15.c new file mode 100644 index 00000000..cc0a48fd --- /dev/null +++ b/backport/compat/backport-5.15.c @@ -0,0 +1,47 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include <linux/compat.h> +#include <linux/export.h> +#include <linux/uaccess.h> +#include <linux/netdevice.h> + +#include <uapi/linux/if.h> + +int get_user_ifreq(struct ifreq *ifr, void __user **ifrdata, void __user *arg) +{ + if (in_compat_syscall()) { + struct compat_ifreq *ifr32 = (struct compat_ifreq *)ifr; + + memset(ifr, 0, sizeof(*ifr)); + if (copy_from_user(ifr32, arg, sizeof(*ifr32))) + return -EFAULT; + + if (ifrdata) + *ifrdata = compat_ptr(ifr32->ifr_data); + + return 0; + } + + if (copy_from_user(ifr, arg, sizeof(*ifr))) + return -EFAULT; + + if (ifrdata) + *ifrdata = ifr->ifr_data; + + return 0; +} +EXPORT_SYMBOL(get_user_ifreq); + +int put_user_ifreq(struct ifreq *ifr, void __user *arg) +{ + size_t size = sizeof(*ifr); + + if (in_compat_syscall()) + size = sizeof(struct compat_ifreq); + + if (copy_to_user(arg, ifr, size)) + return -EFAULT; + + return 0; +} +EXPORT_SYMBOL(put_user_ifreq);
Backport them from 5.15, they are required by QRTR. Signed-off-by: Jiaxun Yang <jiaxun.yang@flygoat.com> --- backport/backport-include/linux/netdevice.h | 5 +++ backport/compat/Makefile | 1 + backport/compat/backport-5.15.c | 47 +++++++++++++++++++++ 3 files changed, 53 insertions(+) create mode 100644 backport/compat/backport-5.15.c