From: isaac Date: Thu, 29 Jan 2009 15:23:34 +0000 (+0000) Subject: b=15984, i=maxim: X-Git-Tag: v1_9_150~4 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=c69f3a890b5dd72c02841dea6863734147ed9784 b=15984, i=maxim: - uptllnd credit overflow fix. --- diff --git a/lnet/ChangeLog b/lnet/ChangeLog index 6a05cf6..5231524 100644 --- a/lnet/ChangeLog +++ b/lnet/ChangeLog @@ -17,6 +17,12 @@ Bugzilla : Description: Details : +Severity : minor +Bugzilla : 15984 +Description: uptllnd credit overflow fix +Details : kptl_msg_t::ptlm_credits could be overflown by uptllnd since + it is only a __u8. + Severity : major Bugzilla : 14634 Description: socklnd prtocol version 3 diff --git a/lnet/include/lnet/ptllnd_wire.h b/lnet/include/lnet/ptllnd_wire.h index 277c51c..2dd7253 100644 --- a/lnet/include/lnet/ptllnd_wire.h +++ b/lnet/include/lnet/ptllnd_wire.h @@ -108,6 +108,9 @@ typedef struct } kptl_msg_t; +/* kptl_msg_t::ptlm_credits is only a __u8 */ +#define PTLLND_MSG_MAX_CREDITS ((typeof(((kptl_msg_t*) 0)->ptlm_credits)) -1) + #define PTLLND_MSG_MAGIC LNET_PROTO_PTL_MAGIC #define PTLLND_MSG_VERSION 0x04 diff --git a/lnet/klnds/ptllnd/ptllnd.c b/lnet/klnds/ptllnd/ptllnd.c index 7f2e959..ffa0a2e 100755 --- a/lnet/klnds/ptllnd/ptllnd.c +++ b/lnet/klnds/ptllnd/ptllnd.c @@ -497,9 +497,8 @@ kptllnd_startup (lnet_ni_t *ni) return -EINVAL; } - /* kptl_msg_t::ptlm_credits is only a __u8 */ - if (*kptllnd_tunables.kptl_peercredits > 255) { - CERROR("kptl_peercredits must be <= 255\n"); + if (*kptllnd_tunables.kptl_peercredits > PTLLND_MSG_MAX_CREDITS) { + CERROR("peercredits must be <= %d\n", PTLLND_MSG_MAX_CREDITS); return -EINVAL; } diff --git a/lnet/ulnds/ptllnd/ptllnd.c b/lnet/ulnds/ptllnd/ptllnd.c index 3b504e7..b0ed0ce 100644 --- a/lnet/ulnds/ptllnd/ptllnd.c +++ b/lnet/ulnds/ptllnd/ptllnd.c @@ -303,6 +303,10 @@ ptllnd_get_tunables(lnet_ni_t *ni) PTLLND_MAX_ULND_MSG_SIZE); if (rc != 0) return rc; + if (plni->plni_peer_credits > PTLLND_MSG_MAX_CREDITS) { + CERROR("PTLLND_PEERCREDITS must be <= %d\n", PTLLND_MSG_MAX_CREDITS); + return -EINVAL; + } rc = ptllnd_parse_int_tunable(&msgs_per_buffer, "PTLLND_MSGS_PER_BUFFER", 64); diff --git a/lnet/ulnds/ptllnd/ptllnd_cb.c b/lnet/ulnds/ptllnd/ptllnd_cb.c index c8431df..9cfa071 100644 --- a/lnet/ulnds/ptllnd/ptllnd_cb.c +++ b/lnet/ulnds/ptllnd/ptllnd_cb.c @@ -875,9 +875,10 @@ ptllnd_check_sends(ptllnd_peer_t *peer) /* * Return all the credits we have */ - tx->tx_msg.ptlm_credits = peer->plp_outstanding_credits; - peer->plp_sent_credits += peer->plp_outstanding_credits; - peer->plp_outstanding_credits = 0; + tx->tx_msg.ptlm_credits = MIN(PTLLND_MSG_MAX_CREDITS, + peer->plp_outstanding_credits); + peer->plp_sent_credits += tx->tx_msg.ptlm_credits; + peer->plp_outstanding_credits -= tx->tx_msg.ptlm_credits; /* * One less credit