From patchwork Mon Oct 14 00:22:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Felipe Pena X-Patchwork-Id: 3034051 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 F15CFBF924 for ; Mon, 14 Oct 2013 00:22:33 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1C3AF2023F for ; Mon, 14 Oct 2013 00:22:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BC9B520253 for ; Mon, 14 Oct 2013 00:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755365Ab3JNAW2 (ORCPT ); Sun, 13 Oct 2013 20:22:28 -0400 Received: from mail-wg0-f49.google.com ([74.125.82.49]:48540 "EHLO mail-wg0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755331Ab3JNAW2 (ORCPT ); Sun, 13 Oct 2013 20:22:28 -0400 Received: by mail-wg0-f49.google.com with SMTP id x12so3801905wgg.4 for ; Sun, 13 Oct 2013 17:22:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=7mvn1wNqohPXec7F1/HQpf4356SkUqiZRcelgazL5yE=; b=OmNVvnidjU3Gsi+7wZU6GmJ+6YasyLGUm6zRLLdYzXYuGBZqN6lMOvbBzJDQkGj11c yc9juTCbH7RByoMQEaA/jMWPtBL1xOz7TRjPwZcRp3aLYtTUiZnnSwbRpX0x6T4Ouyal dIjgyk+Q7V9BI135ptCET+Bd/innK4Z3xLmqYwy0SqJAUBHY3XdkerbIYyq/YhvJlFin zflM+lM8rT4ZnpVzlZq13mrpGC+GC+y58S1QjOV5ZLspvJZZi8SpaHo/oXi3kCJvKI+O LLao56mWT0HA8Sd42QGJKZJYPAnhC2nYW/E9FMhYhAwMjd84aWtN090IEc5xdSSWh4w+ PE1w== X-Received: by 10.180.73.40 with SMTP id i8mr12253131wiv.37.1381710146516; Sun, 13 Oct 2013 17:22:26 -0700 (PDT) Received: from localhost.localdomain (187-126-128-43.user.veloxzone.com.br. [187.126.128.43]) by mx.google.com with ESMTPSA id gp9sm28865153wib.8.2013.10.13.17.22.22 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 13 Oct 2013 17:22:25 -0700 (PDT) From: Felipe Pena To: Or Gerlitz , Roi Dayan , Roland Dreier , Sean Hefty , Hal Rosenstock Cc: linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org, Felipe Pena Subject: [PATCH 1/1] drivers: infiniband: ulp: Fix possible use-after-free Date: Sun, 13 Oct 2013 21:22:46 -0300 Message-Id: <1381710166-27341-1-git-send-email-felipensp@gmail.com> X-Mailer: git-send-email 1.7.10.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.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, 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 The tx_desc variable is being used to access its type member after a kmem_cache_free call Signed-off-by: Felipe Pena --- drivers/infiniband/ulp/iser/iser_initiator.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index 5388226..15b545c 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c @@ -610,17 +610,15 @@ void iser_snd_completion(struct iser_tx_desc *tx_desc, ib_dma_unmap_single(device->ib_device, tx_desc->dma_addr, ISER_HEADERS_LEN, DMA_TO_DEVICE); kmem_cache_free(ig.desc_cache, tx_desc); - } - - atomic_dec(&ib_conn->post_send_buf_count); - - if (tx_desc->type == ISCSI_TX_CONTROL) { + } else if (tx_desc->type == ISCSI_TX_CONTROL) { /* this arithmetic is legal by libiscsi dd_data allocation */ task = (void *) ((long)(void *)tx_desc - sizeof(struct iscsi_task)); if (task->hdr->itt == RESERVED_ITT) iscsi_put_task(task); } + + atomic_dec(&ib_conn->post_send_buf_count); } void iser_task_rdma_init(struct iscsi_iser_task *iser_task)