Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1363082 > unrolled thread
| Started by | James Simmons <jsimmons@infradead.org> |
|---|---|
| First post | 2016-03-23 00:10 +0100 |
| Last post | 2016-03-23 00:20 +0100 |
| Articles | 20 on this page of 24 — 1 participant |
Back to article view | Back to linux.kernel
[PATCH 00/29] Bring libcfs ioctl handling up to date James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 29/29] staging: lustre: libcfs: return size_t for libcfs_ioctl_packlen James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 28/29] staging: lustre: libcfs: use BIT macro in linux-module.c James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 22/29] staging: lustre: libcfs: removal all userland only macros from libcfs_ioctl.h James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 18/29] staging:lustre: remove the IOC_LIBCFS_MEMHOG ioctl James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 24/29] staging: lustre: libcfs: move function declarations from libcfs_ioctl.h James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 03/29] staging: lustre: libcfs: merge code from libcfs_ioctl into libcfs_ioctl_getdata James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 23/29] staging: lustre: libcfs: migrate inline functions to source file James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 19/29] staging:lustre: remove libcfs_psdev_[open|release] James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 26/29] staging: lustre: libcfs: add uapi headers to libcfs_ioctl.h James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 14/29] staging: lustre: libcfs: remove libcfsutil.h in comment James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 25/29] staging: lustre: libcfs: make libcfs_ioctl.h readable James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 27/29] staging: lustre: libcfs: return proper bool values James Simmons <jsimmons@infradead.org> - 2016-03-23 00:10 +0100
[PATCH 08/29] staging: lustre: libcfs: invert test condition for libcfs_ioctl James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 13/29] staging: lustre: libcfs: change variable name James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 11/29] staging: lustre: lnet: make sure lnet data not greater than LIBCFS_IOC_DATA_MAX James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 04/29] staging: lustre: libcfs: merge libcfs_ioctl_handle into libcfs_ioctl James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 10/29] staging: lustre: libcfs: test if userland data is to small James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 01/29] staging: lustre: libcfs: replace LNET_MAX_IOCTL_BUF_LEN with something bigger James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 02/29] staging: lustre: libcfs: use break in switch options for libcfs_ioctl_handle James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 15/29] staging: lustre: libcfs: move libcfs_ioctl_handler stuff to libcfs.h James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 12/29] staging: lustre: simple cleanup in obd_ioctl_popdata James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 09/29] staging: lustre: libcfs: update error messages in linux-module.c James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
[PATCH 05/29] staging: lustre: libcfs: add debugging info for libcfs_ioctl James Simmons <jsimmons@infradead.org> - 2016-03-23 00:20 +0100
Page 1 of 2 [1] 2 Next page →
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 00/29] Bring libcfs ioctl handling up to date |
| Message-ID | <rfDAZ-310-3@gated-at.bofh.it> |
This brings the upstream libcfs ioctl handling up to date with the latest production code. Most of the work was to make libcfs_ioctl.h a simple uapi header that can be used by user land utilities. Lots of ioctl code cleanup and simplification. James Simmons (9): staging: lustre: libcfs: change variable name staging: lustre: libcfs: removal all userland only macros from libcfs_ioctl.h staging: lustre: libcfs: migrate inline functions to source file staging: lustre: libcfs: move function declarations from libcfs_ioctl.h staging: lustre: libcfs: make libcfs_ioctl.h readable staging: lustre: libcfs: add uapi headers to libcfs_ioctl.h staging: lustre: libcfs: return proper bool values staging: lustre: libcfs: use BIT macro in linux-module.c staging: lustre: libcfs: return size_t for libcfs_ioctl_packlen John L. Hammond (3): staging: lustre: libcfs: remove libcfsutil.h in comment staging: lustre: libcfs: move libcfs_ioctl_handler stuff to libcfs.h staging: lustre: libcfs: remove libcfs_ioctl_popdata wrapper Liang Zhen (12): staging: lustre: libcfs: replace LNET_MAX_IOCTL_BUF_LEN with something bigger staging: lustre: libcfs: use break in switch options for libcfs_ioctl_handle staging: lustre: libcfs: merge code from libcfs_ioctl into libcfs_ioctl_getdata staging: lustre: libcfs: merge libcfs_ioctl_handle into libcfs_ioctl staging: lustre: libcfs: add debugging info for libcfs_ioctl staging: lustre: libcfs: move comment in libcfs_ioctl staging: lustre: libcfs: test if data is NULL staging: lustre: libcfs: invert test condition for libcfs_ioctl staging: lustre: libcfs: update error messages in linux-module.c staging: lustre: libcfs: test if userland data is to small staging: lustre: lnet: make sure lnet data not greater than LIBCFS_IOC_DATA_MAX staging: lustre: simple cleanup in obd_ioctl_popdata Parinay Kondekar (5): staging:lustre: remove last bits of the IOC_LIBCFS_PANIC ioctl staging:lustre: remove the IOC_LIBCFS_MEMHOG ioctl staging:lustre: remove libcfs_psdev_[open|release] staging:lustre: call libcfs_ioctl directly staging:lustre: remove libcfs pseudo device abstraction .../staging/lustre/include/linux/libcfs/libcfs.h | 42 +++--- .../lustre/include/linux/libcfs/libcfs_ioctl.h | 161 +++++--------------- .../lustre/lnet/libcfs/linux/linux-module.c | 154 +++++++++++-------- drivers/staging/lustre/lnet/libcfs/module.c | 125 +++++----------- drivers/staging/lustre/lnet/lnet/api-ni.c | 4 + .../lustre/lustre/obdclass/linux/linux-module.c | 4 +- 6 files changed, 190 insertions(+), 300 deletions(-)
[toc] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 29/29] staging: lustre: libcfs: return size_t for libcfs_ioctl_packlen |
| Message-ID | <rfDAZ-310-19@gated-at.bofh.it> |
| In reply to | #1363082 |
Change return value to size_t.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/lnet/libcfs/linux/linux-module.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index cf191ef..b86e937 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -40,9 +40,9 @@
#define LNET_MINOR 240
-static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
+static inline size_t libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
{
- int len = sizeof(*data);
+ size_t len = sizeof(*data);
len += cfs_size_round(data->ioc_inllen1);
len += cfs_size_round(data->ioc_inllen2);
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 28/29] staging: lustre: libcfs: use BIT macro in linux-module.c |
| Message-ID | <rfDAZ-310-11@gated-at.bofh.it> |
| In reply to | #1363082 |
Use the proper BIT macro for libcfs_ioctl_is_invalid().
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/lnet/libcfs/linux/linux-module.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index d5b7d3a..cf191ef 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -51,15 +51,15 @@ static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
{
- if (data->ioc_hdr.ioc_len > (1 << 30)) {
+ if (data->ioc_hdr.ioc_len > BIT(30)) {
CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
return true;
}
- if (data->ioc_inllen1 > (1<<30)) {
+ if (data->ioc_inllen1 > BIT(30)) {
CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
return true;
}
- if (data->ioc_inllen2 > (1<<30)) {
+ if (data->ioc_inllen2 > BIT(30)) {
CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
return true;
}
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 22/29] staging: lustre: libcfs: removal all userland only macros from libcfs_ioctl.h |
| Message-ID | <rfDB0-310-29@gated-at.bofh.it> |
| In reply to | #1363082 |
All the macros in libcfs_ioctl.h that is needed by user
land have been moved into the lustre utilities software
stack.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 9 ---------
1 files changed, 0 insertions(+), 9 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index 2e4e31b..e109a4b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -76,21 +76,12 @@ struct libcfs_ioctl_data {
char ioc_bulk[0];
};
-#define ioc_priority ioc_u32[0]
-
struct libcfs_debug_ioctl_data {
struct libcfs_ioctl_hdr hdr;
unsigned int subs;
unsigned int debug;
};
-#define LIBCFS_IOC_INIT(data) \
-do { \
- memset(&data, 0, sizeof(data)); \
- data.ioc_version = LIBCFS_IOCTL_VERSION; \
- data.ioc_len = sizeof(data); \
-} while (0)
-
/* FIXME check conflict with lustre_lib.h */
#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long)
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 18/29] staging:lustre: remove the IOC_LIBCFS_MEMHOG ioctl |
| Message-ID | <rfDB0-310-33@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Parinay Kondekar <parinay.kondekar@seagate.com>
The IOC_LIBCFS_MEMHOG is not needed so remove the last bits.
Signed-off-by: Parinay Kondekar <parinay.kondekar@seagate.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5844
Reviewed-on: http://review.whamcloud.com/17492
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index d158cd1..2e4e31b 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -100,7 +100,7 @@ do { \
/* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */
#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, long)
#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, long)
-#define IOC_LIBCFS_MEMHOG _IOWR('e', 36, long)
+/* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
/* lnet ioctls */
#define IOC_LIBCFS_GET_NI _IOWR('e', 50, long)
#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long)
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 24/29] staging: lustre: libcfs: move function declarations from libcfs_ioctl.h |
| Message-ID | <rfDB0-310-31@gated-at.bofh.it> |
| In reply to | #1363082 |
Move the function declartions that are used only by
kernel space to libcfs.h This makes libcfs_ioctl.h
a offical uapi header now.
Move large inline functions out of libcfs_ioctl.h to
the source file linux-module.c belonging to libcfs.
This code is only used by the core of libcfs and such
inline functions don't belong in a uapi header file.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../staging/lustre/include/linux/libcfs/libcfs.h | 3 +++
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 4 ----
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 1cd1879..6a8e0d0 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -112,6 +112,9 @@ struct libcfs_ioctl_handler {
int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
+int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+ const struct libcfs_ioctl_hdr __user *uparam);
+int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
int libcfs_ioctl(unsigned long cmd, void *arg);
/* container_of depends on "likely" which is defined in libcfs_private.h */
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index 3af13e4..c379d29 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -138,8 +138,4 @@ struct libcfs_debug_ioctl_data {
#define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, IOCTL_CONFIG_SIZE)
#define IOC_LIBCFS_MAX_NR 91
-int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
- const struct libcfs_ioctl_hdr __user *uparam);
-int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
-
#endif /* __LIBCFS_IOCTL_H__ */
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 03/29] staging: lustre: libcfs: merge code from libcfs_ioctl into libcfs_ioctl_getdata |
| Message-ID | <rfDB0-310-35@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
This is apart of the cleanup of libcfs_ioctl* code. In this
part some of the code in libcfs_ioctl is migrated into
libcfs_ioctl_getdata_len() which is renamed libcfs_ioctl_getdata()
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 4 +-
.../lustre/lnet/libcfs/linux/linux-module.c | 23 ++++++++++++---
drivers/staging/lustre/lnet/libcfs/module.c | 28 ++-----------------
3 files changed, 23 insertions(+), 32 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index c71d125..9c1deae 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -225,8 +225,8 @@ static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
int libcfs_register_ioctl(struct libcfs_ioctl_handler *hand);
int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand);
-int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg,
- __u32 *buf_len);
+int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+ const struct libcfs_ioctl_hdr __user *uparam);
int libcfs_ioctl_popdata(void __user *arg, void *buf, int size);
int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index ebc60ac..a326ac6 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -57,12 +57,13 @@ int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
return 0;
}
-int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg,
- __u32 *len)
+int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
+ const struct libcfs_ioctl_hdr __user *uhdr)
{
struct libcfs_ioctl_hdr hdr;
+ int err = 0;
- if (copy_from_user(&hdr, arg, sizeof(hdr)))
+ if (copy_from_user(&hdr, uhdr, sizeof(uhdr)))
return -EFAULT;
if (hdr.ioc_version != LIBCFS_IOCTL_VERSION &&
@@ -72,9 +73,21 @@ int libcfs_ioctl_getdata_len(const struct libcfs_ioctl_hdr __user *arg,
return -EINVAL;
}
- *len = hdr.ioc_len;
+ if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) {
+ CERROR("libcfs ioctl: user buffer is too large %d/%d\n",
+ hdr.ioc_len, LIBCFS_IOC_DATA_MAX);
+ return -EINVAL;
+ }
- return 0;
+ LIBCFS_ALLOC(*hdr_pp, hdr.ioc_len);
+ if (!*hdr_pp)
+ return -ENOMEM;
+
+ if (copy_from_user(*hdr_pp, uhdr, hdr.ioc_len)) {
+ LIBCFS_FREE(*hdr_pp, hdr.ioc_len);
+ err = -EFAULT;
+ }
+ return err;
}
int libcfs_ioctl_popdata(void __user *arg, void *data, int size)
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 3fe2810..5a20e53 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -172,36 +172,14 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
{
struct libcfs_ioctl_hdr *hdr;
int err = 0;
- __u32 buf_len;
- err = libcfs_ioctl_getdata_len(arg, &buf_len);
+ /* 'cmd' and permissions get checked in our arch-specific caller */
+ err = libcfs_ioctl_getdata(&hdr, arg);
if (err)
return err;
- /*
- * do a check here to restrict the size of the memory
- * to allocate to guard against DoS attacks.
- */
- if (buf_len > LIBCFS_IOC_DATA_MAX) {
- CERROR("LNET: user buffer exceeds kernel buffer\n");
- return -EINVAL;
- }
-
- LIBCFS_ALLOC_GFP(hdr, buf_len, GFP_KERNEL);
- if (!hdr)
- return -ENOMEM;
-
- /* 'cmd' and permissions get checked in our arch-specific caller */
- if (copy_from_user(hdr, arg, buf_len)) {
- CERROR("LNET ioctl: data error\n");
- err = -EFAULT;
- goto out;
- }
-
err = libcfs_ioctl_handle(pfile, cmd, arg, hdr);
-
-out:
- LIBCFS_FREE(hdr, buf_len);
+ LIBCFS_FREE(hdr, hdr->ioc_len);
return err;
}
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 23/29] staging: lustre: libcfs: migrate inline functions to source file |
| Message-ID | <rfDB0-310-37@gated-at.bofh.it> |
| In reply to | #1363082 |
Move large inline functions out of libcfs_ioctl.h to
the source file linux-module.c belonging to libcfs.
This code is only used by the core of libcfs and such
inline functions don't belong in a uapi header file.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 65 --------------------
.../lustre/lnet/libcfs/linux/linux-module.c | 65 ++++++++++++++++++++
2 files changed, 65 insertions(+), 65 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index e109a4b..3af13e4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -138,71 +138,6 @@ struct libcfs_debug_ioctl_data {
#define IOC_LIBCFS_GET_LNET_STATS _IOWR(IOC_LIBCFS_TYPE, 91, IOCTL_CONFIG_SIZE)
#define IOC_LIBCFS_MAX_NR 91
-static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
-{
- int len = sizeof(*data);
-
- len += cfs_size_round(data->ioc_inllen1);
- len += cfs_size_round(data->ioc_inllen2);
- return len;
-}
-
-static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
-{
- if (data->ioc_hdr.ioc_len > (1 << 30)) {
- CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen1 > (1<<30)) {
- CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inllen2 > (1<<30)) {
- CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
- return 1;
- }
- if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
- CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
- CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf1 && !data->ioc_plen1) {
- CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_pbuf2 && !data->ioc_plen2) {
- CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
- return 1;
- }
- if (data->ioc_plen1 && !data->ioc_pbuf1) {
- CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
- return 1;
- }
- if (data->ioc_plen2 && !data->ioc_pbuf2) {
- CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
- return 1;
- }
- if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
- CERROR("LIBCFS ioctl: packlen != ioc_len\n");
- return 1;
- }
- if (data->ioc_inllen1 &&
- data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
- return 1;
- }
- if (data->ioc_inllen2 &&
- data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
- data->ioc_inllen2 - 1] != '\0') {
- CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
- return 1;
- }
- return 0;
-}
-
int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
const struct libcfs_ioctl_hdr __user *uparam);
int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index 7634551..af19f3c 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -40,6 +40,71 @@
#define LNET_MINOR 240
+static inline int libcfs_ioctl_packlen(struct libcfs_ioctl_data *data)
+{
+ int len = sizeof(*data);
+
+ len += cfs_size_round(data->ioc_inllen1);
+ len += cfs_size_round(data->ioc_inllen2);
+ return len;
+}
+
+static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
+{
+ if (data->ioc_hdr.ioc_len > (1 << 30)) {
+ CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen1 > (1<<30)) {
+ CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inllen2 > (1<<30)) {
+ CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
+ CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
+ CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_pbuf1 && !data->ioc_plen1) {
+ CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_pbuf2 && !data->ioc_plen2) {
+ CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
+ return 1;
+ }
+ if (data->ioc_plen1 && !data->ioc_pbuf1) {
+ CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
+ return 1;
+ }
+ if (data->ioc_plen2 && !data->ioc_pbuf2) {
+ CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
+ return 1;
+ }
+ if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
+ CERROR("LIBCFS ioctl: packlen != ioc_len\n");
+ return 1;
+ }
+ if (data->ioc_inllen1 &&
+ data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
+ CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
+ return 1;
+ }
+ if (data->ioc_inllen2 &&
+ data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
+ data->ioc_inllen2 - 1] != '\0') {
+ CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
+ return 1;
+ }
+ return 0;
+}
+
int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
{
if (libcfs_ioctl_is_invalid(data)) {
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 19/29] staging:lustre: remove libcfs_psdev_[open|release] |
| Message-ID | <rfDB0-310-43@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Parinay Kondekar <parinay.kondekar@seagate.com>
With struct libcfs_device_userstate gone we can remove
the remaining code of libcfs_psdev_ops.p_[open|close]
as well as the libcfs_psdev_[open|release] functions.
Signed-off-by: Parinay Kondekar <parinay.kondekar@seagate.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5844
Reviewed-on: http://review.whamcloud.com/17492
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../staging/lustre/include/linux/libcfs/libcfs.h | 2 -
.../lustre/lnet/libcfs/linux/linux-module.c | 32 +-------------------
drivers/staging/lustre/lnet/libcfs/module.c | 16 ----------
3 files changed, 1 insertions(+), 49 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs.h b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
index 0ce52de..5d228e5 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs.h
@@ -73,8 +73,6 @@ struct cfs_psdev_file {
};
struct cfs_psdev_ops {
- int (*p_open)(unsigned long, void *);
- int (*p_close)(unsigned long, void *);
int (*p_read)(struct cfs_psdev_file *, char *, unsigned long);
int (*p_write)(struct cfs_psdev_file *, char *, unsigned long);
int (*p_ioctl)(struct cfs_psdev_file *, unsigned long, void __user *);
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index d801d87..633d76b 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -95,35 +95,6 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
return err;
}
-static int
-libcfs_psdev_open(struct inode *inode, struct file *file)
-{
- int rc = 0;
-
- if (!inode)
- return -EINVAL;
- if (libcfs_psdev_ops.p_open)
- rc = libcfs_psdev_ops.p_open(0, NULL);
- else
- return -EPERM;
- return rc;
-}
-
-/* called when closing /dev/device */
-static int
-libcfs_psdev_release(struct inode *inode, struct file *file)
-{
- int rc = 0;
-
- if (!inode)
- return -EINVAL;
- if (libcfs_psdev_ops.p_close)
- rc = libcfs_psdev_ops.p_close(0, NULL);
- else
- rc = -EPERM;
- return rc;
-}
-
static long libcfs_ioctl(struct file *file,
unsigned int cmd, unsigned long arg)
{
@@ -149,9 +120,8 @@ static long libcfs_ioctl(struct file *file,
}
static const struct file_operations libcfs_fops = {
+ .owner = THIS_MODULE,
.unlocked_ioctl = libcfs_ioctl,
- .open = libcfs_psdev_open,
- .release = libcfs_psdev_release,
};
struct miscdevice libcfs_dev = {
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 3a88e64..4d38aaf 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -65,20 +65,6 @@
static struct dentry *lnet_debugfs_root;
-/* called when opening /dev/device */
-static int libcfs_psdev_open(unsigned long flags, void *args)
-{
- try_module_get(THIS_MODULE);
- return 0;
-}
-
-/* called when closing /dev/device */
-static int libcfs_psdev_release(unsigned long flags, void *args)
-{
- module_put(THIS_MODULE);
- return 0;
-}
-
static DECLARE_RWSEM(ioctl_list_sem);
static LIST_HEAD(ioctl_list);
@@ -180,8 +166,6 @@ out:
}
struct cfs_psdev_ops libcfs_psdev_ops = {
- libcfs_psdev_open,
- libcfs_psdev_release,
NULL,
NULL,
libcfs_ioctl
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 26/29] staging: lustre: libcfs: add uapi headers to libcfs_ioctl.h |
| Message-ID | <rfDB0-310-45@gated-at.bofh.it> |
| In reply to | #1363082 |
Need a few uapi headers to make libcfs_ioctl.h compilable in userland. Signed-off-by: James Simmons <uja.ornl@yahoo.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245 Reviewed-on: http://review.whamcloud.com/17643 Reviewed-by: Bob Glossman <bob.glossman@intel.com> Reviewed-by: John L. Hammond <john.hammond@intel.com> Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> --- .../lustre/include/linux/libcfs/libcfs_ioctl.h | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index 48372c4..4b9102b 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -41,6 +41,9 @@ #ifndef __LIBCFS_IOCTL_H__ #define __LIBCFS_IOCTL_H__ +#include <linux/types.h> +#include <linux/ioctl.h> + #define LIBCFS_IOCTL_VERSION 0x0001000a #define LIBCFS_IOCTL_VERSION2 0x0001000b -- 1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 14/29] staging: lustre: libcfs: remove libcfsutil.h in comment |
| Message-ID | <rfDB1-310-47@gated-at.bofh.it> |
| In reply to | #1363082 |
From: John L. Hammond <john.hammond@intel.com> The header libcfsutil.h has been long gone in the upstream client. Replace libcfsutil.h reference to the current user land header instead. Signed-off-by: John L. Hammond <john.hammond@intel.com> Signed-off-by: James Simmons <uja.ornl@gmail.com> Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245 Reviewed-on: http://review.whamcloud.com/14180 Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com> Reviewed-by: frank zago <fzago@cray.com> Reviewed-by: James Simmons <uja.ornl@yahoo.com> Reviewed-by: Oleg Drokin <oleg.drokin@intel.com> --- .../lustre/include/linux/libcfs/libcfs_ioctl.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h index 9c1deae..01bf8d6 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h @@ -34,7 +34,7 @@ * libcfs/include/libcfs/libcfs_ioctl.h * * Low-level ioctl data structures. Kernel ioctl functions declared here, - * and user space functions are in libcfsutil_ioctl.h. + * and user space functions are in libcfs/util/ioctl.h. * */ -- 1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 25/29] staging: lustre: libcfs: make libcfs_ioctl.h readable |
| Message-ID | <rfDB1-310-51@gated-at.bofh.it> |
| In reply to | #1363082 |
Fix up all thw whitescapes and line up the IOCTL defines
so it is readable.
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 57 ++++++++++----------
1 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index c379d29..48372c4 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -82,41 +82,42 @@ struct libcfs_debug_ioctl_data {
unsigned int debug;
};
-/* FIXME check conflict with lustre_lib.h */
-#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long)
+/* 'f' ioctls are defined in lustre_ioctl.h and lustre_user.h except for: */
+#define LIBCFS_IOC_DEBUG_MASK _IOWR('f', 250, long)
+#define IOCTL_LIBCFS_TYPE long
-#define IOC_LIBCFS_TYPE 'e'
-#define IOC_LIBCFS_MIN_NR 30
+#define IOC_LIBCFS_TYPE ('e')
+#define IOC_LIBCFS_MIN_NR 30
/* libcfs ioctls */
/* IOC_LIBCFS_PANIC obsolete in 2.8.0, was _IOWR('e', 30, IOCTL_LIBCFS_TYPE) */
-#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, long)
-#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, long)
+#define IOC_LIBCFS_CLEAR_DEBUG _IOWR('e', 31, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_MARK_DEBUG _IOWR('e', 32, IOCTL_LIBCFS_TYPE)
/* IOC_LIBCFS_MEMHOG obsolete in 2.8.0, was _IOWR('e', 36, IOCTL_LIBCFS_TYPE) */
/* lnet ioctls */
-#define IOC_LIBCFS_GET_NI _IOWR('e', 50, long)
-#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, long)
-#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, long)
-#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, long)
-/* #define IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, long) */
-#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, long)
-#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, long)
-#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, long)
-#define IOC_LIBCFS_PING _IOWR('e', 61, long)
-/* #define IOC_LIBCFS_DEBUG_PEER _IOWR('e', 62, long) */
-#define IOC_LIBCFS_LNETST _IOWR('e', 63, long)
-#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, long)
+#define IOC_LIBCFS_GET_NI _IOWR('e', 50, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_FAIL_NID _IOWR('e', 51, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_NOTIFY_ROUTER _IOWR('e', 55, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_UNCONFIGURE _IOWR('e', 56, IOCTL_LIBCFS_TYPE)
+/* IOC_LIBCFS_PORTALS_COMPATIBILITY _IOWR('e', 57, IOCTL_LIBCFS_TYPE) */
+#define IOC_LIBCFS_LNET_DIST _IOWR('e', 58, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CONFIGURE _IOWR('e', 59, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_TESTPROTOCOMPAT _IOWR('e', 60, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PING _IOWR('e', 61, IOCTL_LIBCFS_TYPE)
+/* IOC_LIBCFS_DEBUG_PEER _IOWR('e', 62, IOCTL_LIBCFS_TYPE) */
+#define IOC_LIBCFS_LNETST _IOWR('e', 63, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_LNET_FAULT _IOWR('e', 64, IOCTL_LIBCFS_TYPE)
/* lnd ioctls */
-#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, long)
-#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, long)
-#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, long)
-#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, long)
-#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, long)
-#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, long)
-#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, long)
+#define IOC_LIBCFS_REGISTER_MYNID _IOWR('e', 70, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_CLOSE_CONNECTION _IOWR('e', 71, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_PUSH_CONNECTION _IOWR('e', 72, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_CONN _IOWR('e', 73, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_PEER _IOWR('e', 74, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_ADD_PEER _IOWR('e', 75, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_PEER _IOWR('e', 76, IOCTL_LIBCFS_TYPE)
/* ioctl 77 is free for use */
-#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, long)
-#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, long)
-#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, long)
+#define IOC_LIBCFS_ADD_INTERFACE _IOWR('e', 78, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_DEL_INTERFACE _IOWR('e', 79, IOCTL_LIBCFS_TYPE)
+#define IOC_LIBCFS_GET_INTERFACE _IOWR('e', 80, IOCTL_LIBCFS_TYPE)
/*
* DLC Specific IOCTL numbers.
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:10 +0100 |
| Subject | [PATCH 27/29] staging: lustre: libcfs: return proper bool values |
| Message-ID | <rfDB1-310-53@gated-at.bofh.it> |
| In reply to | #1363082 |
Return real bool values for libcfs_ioctl_is_invalid().
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-6245
Reviewed-on: http://review.whamcloud.com/17643
Reviewed-by: Bob Glossman <bob.glossman@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/lnet/libcfs/linux/linux-module.c | 26 ++++++++++----------
1 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index af19f3c..d5b7d3a 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -53,56 +53,56 @@ static inline bool libcfs_ioctl_is_invalid(struct libcfs_ioctl_data *data)
{
if (data->ioc_hdr.ioc_len > (1 << 30)) {
CERROR("LIBCFS ioctl: ioc_len larger than 1<<30\n");
- return 1;
+ return true;
}
if (data->ioc_inllen1 > (1<<30)) {
CERROR("LIBCFS ioctl: ioc_inllen1 larger than 1<<30\n");
- return 1;
+ return true;
}
if (data->ioc_inllen2 > (1<<30)) {
CERROR("LIBCFS ioctl: ioc_inllen2 larger than 1<<30\n");
- return 1;
+ return true;
}
if (data->ioc_inlbuf1 && !data->ioc_inllen1) {
CERROR("LIBCFS ioctl: inlbuf1 pointer but 0 length\n");
- return 1;
+ return true;
}
if (data->ioc_inlbuf2 && !data->ioc_inllen2) {
CERROR("LIBCFS ioctl: inlbuf2 pointer but 0 length\n");
- return 1;
+ return true;
}
if (data->ioc_pbuf1 && !data->ioc_plen1) {
CERROR("LIBCFS ioctl: pbuf1 pointer but 0 length\n");
- return 1;
+ return true;
}
if (data->ioc_pbuf2 && !data->ioc_plen2) {
CERROR("LIBCFS ioctl: pbuf2 pointer but 0 length\n");
- return 1;
+ return true;
}
if (data->ioc_plen1 && !data->ioc_pbuf1) {
CERROR("LIBCFS ioctl: plen1 nonzero but no pbuf1 pointer\n");
- return 1;
+ return true;
}
if (data->ioc_plen2 && !data->ioc_pbuf2) {
CERROR("LIBCFS ioctl: plen2 nonzero but no pbuf2 pointer\n");
- return 1;
+ return true;
}
if ((__u32)libcfs_ioctl_packlen(data) != data->ioc_hdr.ioc_len) {
CERROR("LIBCFS ioctl: packlen != ioc_len\n");
- return 1;
+ return true;
}
if (data->ioc_inllen1 &&
data->ioc_bulk[data->ioc_inllen1 - 1] != '\0') {
CERROR("LIBCFS ioctl: inlbuf1 not 0 terminated\n");
- return 1;
+ return true;
}
if (data->ioc_inllen2 &&
data->ioc_bulk[cfs_size_round(data->ioc_inllen1) +
data->ioc_inllen2 - 1] != '\0') {
CERROR("LIBCFS ioctl: inlbuf2 not 0 terminated\n");
- return 1;
+ return true;
}
- return 0;
+ return false;
}
int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data)
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 08/29] staging: lustre: libcfs: invert test condition for libcfs_ioctl |
| Message-ID | <rfDKG-34K-1@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
Invert the test of error returned by the handle_ioctl pointer.
This reduces the code by one indentation level.
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lnet/libcfs/module.c | 13 +++++++------
1 files changed, 7 insertions(+), 6 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index cce6ce3..97fc905 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -165,12 +165,13 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
down_read(&ioctl_list_sem);
list_for_each_entry(hand, &ioctl_list, item) {
err = hand->handle_ioctl(cmd, hdr);
- if (err != -EINVAL) {
- if (err == 0)
- err = libcfs_ioctl_popdata(arg,
- hdr, hdr->ioc_len);
- break;
- }
+ if (err == -EINVAL)
+ continue;
+
+ if (!err)
+ err = libcfs_ioctl_popdata(arg, hdr,
+ hdr->ioc_len);
+ break;
}
up_read(&ioctl_list_sem);
break; }
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 13/29] staging: lustre: libcfs: change variable name |
| Message-ID | <rfDKG-34K-13@gated-at.bofh.it> |
| In reply to | #1363082 |
Change arg to uparam name for libcfs_ioctl().
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lnet/libcfs/module.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 97fc905..839145e 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -113,14 +113,14 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
EXPORT_SYMBOL(libcfs_deregister_ioctl);
static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
- void __user *arg)
+ void __user *uparam)
{
struct libcfs_ioctl_data *data = NULL;
struct libcfs_ioctl_hdr *hdr;
int err;
/* 'cmd' and permissions get checked in our arch-specific caller */
- err = libcfs_ioctl_getdata(&hdr, arg);
+ err = libcfs_ioctl_getdata(&hdr, uparam);
if (err) {
CDEBUG_LIMIT(D_ERROR,
"libcfs ioctl: data header error %d\n", err);
@@ -169,7 +169,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
continue;
if (!err)
- err = libcfs_ioctl_popdata(arg, hdr,
+ err = libcfs_ioctl_popdata(uparam, hdr,
hdr->ioc_len);
break;
}
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 11/29] staging: lustre: lnet: make sure lnet data not greater than LIBCFS_IOC_DATA_MAX |
| Message-ID | <rfDKG-34K-9@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
Fail to compile if largest LNet user land data structures passed
to kernel are larger than LIBCFS_IOC_DATA_MAX
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lnet/lnet/api-ni.c | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/lustre/lnet/lnet/api-ni.c b/drivers/staging/lustre/lnet/lnet/api-ni.c
index 8764755..f825784 100644
--- a/drivers/staging/lustre/lnet/lnet/api-ni.c
+++ b/drivers/staging/lustre/lnet/lnet/api-ni.c
@@ -1864,6 +1864,10 @@ LNetCtl(unsigned int cmd, void *arg)
int rc;
unsigned long secs_passed;
+ BUILD_BUG_ON(LIBCFS_IOC_DATA_MAX <
+ sizeof(struct lnet_ioctl_net_config) +
+ sizeof(struct lnet_ioctl_config_data));
+
switch (cmd) {
case IOC_LIBCFS_GET_NI:
rc = LNetGetId(data->ioc_count, &id);
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 04/29] staging: lustre: libcfs: merge libcfs_ioctl_handle into libcfs_ioctl |
| Message-ID | <rfDKG-34K-15@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
This is apart of the cleanup of libcfs_ioctl* code. In this
part we turn libcfs_ioctl_handle into libcfs_ioctl since
libcfs_ioctl is now a skeleton function.
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lnet/libcfs/module.c | 37 +++++++++++----------------
1 files changed, 15 insertions(+), 22 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index 5a20e53..8beb954 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -112,11 +112,17 @@ int libcfs_deregister_ioctl(struct libcfs_ioctl_handler *hand)
}
EXPORT_SYMBOL(libcfs_deregister_ioctl);
-static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
- void __user *arg, struct libcfs_ioctl_hdr *hdr)
+static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
+ void __user *arg)
{
struct libcfs_ioctl_data *data = NULL;
- int err = 0;
+ struct libcfs_ioctl_hdr *hdr;
+ int err;
+
+ /* 'cmd' and permissions get checked in our arch-specific caller */
+ err = libcfs_ioctl_getdata(&hdr, arg);
+ if (err)
+ return err;
/*
* The libcfs_ioctl_data_adjust() function performs adjustment
@@ -128,7 +134,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
data = container_of(hdr, struct libcfs_ioctl_data, ioc_hdr);
err = libcfs_ioctl_data_adjust(data);
if (err)
- return err;
+ goto out;
}
switch (cmd) {
@@ -141,8 +147,10 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
*/
case IOC_LIBCFS_MARK_DEBUG:
if (!data->ioc_inlbuf1 ||
- data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0')
- return -EINVAL;
+ data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0') {
+ err = -EINVAL;
+ goto out;
+ }
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
break;
@@ -163,22 +171,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
up_read(&ioctl_list_sem);
break; }
}
-
- return err;
-}
-
-static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
- void __user *arg)
-{
- struct libcfs_ioctl_hdr *hdr;
- int err = 0;
-
- /* 'cmd' and permissions get checked in our arch-specific caller */
- err = libcfs_ioctl_getdata(&hdr, arg);
- if (err)
- return err;
-
- err = libcfs_ioctl_handle(pfile, cmd, arg, hdr);
+out:
LIBCFS_FREE(hdr, hdr->ioc_len);
return err;
}
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 10/29] staging: lustre: libcfs: test if userland data is to small |
| Message-ID | <rfDKH-34K-21@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
Ensure that user land data is at least the smallest size.
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/lnet/libcfs/linux/linux-module.c | 5 +++++
1 files changed, 5 insertions(+), 0 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
index 35e2fcf..ae05895 100644
--- a/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
+++ b/drivers/staging/lustre/lnet/libcfs/linux/linux-module.c
@@ -73,6 +73,11 @@ int libcfs_ioctl_getdata(struct libcfs_ioctl_hdr **hdr_pp,
return -EINVAL;
}
+ if (hdr.ioc_len < sizeof(struct libcfs_ioctl_data)) {
+ CERROR("libcfs ioctl: user buffer too small for ioctl\n");
+ return -EINVAL;
+ }
+
if (hdr.ioc_len > LIBCFS_IOC_DATA_MAX) {
CERROR("libcfs ioctl: user buffer is too large %d/%d\n",
hdr.ioc_len, LIBCFS_IOC_DATA_MAX);
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 01/29] staging: lustre: libcfs: replace LNET_MAX_IOCTL_BUF_LEN with something bigger |
| Message-ID | <rfDKH-34K-23@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
The size of LNET_MAX_IOCTL_BUF_LEN restricts the size of
libcfs ioctl to the maximum needs of the LNet layer. Since
libcfs also handles things like debugging we might need
to let user land pass more data to or from the kernel than
what is possible
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
.../lustre/include/linux/libcfs/libcfs_ioctl.h | 3 +++
drivers/staging/lustre/lnet/libcfs/module.c | 5 +----
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
index 5ca99bd..c71d125 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_ioctl.h
@@ -49,6 +49,9 @@ struct libcfs_ioctl_hdr {
__u32 ioc_version;
};
+/** max size to copy from userspace */
+#define LIBCFS_IOC_DATA_MAX (128 * 1024)
+
struct libcfs_ioctl_data {
struct libcfs_ioctl_hdr ioc_hdr;
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index cdc640b..f9f9d59 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -54,9 +54,6 @@
# define DEBUG_SUBSYSTEM S_LNET
-#define LNET_MAX_IOCTL_BUF_LEN (sizeof(struct lnet_ioctl_net_config) + \
- sizeof(struct lnet_ioctl_config_data))
-
#include "../../include/linux/libcfs/libcfs.h"
#include <asm/div64.h>
@@ -186,7 +183,7 @@ static int libcfs_ioctl(struct cfs_psdev_file *pfile, unsigned long cmd,
* do a check here to restrict the size of the memory
* to allocate to guard against DoS attacks.
*/
- if (buf_len > LNET_MAX_IOCTL_BUF_LEN) {
+ if (buf_len > LIBCFS_IOC_DATA_MAX) {
CERROR("LNET: user buffer exceeds kernel buffer\n");
return -EINVAL;
}
--
1.7.1
[toc] | [prev] | [next] | [standalone]
| From | James Simmons <jsimmons@infradead.org> |
|---|---|
| Date | 2016-03-23 00:20 +0100 |
| Subject | [PATCH 02/29] staging: lustre: libcfs: use break in switch options for libcfs_ioctl_handle |
| Message-ID | <rfDKH-34K-25@gated-at.bofh.it> |
| In reply to | #1363082 |
From: Liang Zhen <liang.zhen@intel.com>
Instead of just returning for each switch condition use a break.
Signed-off-by: Liang Zhen <liang.zhen@intel.com>
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-5435
Reviewed-on: http://review.whamcloud.com/11313
Reviewed-by: Bobi Jam <bobijam@gmail.com>
Reviewed-by: Johann Lombardi <johann.lombardi@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
---
drivers/staging/lustre/lnet/libcfs/module.c | 9 ++++-----
1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/drivers/staging/lustre/lnet/libcfs/module.c b/drivers/staging/lustre/lnet/libcfs/module.c
index f9f9d59..3fe2810 100644
--- a/drivers/staging/lustre/lnet/libcfs/module.c
+++ b/drivers/staging/lustre/lnet/libcfs/module.c
@@ -116,7 +116,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
void __user *arg, struct libcfs_ioctl_hdr *hdr)
{
struct libcfs_ioctl_data *data = NULL;
- int err = -EINVAL;
+ int err = 0;
/*
* The libcfs_ioctl_data_adjust() function performs adjustment
@@ -134,7 +134,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
switch (cmd) {
case IOC_LIBCFS_CLEAR_DEBUG:
libcfs_debug_clear_buffer();
- return 0;
+ break;
/*
* case IOC_LIBCFS_PANIC:
* Handled in arch/cfs_module.c
@@ -144,7 +144,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
data->ioc_inlbuf1[data->ioc_inllen1 - 1] != '\0')
return -EINVAL;
libcfs_debug_mark_buffer(data->ioc_inlbuf1);
- return 0;
+ break;
default: {
struct libcfs_ioctl_handler *hand;
@@ -161,8 +161,7 @@ static int libcfs_ioctl_handle(struct cfs_psdev_file *pfile, unsigned long cmd,
}
}
up_read(&ioctl_list_sem);
- break;
- }
+ break; }
}
return err;
--
1.7.1
[toc] | [prev] | [next] | [standalone]
Page 1 of 2 [1] 2 Next page →
Back to top | Article view | linux.kernel
csiph-web