Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1120058rwi; Thu, 13 Oct 2022 09:16:55 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5Sb664LUenEVi6R4qQpduMMciUxIbmC2aylvGavs+5EFqhOhWa/Jm7j1J2X4H+GxOIpX78 X-Received: by 2002:a17:907:7f07:b0:779:7f94:d259 with SMTP id qf7-20020a1709077f0700b007797f94d259mr360557ejc.525.1665677815318; Thu, 13 Oct 2022 09:16:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665677815; cv=none; d=google.com; s=arc-20160816; b=BqtwmkvhbC/X7va28bK078f+UIMCkeUiNbjX2OwhpcCzMv8YA/oOZoGIR+h0bgOnni 09YhSllxVCUnxwfEcMlQm+QOmYn3gtvJ9iDvLCcOjyITl2UwlAHheVQ23sMlEx0sYngk MOsoMaJ5cq0sdUSQt3fLSuat6sGYPCfvFHQwKvflgiTNyqnNtkG3HsbTCk+s3N4OU4H7 qbJBnpOUyNg71ULJIUWFlAJcU6/I4tsNCasoVDBkEz91fskG7zCH6Y6XhkoiobN0c7/Y bbLmIhkJh3/vLOe7+BpCgDrsWoL8vmI0Zf/yuwoKgNFuZovmKN23r3eTNh7fjQJG0GIe aOYw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=gFTFokgNHTGaQylOsGEna9aC1ySQtkamEeN27nYYtMo=; b=lpK15I53ztjkQCmOZLDF+4gIyn7sEf/7ubz+HXiLPQlCvtm1YZeFZF/rDeVhEbWeet YRDEuBHuT5tQW5nCc/Qk88fSYUKm8Cbsl22DfKebnBf2dShSNXzFj1sOVOhJ2+KVipNh 2jIgqC0Bd/ss2GGtOkSfgZPb0P4TRU1CRrdUJw0b4JK1guDrwgrVwK7XARTUj+wej3Ii XRdbqXc2CnvH5rr0YTYiqZXB+ubycsWVS3A3mByhAABr6WbwfFHWmDlYMQ6Ow60jSbwE iiV7ABYrktGo05zkDvsf9THTO3/4ZJatum0KmLLPH1nBrQs8L/EZ0NGVP4ATjDAa+nag jSYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZfLz0Qdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd44-20020a17090796ac00b0078cb8b09d34si111181ejc.216.2022.10.13.09.16.26; Thu, 13 Oct 2022 09:16:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=ZfLz0Qdi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbiJMPhX (ORCPT + 99 others); Thu, 13 Oct 2022 11:37:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229459AbiJMPhV (ORCPT ); Thu, 13 Oct 2022 11:37:21 -0400 Received: from mail-yb1-xb36.google.com (mail-yb1-xb36.google.com [IPv6:2607:f8b0:4864:20::b36]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F26C9BE2C8 for ; Thu, 13 Oct 2022 08:37:20 -0700 (PDT) Received: by mail-yb1-xb36.google.com with SMTP id y205so2454296yby.13 for ; Thu, 13 Oct 2022 08:37:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=gFTFokgNHTGaQylOsGEna9aC1ySQtkamEeN27nYYtMo=; b=ZfLz0QdiG9JBjp7/wEbV0kPjVt5hjZm/ZfmjnY7krnW3YJ51i4IZNCm/42GSkTLfsi 96OYRIV113x7VnJuK0maHfWcnG8QFdVZIjHe/0PNePOvzphvuxlgmYwqSAd+Sb5FUOSd XpcqG7xnc/ayC4mGz7aPyPDM+koPWVNEfndV/AQr7XoatkXvw/DbdiOOgPATeZWELPch loJ5aCEYuTaZiSCH6eohOgmCB3LoCp7/MYBx/4P4+x8XF+v3ZK/nY38AoaHpgIP8aHMz 241UX7NA0+zvmIw4JsTmNUbAurwfxxl+Vn8spwjRfKusHAORCRndam+Fh33IAn3iSh0w nOcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=gFTFokgNHTGaQylOsGEna9aC1ySQtkamEeN27nYYtMo=; b=Ayh3heMZRbBYb8OZTfrIXuJyR7dKPhcL1SWcNcxi69Xc2/5iGYOadFwf84JNoS0YSm DYFzjLrqn6x2oJptYJQpMfQLb77exQUJwQWYA0QnKAny6dfcEX8yNYPi7GheTUxB3u8M QocPzsq1+UKjGLOYkBqV6TX2ki7E0553fhOYaVH5N0f7ogPpfF5NsIYbYXX4NEa3c3BV XLNqpizzFsgq1R08wwN1aA73fe13UY4VLYeo4zMOcr9wjboEhzVqT1tY5AlNRQvS2tZl CLho1G+Ah7DXvHJC+/mHQybRdjd+3XFG4++/y6NGSgarzXGeRrlJ5eT128kHZ3dnU4YU rwWw== X-Gm-Message-State: ACrzQf16ygC13rbDTDkcfLtOjD3VQZfcTRurszQ9vXyz6glePYk1YyBl FAan+g05+oBphqfE7x7MBv2Xac7u3WqlnXbBBkmdtQ== X-Received: by 2002:a25:ccd0:0:b0:6bf:d596:72ff with SMTP id l199-20020a25ccd0000000b006bfd59672ffmr542750ybf.598.1665675439989; Thu, 13 Oct 2022 08:37:19 -0700 (PDT) MIME-Version: 1.0 References: <20221013151901.29368-1-cppcoffee@gmail.com> In-Reply-To: <20221013151901.29368-1-cppcoffee@gmail.com> From: Eric Dumazet Date: Thu, 13 Oct 2022 08:37:08 -0700 Message-ID: Subject: Re: [PATCH] net/atm: fix proc_mpc_write 1 byte less calculated To: Xiaobo Liu Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 13, 2022 at 8:19 AM Xiaobo Liu wrote: > > Then the input contains '\0' or '\n', proc_mpc_write has read them, > so the return value needs +1. > > Signed-off-by: Xiaobo Liu > --- > net/atm/mpoa_proc.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c > index 829db9eba..444ceda60 100755 > --- a/net/atm/mpoa_proc.c > +++ b/net/atm/mpoa_proc.c > @@ -224,8 +224,11 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff, > free_page((unsigned long)page); > return -EFAULT; > } > - if (*p == '\0' || *p == '\n') > + > + if (*p == '\0' || *p == '\n') { > + len += 1 > break; > + } > } > > *p = '\0'; > -- > 2.21.0 (Apple Git-122.2) > Hi Xiaobo Can you submit a v2, with this added tag ? Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Also, I would switch to something cleaner like diff --git a/net/atm/mpoa_proc.c b/net/atm/mpoa_proc.c index 829db9eba0cb95ac9cfe775e8eaad712943a8dbe..df530e9725fa63820a7adcd44e750db0733f9d94 100644 --- a/net/atm/mpoa_proc.c +++ b/net/atm/mpoa_proc.c @@ -219,11 +219,12 @@ static ssize_t proc_mpc_write(struct file *file, const char __user *buff, if (!page) return -ENOMEM; - for (p = page, len = 0; len < nbytes; p++, len++) { + for (p = page, len = 0; len < nbytes; p++) { if (get_user(*p, buff++)) { free_page((unsigned long)page); return -EFAULT; } + len++; if (*p == '\0' || *p == '\n') break; }