Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp731944imm; Thu, 13 Sep 2018 06:59:31 -0700 (PDT) X-Google-Smtp-Source: ANB0VdariTOOC1ij0U38QAOX430adMjEZA3UJVcZSuLPrlSEndPbg8vCDlQuVzznSZvGkfP9r+1c X-Received: by 2002:a17:902:6b47:: with SMTP id g7-v6mr7575521plt.128.1536847171797; Thu, 13 Sep 2018 06:59:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536847171; cv=none; d=google.com; s=arc-20160816; b=ID3rLJxVgDNk79adylrJ71rKbl4D7+AUv1+JoZBHVni/W4xqFbz7BeyyzvCpbvZp8N cu47/eA1KwJkHS1wJQZNE81Zo4sJdmtlIBuAjExzGZHNGgy6JsLsEa6Lc+A1r7jey9wP dXL9qWh0CvuSHzTQWJ8mS4uySK7mMAe4cbdgcysEMLVdOYZ2IB3UP2yAdsNXIaLisn3L j6v/5+BOCPTBe6Eb2zK9lJ6GaWdy2HGDeni69c6SZMGoH4NUudNkjTBzSaYO38lrc8af yDY5WImHkCssIT7k5FtBzJEGRjwpOYVq7XFgCdEjISnv6B/nIfMHlnNdWfc9moUxXr+D wykA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from; bh=9xSPCgZMN94ATYgIgoef43iostOzh6qsFrau5hAL7MY=; b=MMTBoby7RltvOSX6jL1f3KebSnLp28T4SVIJKtFp1CJWlnGfHtPMasN95qrWwuxwDf iDgZkdVp4rUXz6wHEP7ucQc2GwS8omJtjKsq87cUkHMNktErIJHioqBVLI0n2nnPB8SY UOBqqVSOY1/lgK2vdP0ouzFSEWmfoab1cqlWXQolLHvCe84cdLp/5YOmqOxmk30YV62t pdIuQtW0aATAbpTiF8mjfDHuKQZRS9VpndyXSZ+5Yvt5Jixmjh5vt/Eueb36jh3stm0d ne4dkvkfkbHaVmm+LQaJL9rlYUw5AFti+IarLKlXvijsI5tr70RbHdHcNtaJRIZTV1EK C5Lw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y193-v6si4003827pgd.512.2018.09.13.06.59.16; Thu, 13 Sep 2018 06:59:31 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731504AbeIMTHU (ORCPT + 99 others); Thu, 13 Sep 2018 15:07:20 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:34410 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731329AbeIMTHT (ORCPT ); Thu, 13 Sep 2018 15:07:19 -0400 Received: from localhost (ip-213-127-77-73.ip.prioritytelecom.net [213.127.77.73]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id D392CD0E; Thu, 13 Sep 2018 13:57:42 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Greg Edwards , Jens Axboe , Sasha Levin Subject: [PATCH 4.18 101/197] block: bvec_nr_vecs() returns value for wrong slab Date: Thu, 13 Sep 2018 15:30:50 +0200 Message-Id: <20180913131845.587435113@linuxfoundation.org> X-Mailer: git-send-email 2.19.0 In-Reply-To: <20180913131841.568116777@linuxfoundation.org> References: <20180913131841.568116777@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Greg Edwards [ Upstream commit d6c02a9beb67f13d5f14f23e72fa9981e8b84477 ] In commit ed996a52c868 ("block: simplify and cleanup bvec pool handling"), the value of the slab index is incremented by one in bvec_alloc() after the allocation is done to indicate an index value of 0 does not need to be later freed. bvec_nr_vecs() was not updated accordingly, and thus returns the wrong value. Decrement idx before performing the lookup. Fixes: ed996a52c868 ("block: simplify and cleanup bvec pool handling") Signed-off-by: Greg Edwards Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- block/bio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/block/bio.c +++ b/block/bio.c @@ -156,7 +156,7 @@ out: unsigned int bvec_nr_vecs(unsigned short idx) { - return bvec_slabs[idx].nr_vecs; + return bvec_slabs[--idx].nr_vecs; } void bvec_free(mempool_t *pool, struct bio_vec *bv, unsigned int idx)