From patchwork Wed Feb 15 15:25:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Matias_Bj=C3=B8rling?= X-Patchwork-Id: 9574303 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A375260493 for ; Wed, 15 Feb 2017 15:27:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 343AE24DA2 for ; Wed, 15 Feb 2017 15:27:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 28D1B28249; Wed, 15 Feb 2017 15:27:22 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD6B924DA2 for ; Wed, 15 Feb 2017 15:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751734AbdBOP1G (ORCPT ); Wed, 15 Feb 2017 10:27:06 -0500 Received: from mail-bn3nam01on0043.outbound.protection.outlook.com ([104.47.33.43]:3526 "EHLO NAM01-BN3-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751175AbdBOP0M (ORCPT ); Wed, 15 Feb 2017 10:26:12 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cnexlabs.onmicrosoft.com; s=selector1-cnexlabs-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=1XeFM+0jpgSVjGX1Oh5fJLWVG9t/oPl6egAhBJL/jw8=; b=FpyoFlR32Qbj/5/T0hARWxnxnv7zerFE+79ZetgAnu6fZRJej86f5IehsuE0Hg7U0QfGTViH/MDirCqCqCOQHpKVChJ0DcgzJ6S6322mFM8Y02GQ3mWNyR6bo31siTnfadSXztTaaTRxqFLk16irbn78aNJY0AcZJkBl/yCv+P0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=matias@cnexlabs.com; Received: from skyninja.cnexlabs.com (193.106.164.211) by BN6PR06MB2769.namprd06.prod.outlook.com (10.175.127.11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.888.16; Wed, 15 Feb 2017 15:26:09 +0000 From: =?UTF-8?q?Matias=20Bj=C3=B8rling?= To: CC: , , =?UTF-8?q?Matias=20Bj=C3=B8rling?= Subject: [PATCH 1/2] lightnvm: fix off-by-one error on target initialization Date: Wed, 15 Feb 2017 16:25:32 +0100 Message-ID: <20170215152533.9712-2-matias@cnexlabs.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170215152533.9712-1-matias@cnexlabs.com> References: <20170215152533.9712-1-matias@cnexlabs.com> MIME-Version: 1.0 X-Originating-IP: [193.106.164.211] X-ClientProxiedBy: HE1P195CA0009.EURP195.PROD.OUTLOOK.COM (10.171.121.19) To BN6PR06MB2769.namprd06.prod.outlook.com (10.175.127.11) X-MS-Office365-Filtering-Correlation-Id: 98a0e31e-2323-4cd6-6d5d-08d455b6f7fa X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001); SRVR:BN6PR06MB2769; X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2769; 3:r0sk3JPQHP8GOQEGoG+oTbMgaOp7sMnwEEvYtuHR9ONunvoAizFK91xaGpZNzwkFLfuScyHgj8n9K791XYPBgw5S7yTLomvlEThT2mV+wL5CfFKXOvrr2u/dnD2XnFRuLtqyIovqu07x/P8gbEx8Dz13DrvHohZWyqYQXhq4Qh9bKJ9hIjev/fLWWNfzoLkAPu7J9r3a1+eCWwG6A94KQHWZbi2Igq8BhFPApzJOAINC7nHreS0O52c47wO2uRNOhMhukOmCz/W5j+QBCFv2kQ==; 25:DD7OVE/6PvdrssJaELyf9rIVVodFVYIuP2mbQyvHm36omBixw6B2uGwphrpWwPs5wDpUkQZK472i+KrkhBqK7zUamczw/IZ6CgZh21didc4QY/7GXy4Yilt/dvZPc+Fil2zLMoFez+GUBFTIR6HbETgUF7/WAiCGS0ry8Y90/naNHAht+mQX3c3qqZR13lCzaCxaUTcngM29RwIDjo/O9rAykKuyS17HJyk/n52TJVUZIGPDdSMNr4zRqXMCsTs8/sp1DzkVfn2p2WD2V34H0fUmWmPfEQ7dpLIPB33Kl9kaD5ELxFT+X5bFqVgLHCF02qeARNHkQW02UZufs1srHXIuFcgw4Ti1A6SwTFdC3E3u2jWjx5j7fSfv1CEYapRpZ9lAlCw3D+n7Wt9BL9z8lbE7x7+co4g+pbQt036UZTn0bVm3rb7j1reejMy3aW99bYevPg3GHp4kDr0WlpnRyg== X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2769; 31:vt0e+wK4U47gR/95Fk2uOoT08bLAQQ5Brb4meQxTZ7zctaL+ZtHLqUSX9AH4NpzLl9FREqo0LBYod/WRGUsywIH6zoe90FAuSroHVrP5tdcU/rA1SumfUeS2UUd+jK0UMcidySn89ql5FuvOOI61M8pa/EacEb+EG9C2t/tGoTT0+Y5sE9MVQBSzDuYbus3yG3kiS4N6jh5SxXJNCtMBzYdDfX9xy69sNZ6eUqihNGc=; 20:QuwRUT1otEBdIcLS4so2lW4TVCviXRMS4QoFYikLofP1VzR50xt+zP8f5s6iaRnHu2Kb91F8gup2oNtK005fVLpeswN0w+bZGsXffcxFdFsd7ok6oqwrhL3dCQFm3wjRvVhRiw+TCx1ZfKNT8oaU67qZqlqUFKBHx0L8qkNJgT4= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6041248)(20161123560025)(20161123558025)(20161123555025)(20161123562025)(20161123564025)(6072148); SRVR:BN6PR06MB2769; BCL:0; PCL:0; RULEID:; SRVR:BN6PR06MB2769; X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2769; 4:OImDBPKToTi2PwWuVg5wYPiz2Wds0A9AR7SIplozMVEJ39q5VuIj8ZtNFYCG0t5IoyT2FjkJz41cdGPO6CblknsQ+QaCLy0CAiBbhZJ+ezuEz7z3UMzbLfgeCKKpp2//BouMdS+kFx1Whb6j2WRNFKqSYavB4nMGk0jge1wjaDohXtKJ78ZpgYUjfVK2Ezm/ts6M39N/ceU57Ij+pJVbe3HM1XLoR9Ss7U32TKNNdBkZp//BzlLuyg8fBcc3/LlGxv4Q1qIOP9HbZMm3fgGscC555lHsMYtMt+Ixm96Spr9lcVDEPkK6I08JnlqI2UCpvZ5yQuUuFtMXVO4ClWoIMD5L3litzwgYtR0n3M8FMQC//L7B06qK5ch5ydrHOgEUDYa9jEnYIVZK95vW5Zubs7E08MDCWmetB30hu08vPBuHfTWT9PAe++RweoNPb0z8z337pig0wLBQ+/R/1JI67VkVeyg+4OYLMw7JFhXzGlRa9vBOjj4++gKtqNBTjvmBfPhgaAUw5DAba4B8OUFZyNGyGRqWf2tHZyGirRdVkgVLwZTT1uO7U/k4Ft0zLyO5SuY7wmokoVDTxRowQt6+fF8fWYkGEMbqIHRvOXccxKU= X-Forefront-PRVS: 021975AE46 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(39450400003)(189002)(199003)(106356001)(6916009)(6666003)(2351001)(1076002)(66066001)(105586002)(2950100002)(2870700001)(54906002)(36756003)(53416004)(4326007)(5820100001)(50466002)(8676002)(2906002)(81156014)(86362001)(389900002)(33646002)(189998001)(6116002)(81166006)(47776003)(25786008)(50226002)(110136004)(50986999)(53936002)(7736002)(305945005)(42186005)(76176999)(6486002)(107886003)(3846002)(38730400002)(68736007)(23676002)(97736004)(230783001)(101416001)(5660300001)(92566002)(69596002); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR06MB2769; H:skyninja.cnexlabs.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cnexlabs.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtCTjZQUjA2TUIyNzY5OzIzOkRhTE9mQ3h1VnNwUVF4QlFtd1daY2NoUGV4?= =?utf-8?B?WWYrdjdQeVdzUkVmVnBvWlhaU1RqSktKaFVSbFc2WTU4eG1MQ0FQRllJNCtP?= =?utf-8?B?aklzS2JhUEdTOHAwYkEwQjhxVzR0bm4xNXFXTXU2amU0RktrRUdKaU1jZHlu?= =?utf-8?B?N1pURkx3dTMvN0xWcVYzMGF4ZlYvRk1ZeDY5LzQ3TFZEV1N6VFBkY01JY0tQ?= =?utf-8?B?eGxYUGRnU0xKZUpJYnJQSDNrTHphODlVcXNxYW9na0UrSFN1TXZwT2VUNGRi?= =?utf-8?B?aXRiVFFRM2ZZMDZha3R6TTV2K3BYZkRrUDhXSXVOUUx5SVZmLytWelU1SDhh?= =?utf-8?B?bkV3czlyQmo1TGRjcHgzTFRNcFhMMzBKcU4xd2YzWEVOLzE4WWY5QUw4ZEpr?= =?utf-8?B?R2Q3N2VFQnp2SHBOelAyRGdBWWR2MUlubUZKTlgrNFowQ2pUTTVNb3RXYnZt?= =?utf-8?B?eE5INmVVV1V0N1VNRC9TaUhYeXQyL0h0NTdqT1UxdFl2NUVBaS9jNmI0cE12?= =?utf-8?B?MFp4aXNTeXQyeVhhTkdPaFg1T2NxeVZNa2llejdyLzVSeEpsdStGcjBPaTdD?= =?utf-8?B?UEsvdklhVW9jdFFnV0FndjlwWXplTVdHelJ4Q09OVlV1OWZuK2pKWVlHYnJP?= =?utf-8?B?eHQ1d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3dsL2gw?= =?utf-8?B?VFZUTG1Bamxxd2grYXl3M0haNVBLKzFXZHdkT29iVExVaWwwSmtpQmNFUWQy?= =?utf-8?B?bjdPd29PdjNNcitXZ1lsRmNjdmY1RTQ2UGpkQkxKNnJ0Z1VFc3RPYjdpYTBl?= =?utf-8?Q?2zwX+lXA6lmtNxL41E=3D?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2769; 6:0uzUu7pBa6VfKmLPlIPT8y11w+1NritNst4CQpzM/pfKS4LJsFr4FEGTlLDAhSqGXccFa1B9eF+x8v5oeScZdnu/fhFK6P5vs7pPhJjOda87SpdlYzIPR/G7KOvcDVeIhnJL5DvF2J/u7Mv+B6OrlChh7iSI34Q9+9/5X4i+RzHEJBJDRZ1qg/+ST/ieBJFyOFAZ/UIP+htP0aJtfA3g+Gv3nEb605OFa/T9DyAZFHtD1l33hB5O2UsiVuifnkfzhPW8ZBYmtd7RahX3+6gE/vtK82h2XbhkozipHwLbOY81jCOim0p/EUd5NUW3EKDFCFG6fvveHIOi5gh9BNvGlMU60B9Yf/gwlYf2QddHrAbQgCoRocKXHXCZOK2Hm0QLAegpnKCtAj4OPVqnjfM7zQ==; 5:lIvDBokBNVnBNEOcTLDMO7GjT67xE4igGH04Wa63Eu7w35S1nGfcGr4SeqSSznWhRAS4aIDzsv8TR0saVZ5cpVx4lCcGgccUA+RqrWfENTixLwxQgNAWykmmNXLeYj0076Dya9hfrb19FeKK4wtDBw==; 24:8FjuHtJ93EfCgRpmNBS+1SzilgO9GUju6pMHZcbrsrVpl08ChRfpLpRDrDVlnJqGs5ibvgceLCo6EvLxxvty/OWA4bP5lwUbyzulOhDKKW8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BN6PR06MB2769; 7:hraiMcN76x2oP1E44qz+pkhxPcIDhxbprK6sLIVtBVt9FHAdI5d3gFvQit4WQd35jJlQXPVLEXlLrE8wYWYbM8khHsh+JoxvzthIriqoYXIJK01GhfFmM/wR2zolxzxWjwnYMlJ0RRL54OzxN6PAgfYU26J8UHXnrq8cE0wZoGXLf+yKf6u3s/xQpuqpBUtTM2tkQEHmK+ANsqLRVZZ+aTWlxh6nSNIB4+FdDDe+iM8Dz6xmfkv7YPbsS2kMRC1LrRyUAZz0ehze4aVPVWiaQ4uuUwM/TFO28atb2BuFnVFvClUAvf4MVGHidmGGpxCPZJKihMqk7s1xZ4CfMA/KUydbGR8kGXzUPvdTm9aZf/g22+Y1Rpqf79EPLYLoV5vK2pDN3C8eAUIk6TASAIGs0UmaUzU5132iaVF92gGm04zzx4bVD9u//JznaZUSNm4Uw5xby567duI2uK4+jwFggoD4eKvWmw8ye7nreXmWie7SloZ9qefW+V8jCRrHOfnbbZy1IKDDhzdBVT3zqHAo2w== X-OriginatorOrg: cnexlabs.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Feb 2017 15:26:09.0979 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR06MB2769 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If one specifies the end lun id to be the absolute number of luns, without taking zero indexing into account, the lightnvm core will pass the off-by-one end lun id to target creation, which then panics during nvm_ioctl_dev_create. Signed-off-by: Matias Bjørling --- drivers/lightnvm/core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/lightnvm/core.c b/drivers/lightnvm/core.c index 9bfe035..6ce76c0 100644 --- a/drivers/lightnvm/core.c +++ b/drivers/lightnvm/core.c @@ -1102,9 +1102,9 @@ static int __nvm_configure_create(struct nvm_ioctl_create *create) } s = &create->conf.s; - if (s->lun_begin > s->lun_end || s->lun_end > dev->geo.nr_luns) { + if (s->lun_begin > s->lun_end || s->lun_end >= dev->geo.nr_luns) { pr_err("nvm: lun out of bound (%u:%u > %u)\n", - s->lun_begin, s->lun_end, dev->geo.nr_luns); + s->lun_begin, s->lun_end, dev->geo.nr_luns - 1); return -EINVAL; }