diff options
author | Oleg Drokin <green@linuxhacker.ru> | 2014-01-23 23:45:07 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2014-02-07 12:09:38 -0500 |
commit | 18e042f0c9cb14afa5540dc366eeefe67295d0b9 (patch) | |
tree | 4a276176a07c6f16023d6f678819f474da1117b8 | |
parent | 910827f17496e03d23577c580e2456604caa9f35 (diff) |
lustre: Correct KUC code max changelog msg size
The kernel to userspace communication routines (KUC) allocate
and limit the maximum cs_buf size to CR_MAXSIZE. However this
fails to account for the fact that the buffer is assumed to begin
with a struct kuc_hdr. To allocate and account for that space,
we introduce a new define, KUC_CHANGELOG_MSG_MAXSIZE.
Signed-off-by: Christopher J. Morrone <morrone2@llnl.gov>
Reviewed-on: http://review.whamcloud.com/7406
Intel-bug-id: https://jira.hpdd.intel.com/browse/LU-3587
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: jacques-Charles Lafoucriere <jacques-charles.lafoucriere@cea.fr>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Oleg Drokin <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h | 2 | ||||
-rw-r--r-- | drivers/staging/lustre/lustre/mdc/mdc_request.c | 6 |
2 files changed, 5 insertions, 3 deletions
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h index 596a15fc8996..037ae8a6d531 100644 --- a/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h +++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_kernelcomm.h | |||
@@ -61,6 +61,8 @@ struct kuc_hdr { | |||
61 | __u16 kuc_msglen; /* Including header */ | 61 | __u16 kuc_msglen; /* Including header */ |
62 | } __attribute__((aligned(sizeof(__u64)))); | 62 | } __attribute__((aligned(sizeof(__u64)))); |
63 | 63 | ||
64 | #define KUC_CHANGELOG_MSG_MAXSIZE (sizeof(struct kuc_hdr)+CR_MAXSIZE) | ||
65 | |||
64 | #define KUC_MAGIC 0x191C /*Lustre9etLinC */ | 66 | #define KUC_MAGIC 0x191C /*Lustre9etLinC */ |
65 | #define KUC_FL_BLOCK 0x01 /* Wait for send */ | 67 | #define KUC_FL_BLOCK 0x01 /* Wait for send */ |
66 | 68 | ||
diff --git a/drivers/staging/lustre/lustre/mdc/mdc_request.c b/drivers/staging/lustre/lustre/mdc/mdc_request.c index d1ad91c34ddc..83013927e131 100644 --- a/drivers/staging/lustre/lustre/mdc/mdc_request.c +++ b/drivers/staging/lustre/lustre/mdc/mdc_request.c | |||
@@ -1430,7 +1430,7 @@ static struct kuc_hdr *changelog_kuc_hdr(char *buf, int len, int flags) | |||
1430 | { | 1430 | { |
1431 | struct kuc_hdr *lh = (struct kuc_hdr *)buf; | 1431 | struct kuc_hdr *lh = (struct kuc_hdr *)buf; |
1432 | 1432 | ||
1433 | LASSERT(len <= CR_MAXSIZE); | 1433 | LASSERT(len <= KUC_CHANGELOG_MSG_MAXSIZE); |
1434 | 1434 | ||
1435 | lh->kuc_magic = KUC_MAGIC; | 1435 | lh->kuc_magic = KUC_MAGIC; |
1436 | lh->kuc_transport = KUC_TRANSPORT_CHANGELOG; | 1436 | lh->kuc_transport = KUC_TRANSPORT_CHANGELOG; |
@@ -1503,7 +1503,7 @@ static int mdc_changelog_send_thread(void *csdata) | |||
1503 | CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n", | 1503 | CDEBUG(D_CHANGELOG, "changelog to fp=%p start "LPU64"\n", |
1504 | cs->cs_fp, cs->cs_startrec); | 1504 | cs->cs_fp, cs->cs_startrec); |
1505 | 1505 | ||
1506 | OBD_ALLOC(cs->cs_buf, CR_MAXSIZE); | 1506 | OBD_ALLOC(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); |
1507 | if (cs->cs_buf == NULL) | 1507 | if (cs->cs_buf == NULL) |
1508 | GOTO(out, rc = -ENOMEM); | 1508 | GOTO(out, rc = -ENOMEM); |
1509 | 1509 | ||
@@ -1540,7 +1540,7 @@ out: | |||
1540 | if (ctxt) | 1540 | if (ctxt) |
1541 | llog_ctxt_put(ctxt); | 1541 | llog_ctxt_put(ctxt); |
1542 | if (cs->cs_buf) | 1542 | if (cs->cs_buf) |
1543 | OBD_FREE(cs->cs_buf, CR_MAXSIZE); | 1543 | OBD_FREE(cs->cs_buf, KUC_CHANGELOG_MSG_MAXSIZE); |
1544 | OBD_FREE_PTR(cs); | 1544 | OBD_FREE_PTR(cs); |
1545 | return rc; | 1545 | return rc; |
1546 | } | 1546 | } |