From patchwork Fri May 1 06:23:48 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Akinobu Mita X-Patchwork-Id: 6308521 Return-Path: X-Original-To: patchwork-linux-scsi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id A10119F32E for ; Fri, 1 May 2015 06:24:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id C05F1203A9 for ; Fri, 1 May 2015 06:24:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D7F03203C2 for ; Fri, 1 May 2015 06:24:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753075AbbEAGYN (ORCPT ); Fri, 1 May 2015 02:24:13 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:35276 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750904AbbEAGYM (ORCPT ); Fri, 1 May 2015 02:24:12 -0400 Received: by pdbqd1 with SMTP id qd1so83999310pdb.2; Thu, 30 Apr 2015 23:24:11 -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:in-reply-to:references; bh=XN+6AXMrgEJvQn+3/v/VdxCTi5bmJz63TKz5Fvf8A/s=; b=e3zMnBkD+7ILWUs6cBsQaTwoPRhpAja39yVs6xeuYY52sydAbDRW2qd1RTnPuBWMSI Z0DIwwbHcNauVkSaQVVDLzjICfmKD+Dkq1gQzB5mQlDtgx848QvTzDZGgd+oBuVsvY53 jJZAqglosTfeqMzWfOpHYq/wTQyCBw7sIkNG9DL96NTk+tCa3NmSkkJRoeB7U1BvNh2p msjMAmGtRQCO0/MPREvhw1B9zbzBLy6v2gn2tP67EYUWQ0F93u5NXSsQ0Yme0eV+7fcw dDCPB5eE7Dd8gK+I8T9IYULIJwGFQd0EdUVOe0dihUrIcZQpvEAIXHe7Lne7w6u1KAkx e12A== X-Received: by 10.66.186.103 with SMTP id fj7mr14936387pac.132.1430461451807; Thu, 30 Apr 2015 23:24:11 -0700 (PDT) Received: from localhost.localdomain (KD106168100169.ppp-bb.dion.ne.jp. [106.168.100.169]) by mx.google.com with ESMTPSA id bz11sm3889311pdb.34.2015.04.30.23.24.08 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 30 Apr 2015 23:24:10 -0700 (PDT) From: Akinobu Mita To: target-devel@vger.kernel.org Cc: Akinobu Mita , Nicholas Bellinger , Sagi Grimberg , "Martin K. Petersen" , Christoph Hellwig , "James E.J. Bottomley" , linux-scsi@vger.kernel.org Subject: [PATCH v4 1/4] target: Fix inconsistent address passed to kunmap_atomic() in sbc_dif_copy_prot() Date: Fri, 1 May 2015 15:23:48 +0900 Message-Id: <1430461431-5936-2-git-send-email-akinobu.mita@gmail.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1430461431-5936-1-git-send-email-akinobu.mita@gmail.com> References: <1430461431-5936-1-git-send-email-akinobu.mita@gmail.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Spam-Status: No, score=-6.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID, 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 In sbc_dif_copy_prot(), the addresses passed to kunmap_atomic() are inconsistent with the addresses which are mapped by kmap_atomic(). That could be problematic if an SG element has its length larger than PAGE_SIZE as kunmap_atomic() will attempt to unmap different page. Signed-off-by: Akinobu Mita Cc: Nicholas Bellinger Cc: Sagi Grimberg Cc: "Martin K. Petersen" Cc: Christoph Hellwig Cc: "James E.J. Bottomley" Cc: target-devel@vger.kernel.org Cc: linux-scsi@vger.kernel.org --- * New patch from v3 drivers/target/target_core_sbc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/target/target_core_sbc.c b/drivers/target/target_core_sbc.c index edba39f..b765cdd 100644 --- a/drivers/target/target_core_sbc.c +++ b/drivers/target/target_core_sbc.c @@ -1299,13 +1299,14 @@ void sbc_dif_copy_prot(struct se_cmd *cmd, unsigned int sectors, bool read, copied += len; psg_len -= len; + kunmap_atomic(addr - sg->offset - offset); + if (offset >= sg->length) { sg = sg_next(sg); offset = 0; } - kunmap_atomic(addr); } - kunmap_atomic(paddr); + kunmap_atomic(paddr - psg->offset); } } EXPORT_SYMBOL(sbc_dif_copy_prot);