Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp2333592ybl; Sun, 18 Aug 2019 23:55:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqz18+eXqybBv8wQ3agGryRaQx92Nd/PEs8xFxbH53Yg1vyZUMpSfqm44Ji0pkLtqwZ6g7TK X-Received: by 2002:a62:1ad4:: with SMTP id a203mr22190264pfa.210.1566197722288; Sun, 18 Aug 2019 23:55:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566197722; cv=none; d=google.com; s=arc-20160816; b=y64wpHdMY6l4AisYN/N/3IzEn0gNuBKuxxnmKrufvTIflHA4rhrx0At7xpoJutckmc 34uvzUid70z0+UVHhX1VZvL0gV02pl1REFkK1gvVzQaXjuDYcd8Chh5M+vsQoNPfu3VO igN4I2X8dRviTNVNi2LtLTGZVcDI3g6+SWwrixz/XZx2f+rb5UgKn+9fpmhK2qHRs7Pw VaCld/QTaeDL64Nouayf1Z/mqLu4bRs61hQr5zW8LHRBMTEvsCaVrygY8qPNEyTQ7s5S tDOrx14NjbuOprfr3TpcyMBZ1Tl+0njzpfgLIZoPRFTsrteoTYlpaLaWO0OWNyMv/g4F 1nCw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:to:subject:from; bh=Li8wyA84tqcPkK8z8IhdREv5Ttk3lpmM0aXxtXLC6mU=; b=FBEsJFA9R05nXy2cQMLf0QOGZKmi0fdfoPxWytyZEqtmVTOl+EqTiraXai80r0pXgM VAWFgVW6th3YtFAj3KwZacxK9Dy7aBwtjyzaOVIxZZ150MgKsBAK6IwMoeUZkg+86MZZ uI+1Af1wI381PPFqi7Ue7myAcnXr9BUzg4pqlwqJGSiAoHyGmsSkTBStv2lQvqave523 iVYuI7fMaxpC6v7XYaeC8jyRHsh/Bs4GWlxPoajjnRHq3COe/wShqHvvIcdHt2F7qikG aLGuGaikw4Qeme4b027ZH1dbnrwutd6++sKaJyQXm1jz0kZnVBU5PhKlsZS99+abXYwE dmDQ== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t10si9210647pgu.549.2019.08.18.23.55.07; Sun, 18 Aug 2019 23:55:22 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=virtuozzo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726628AbfHSGxz (ORCPT + 99 others); Mon, 19 Aug 2019 02:53:55 -0400 Received: from relay.sw.ru ([185.231.240.75]:45104 "EHLO relay.sw.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725871AbfHSGxz (ORCPT ); Mon, 19 Aug 2019 02:53:55 -0400 Received: from [172.16.24.21] by relay.sw.ru with esmtp (Exim 4.92) (envelope-from ) id 1hzbY7-0008J5-PI; Mon, 19 Aug 2019 09:53:52 +0300 From: Vasily Averin Subject: [PATCH] fuse: BUG_ON correction in fuse_dev_splice_write() To: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Miklos Szeredi , Andrey Ryabinin References: Message-ID: <1b09a159-bcec-63c9-df42-47d99f44d445@virtuozzo.com> Date: Mon, 19 Aug 2019 09:53:50 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org commit 963545357202 ("fuse: reduce allocation size for splice_write") changed size of bufs array, so BUG_ON which checks the index of the array shold also be fixed. Fixes: 963545357202 ("fuse: reduce allocation size for splice_write") Signed-off-by: Vasily Averin --- fs/fuse/dev.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index ea8237513dfa..f4ef6e01642c 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c @@ -2029,7 +2029,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, struct file *out, loff_t *ppos, size_t len, unsigned int flags) { - unsigned nbuf; + unsigned nbuf, bsize; unsigned idx; struct pipe_buffer *bufs; struct fuse_copy_state cs; @@ -2043,7 +2043,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, pipe_lock(pipe); - bufs = kvmalloc_array(pipe->nrbufs, sizeof(struct pipe_buffer), + bsize = pipe->nrbufs; + bufs = kvmalloc_array(bsize, sizeof(struct pipe_buffer), GFP_KERNEL); if (!bufs) { pipe_unlock(pipe); @@ -2064,7 +2065,7 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, struct pipe_buffer *ibuf; struct pipe_buffer *obuf; - BUG_ON(nbuf >= pipe->buffers); + BUG_ON(nbuf >= bsize); BUG_ON(!pipe->nrbufs); ibuf = &pipe->bufs[pipe->curbuf]; obuf = &bufs[nbuf]; -- 2.17.1