From patchwork Mon Jul 28 12:48:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Nelkenbaum X-Patchwork-Id: 4634221 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 13F2BC0338 for ; Mon, 28 Jul 2014 12:48:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 578202018B for ; Mon, 28 Jul 2014 12:48:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 801542017E for ; Mon, 28 Jul 2014 12:48:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752191AbaG1MsU (ORCPT ); Mon, 28 Jul 2014 08:48:20 -0400 Received: from mailp.voltaire.com ([193.47.165.129]:46223 "EHLO mellanox.co.il" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1752154AbaG1MsU (ORCPT ); Mon, 28 Jul 2014 08:48:20 -0400 Received: from Internal Mail-Server by MTLPINE2 (envelope-from ilyan@dev.mellanox.co.il) with SMTP; 28 Jul 2014 15:48:16 +0300 Received: from dev-r-vrt-086.mtr.labs.mlnx. (dev-r-vrt-086.mtr.labs.mlnx [10.212.86.1]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id s6SCmAje015022; Mon, 28 Jul 2014 15:48:15 +0300 From: Ilya Nelkenbaum To: sean.hefty@intel.com Cc: linux-rdma@vger.kernel.org, Ilya Nelkenbaum Subject: [PATCH librdmacm] rsocket: Segmentation fault fix in case of multiple connections Date: Mon, 28 Jul 2014 15:48:09 +0300 Message-Id: <1406551689-8142-1-git-send-email-ilyan@dev.mellanox.co.il> X-Mailer: git-send-email 1.8.3.4 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ilya Nelkenbaum In case of more than 16 rsocket connections are established, "svc->rss" buffer is reallocated with more memory. Index 0 is reserved for the service's communication socket, and this is not taken in count when data is copied from old buffer location to new one. Signed-off-by: Ilya Nelkenbaum --- src/rsocket.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/rsocket.c b/src/rsocket.c index c7a0cb2..7007897 100644 --- a/src/rsocket.c +++ b/src/rsocket.c @@ -3915,8 +3915,8 @@ static int rs_svc_grow_sets(struct rs_svc *svc, int grow_size) rss = set; contexts = set + sizeof(*rss) * svc->size; if (svc->cnt) { - memcpy(rss, svc->rss, sizeof(*rss) * svc->cnt); - memcpy(contexts, svc->contexts, svc->context_size * svc->cnt); + memcpy(rss, svc->rss, sizeof(*rss) * (svc->cnt + 1)); + memcpy(contexts, svc->contexts, svc->context_size * (svc->cnt + 1)); } free(svc->rss);