From patchwork Tue Dec 16 15:43:16 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinpu Wang X-Patchwork-Id: 5501271 Return-Path: X-Original-To: patchwork-linux-rdma@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 15B8C9F30B for ; Tue, 16 Dec 2014 15:43:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50D5A209CD for ; Tue, 16 Dec 2014 15:43:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 83A4F20A25 for ; Tue, 16 Dec 2014 15:43:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750906AbaLPPnp (ORCPT ); Tue, 16 Dec 2014 10:43:45 -0500 Received: from mail-wg0-f44.google.com ([74.125.82.44]:44158 "EHLO mail-wg0-f44.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750832AbaLPPnp (ORCPT ); Tue, 16 Dec 2014 10:43:45 -0500 Received: by mail-wg0-f44.google.com with SMTP id b13so17860999wgh.31 for ; Tue, 16 Dec 2014 07:43:43 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HU10tgl9GOPPUBwVqKQyyqaXoqJ12W0Fg7aazI64uGU=; b=BY4K5TaoGhyuUysub5bEppZjHQyt4lklCdaAa2mcrihMqXph5q+lDhdzKvgrbwL322 bksY3iJGWprLB/wwlRlnrD2MDHutO8FHhkyx5eQrLZiTGwrclZh8FN6/vsFV2hD4G7jO 9uYdKwFw9tj2nWliHvxLg/MEj0f7M1firrMUSSsatfhqDDAqYNd9/3JoalN7XyrYKgkd 3Jipjf1i5wbcpMZ98jpRvkz2hQh7jfM6CopsjixDeB7NFPen/afrzt4b+87D6lXtH73y P+s96LXX30FeZcYouNGlfVn/MAM/Ym2ZQ+EiguPJ941xsPQ2IAI5lur4oALsyz4v4LdO gaKQ== X-Gm-Message-State: ALoCoQnuq2fvwgyRzBUKuowsu0pfIc/qKDvrz5XDrbGHsMzVLL00opVhVtCEthYjhxw1lmAGZlnG X-Received: by 10.180.20.6 with SMTP id j6mr5698847wie.59.1418744623794; Tue, 16 Dec 2014 07:43:43 -0800 (PST) Received: from jinpu-GA-870A-USB3.pb.local ([62.217.45.26]) by mx.google.com with ESMTPSA id fo12sm17369966wic.19.2014.12.16.07.43.42 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 16 Dec 2014 07:43:43 -0800 (PST) From: Jack Wang To: roland@kernel.org Cc: linux-rdma@vger.kernel.org, Jack Wang Subject: [PATCH] RDMA/cma: fix first byte overwritten for AF_IB Date: Tue, 16 Dec 2014 16:43:16 +0100 Message-Id: <1418744596-25251-1-git-send-email-jinpu.wang@profitbricks.com> X-Mailer: git-send-email 1.9.1 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_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 If user attach private data for AF_IB, the first byte will be overwritten, because we always set the cma version no matter family is AF_IB, so move the version set inside if condition. Reported-by: Fabian Holler Signed-off-by: Jack Wang --- drivers/infiniband/core/cma.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index d570030..22a22e2 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c @@ -2618,10 +2618,10 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) struct cma_hdr *cma_hdr; cma_hdr = hdr; - cma_hdr->cma_version = CMA_VERSION; if (cma_family(id_priv) == AF_INET) { struct sockaddr_in *src4, *dst4; + cma_hdr->cma_version = CMA_VERSION; src4 = (struct sockaddr_in *) cma_src_addr(id_priv); dst4 = (struct sockaddr_in *) cma_dst_addr(id_priv); @@ -2632,6 +2632,7 @@ static int cma_format_hdr(void *hdr, struct rdma_id_private *id_priv) } else if (cma_family(id_priv) == AF_INET6) { struct sockaddr_in6 *src6, *dst6; + cma_hdr->cma_version = CMA_VERSION; src6 = (struct sockaddr_in6 *) cma_src_addr(id_priv); dst6 = (struct sockaddr_in6 *) cma_dst_addr(id_priv);