Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp44959ybn; Thu, 3 Oct 2019 01:05:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxUtRcpMl8kuCV9TtB9ZrpA6qN8LBqUb407DTE6wwpT/pZ5mmt6ah9DUpVA+b7p4/x0CFit X-Received: by 2002:a50:935d:: with SMTP id n29mr8128265eda.294.1570089928739; Thu, 03 Oct 2019 01:05:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570089928; cv=none; d=google.com; s=arc-20160816; b=jIryUdNlN7UrAQgjpn/TbAhMdJhjNpXJpg8lOEiWuWC/rYvfsWxL+fES1xEbC2MsJ7 BK/gy6+97yVRdHQSbjaMfIpJCwAz1ls0nkNveDgR7tvuhvfG7nWknyXCNbqa2TowNR8O FNf+inxf+KsKD7J4uo7w7OVh6WZ0+j1BVBZWWr6Oa627Urb6TarXaaiYD1lx0QBp52y+ cqV0xY4cQEMQl4gE85it0s0hcYnL/Ail6E8meVPKvIlURB3i6V0+ZTsZ5g5AFV+O5sV9 v8I5Pokkgp5FHKFMMz6mTrL/bqIyV8UqCCAs41e91wQGgPipDhUA4cy41w41JFMAzkzV P/8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=RFLlzP5Js98BS8nkgSfEvrEZLCP/SMDrxOQITXNt3eI=; b=r9CIZkAJyYb7znpq1nPrNo6MyWIWLn9FiMb6DSB9wyHVseFuTjdJIjJUFH2rdadKXf pgnmQ2nFl45VxxaC4AOXi3owEIa6X8N6DHg7dz2psoJdO0TlPpNxTUdLfIhe3SDLhf/x fdktz3nk8e6bcSGxADIuwRjAIDZNAbxoW3jM2A4T965Fk06Dbt+SPfrVhU/zkGx5hF4M 6BuwgwuybfAahhfwCkb/qnXhkimJFUy843I8AX4dDjrn4lcUXau5dzPZa/7uCPHlKcBi l0ZMaOIsmkb4mdXBeOgBHgSTyZCFMTIM6jtIxJeFZ+tSAir92PkxiEdwrs5YXOyw0LKm iReQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=T+inIGth; 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 i10si1048815ede.101.2019.10.03.01.05.03; Thu, 03 Oct 2019 01:05:28 -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; dkim=temperror (no key for signature) header.i=@szeredi.hu header.s=google header.b=T+inIGth; 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 S1728855AbfJCIEe (ORCPT + 99 others); Thu, 3 Oct 2019 04:04:34 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:42585 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728766AbfJCIEe (ORCPT ); Thu, 3 Oct 2019 04:04:34 -0400 Received: by mail-io1-f68.google.com with SMTP id n197so3368578iod.9 for ; Thu, 03 Oct 2019 01:04:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=szeredi.hu; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=RFLlzP5Js98BS8nkgSfEvrEZLCP/SMDrxOQITXNt3eI=; b=T+inIGthBvE2//4VZmd63eyRSLLLrR2dZV3XC6Gze72yu+iWc2TuhC9KAwqW1fcGZq V4qnPy9VgsX44Sy3xvd4Qo2blktM9gmPmA0CVDmErzDIOibLMHDVtUXsl8nOoesSbJ0/ artzBJciGJ5N7rJi9zsfVOYKuofa7muPcE6pU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=RFLlzP5Js98BS8nkgSfEvrEZLCP/SMDrxOQITXNt3eI=; b=I+TUqqVtjxl1fOWkE/jPS3VtZ//y3qb+clhMEYb7uLJnWBYRFtcC4Cxz4M3KVv4Lzz tmGk1gD7+w4TmjlLDIs6BjjifTpV+3lJ8uc5jQ10kbQhg9eW6XdkUARzUfMjAwxdDRtE OUPWAWMXeiO4UkXhgefWHWUoMHULnJPe59y55YVnfqtaO9my0/9gSf4K9W2lRJgNrPQy WwfQoSrN+msBU4MhTdmfDQ1cik8bpB0D/hq+4alLGnaHVUzzmPAstuPVYzcV8nCAuBys qAxFRzkFJ5tw/dlvxfVWCmdBIyX+n0xk7JTUMbTYBtrea1Vsu0LJoacfBI011U16N8iP gWCw== X-Gm-Message-State: APjAAAXZpFL8Ioee7qvufioY/AXhrrlcH7v+wHEZmROr4kmIQJgEVKxG uwEJyJIlwnBhyeUEuT1hwGMHC5zi3mulVq81oBI4fg== X-Received: by 2002:a05:6e02:4d2:: with SMTP id f18mr8908437ils.174.1570089873408; Thu, 03 Oct 2019 01:04:33 -0700 (PDT) MIME-Version: 1.0 References: <1b09a159-bcec-63c9-df42-47d99f44d445@virtuozzo.com> In-Reply-To: <1b09a159-bcec-63c9-df42-47d99f44d445@virtuozzo.com> From: Miklos Szeredi Date: Thu, 3 Oct 2019 10:04:22 +0200 Message-ID: Subject: Re: [PATCH] fuse: BUG_ON correction in fuse_dev_splice_write() To: Vasily Averin Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrey Ryabinin Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Aug 19, 2019 at 8:53 AM Vasily Averin wrote: > > 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); Better turn these into WARN_ON's.. Fixed and applied. Thanks, Miklos