backports.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jiaxun Yang <jiaxun.yang@flygoat.com>
To: hauke@hauke-m.de, mcgrof@kernel.org
Cc: backports@vger.kernel.org, Jiaxun Yang <jiaxun.yang@flygoat.com>
Subject: [PATCH 3/6] backports: backport {get,set}_user_ifreq
Date: Sun,  6 Feb 2022 22:26:53 +0000	[thread overview]
Message-ID: <20220206222656.210655-4-jiaxun.yang@flygoat.com> (raw)
In-Reply-To: <20220206222656.210655-1-jiaxun.yang@flygoat.com>

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()) {
+		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);
-- 
2.35.1

--
To unsubscribe from this list: send the line "unsubscribe backports" in

  parent reply	other threads:[~2022-02-06 22:27 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-06 22:26 [PATCH 0/6] backports: Backport some ath11k runtime dependencies Jiaxun Yang
2022-02-06 22:26 ` [PATCH 1/6] headers: Add MHI stuff to mod_devicetable Jiaxun Yang
2022-02-06 22:26 ` [PATCH 2/6] backports: Add mhi bus driver Jiaxun Yang
2022-02-06 22:26 ` Jiaxun Yang [this message]
2022-02-06 22:26 ` [PATCH 4/6] headers: backport sk_error_report Jiaxun Yang
2022-02-06 22:26 ` [PATCH 5/6] backports: Add QRTR driver Jiaxun Yang
2022-02-06 22:26 ` [PATCH 6/6] defconfigs: Refresh for ath11k Jiaxun Yang
2022-02-06 23:30 ` [PATCH 0/6] backports: Backport some ath11k runtime dependencies Hauke Mehrtens
2022-02-07  1:09   ` Jiaxun Yang
2022-02-07 22:26     ` Hauke Mehrtens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220206222656.210655-4-jiaxun.yang@flygoat.com \
    --to=jiaxun.yang@flygoat.com \
    --cc=backports@vger.kernel.org \
    --cc=hauke@hauke-m.de \
    --cc=mcgrof@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).