Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp371698imm; Thu, 2 Aug 2018 21:24:59 -0700 (PDT) X-Google-Smtp-Source: AAOMgpdtnFnf076wJpWIxbJA0XUA/XXsIVtBReYNVpp2+90UxmHc/pI/qN//m6U0Sy+HkuuWQryn X-Received: by 2002:a63:e74e:: with SMTP id j14-v6mr2080880pgk.185.1533270299252; Thu, 02 Aug 2018 21:24:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533270299; cv=none; d=google.com; s=arc-20160816; b=LMpF0y6PvYGWAILPBxFrP+r0rRCVVX6IIAphVon7oEYyEVEotjy3tqrA30Qr+yVHdP ILF2I12EQSVtbcjvDqE1Mzf6XVoO3V6Ajr1p7sRfGYyGgzkMyDTseHWJ341FWDTueXDh DR03P8P/zoKQ6ov762DXl2gEkq5mQZoLz06LhaHo3VjYBwFeaBowMjM2WwgIGVoDCrD2 rM6gWd5FWt/w55tsn1Dz8RhCKfLjZIWgaC45XSiZBYnkiK0BYB0xck52i8x2yR+vDOWN a8tM4RXV7EAkCNt7C9CyfT2MMC73kdkq82FlaAR73sPt0jhlHVPGLkd3UCYvDjSCpoP5 dKcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=qXhQIqSgZZcd8TfMn5CbLoe4qMEn6NZ8FI8mCgYFC8g=; b=OaioZ20U74Gtheg2XLcP9fbdU/53tpQ/fMN0j+Iby0kvnhqe50mhOfHINxEFTX/MHr hLqMts/asnfKM21j2JrbCNI5wnn1dvKEgAu2fCQV4KmZYHXjNuMOOx+G8mFHcXNeJk6i AtJ6ixGVanJdjE+CzqAJKQssi38aBQeFB42HJ7BnTsVbOBghdWHQtXnlcybVdS3iHREQ /E8O3XXVXw7J54gcVj3ykzrg0C7sooACt+ZgzlcHZhHXyqeoXzMCR4WMK6d3xLA0mB7Q dLJd52/PeubHmh98yA0y0Q00AUHGRIVd0jSd/oukZST059+nzbniQ7T6vSgcJc2SP085 GKqg== 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 g12-v6si3674780pfh.346.2018.08.02.21.24.19; Thu, 02 Aug 2018 21:24:59 -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 S1727343AbeHCGRr (ORCPT + 99 others); Fri, 3 Aug 2018 02:17:47 -0400 Received: from nautica.notk.org ([91.121.71.147]:34320 "EHLO nautica.notk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726571AbeHCGRr (ORCPT ); Fri, 3 Aug 2018 02:17:47 -0400 Received: by nautica.notk.org (Postfix, from userid 1001) id 3AE7DC009; Fri, 3 Aug 2018 06:23:23 +0200 (CEST) Date: Fri, 3 Aug 2018 06:23:08 +0200 From: Dominique Martinet To: jiangyiwen Cc: Eric Van Hensbergen , Ron Minnich , Latchesar Ionkov , Linux Kernel Mailing List , v9fs-developer@lists.sourceforge.net, netdev@vger.kernel.org Subject: Re: [V9fs-developer] [PATCH] net/9p: Modify the problem of BUG_ON judgment Message-ID: <20180803042308.GA4618@nautica> References: <5B63D5F6.6080109@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5B63D5F6.6080109@huawei.com> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org jiangyiwen wrote on Fri, Aug 03, 2018: > Because the value of limit is VIRTQUEUE_NUM, if index is equal to > limit, it will cause sg array out of bounds, so correct the judgement > of BUG_ON. > > Signed-off-by: Yiwen Jiang I'm not sure you've acted on his mail or if you found this independantly, but this was reported by Dan Carpenter on the list in June. Would you mind if I add a tag for him? Reported-by: Dan Carpenter That aside this looks good, I'll take it. > --- > net/9p/trans_virtio.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c > index 6265d1d..08264ba 100644 > --- a/net/9p/trans_virtio.c > +++ b/net/9p/trans_virtio.c > @@ -191,7 +191,7 @@ static int pack_sg_list(struct scatterlist *sg, int start, > s = rest_of_page(data); > if (s > count) > s = count; > - BUG_ON(index > limit); > + BUG_ON(index >= limit); > /* Make sure we don't terminate early. */ > sg_unmark_end(&sg[index]); > sg_set_buf(&sg[index++], data, s); > @@ -236,6 +236,7 @@ static int p9_virtio_cancel(struct p9_client *client, struct p9_req_t *req) > s = PAGE_SIZE - data_off; > if (s > count) > s = count; > + BUG_ON(index >= limit); > /* Make sure we don't terminate early. */ > sg_unmark_end(&sg[index]); > sg_set_page(&sg[index++], pdata[i++], s, data_off); -- Dominique Martinet