Message ID | 20221013151901.29368-1-cppcoffee@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp336454wrs; Thu, 13 Oct 2022 08:22:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6xxXIPcn3FGhJghHkfD8bKzwyjvHDKBPnbobTjcK61qQCphQJGw3hLrEvsI4Uev888646L X-Received: by 2002:a63:8549:0:b0:461:47e9:30df with SMTP id u70-20020a638549000000b0046147e930dfmr365556pgd.376.1665674572417; Thu, 13 Oct 2022 08:22:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665674572; cv=none; d=google.com; s=arc-20160816; b=KxJlHZ7Tyt/Bpvhco0GClHC+rcyEC0uyB19mDPMkAoY7HSQoPwv0ewq1MwMIP1XbS0 JdZ3wtgqYvyIQuRMWypvO99iGEQwXFQqJ9SzxJWS7/GnfN2IEiW7KrmKFWnQAt+fapP3 UiPXnE79yZwGUIVtBOFOidm7pgT8aFHbiK3zaNO/g9nL5Dh53sYArLchl+D429IfQUZU 6w91LJbWvEZzyjA+Dh5kRJwL2QPC7LVkx0es8FJ03NtItq2vnBsfGeHlOIzlpunE5M3r TNqhpTktIsoCp4htZ4vg9LIOqpTpFJ7RPev/9mbQsCc7CBd9x7Fj0N7Hbkrui61QSPmQ 6WpA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=3muxJhNWv1hg7XONepRN26NwBDFTg3vZFivnKP3G+hw=; b=lt9MlNEB4NGiwl/4DxT2UMs/bzjQqtTQWAQxs3J69iXI4hufUKqHswlYmS1GWV01rT Km77HVc3jb1osdFdw4ROUUKsIpfn7ixkZ7q6pRpDi8HFGJ7OPLN/cel+FKmnUG8W+j1c /KKimQSulCnpHLkIuDt1eVJLsn47acjCSmuLtGaiAwZ4tYOQ2SC/GORKC3bKOqyBzwJ9 6XWKTxy2ZZiuq22BvsOeCs3/pTqgk21t8Beej71ccGcYbdxCiErgDNdtTylRC3vj0PiR JPGvzwFTogLQbTwSzCuJQgsgpb0w8t1fc83QlHZs2DQAz7sEKtmie135PbGwGjtkMtUe tbmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=F8jmyvQu; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r7-20020a17090a4dc700b0020aedc078d7si5543062pjl.17.2022.10.13.08.22.37; Thu, 13 Oct 2022 08:22:52 -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=@gmail.com header.s=20210112 header.b=F8jmyvQu; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229791AbiJMPTT (ORCPT <rfc822;ouuuleilei@gmail.com> + 99 others); Thu, 13 Oct 2022 11:19:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229436AbiJMPTR (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 13 Oct 2022 11:19:17 -0400 Received: from mail-pg1-x536.google.com (mail-pg1-x536.google.com [IPv6:2607:f8b0:4864:20::536]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E13B8E09B2; Thu, 13 Oct 2022 08:19:16 -0700 (PDT) Received: by mail-pg1-x536.google.com with SMTP id b5so1822550pgb.6; Thu, 13 Oct 2022 08:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=3muxJhNWv1hg7XONepRN26NwBDFTg3vZFivnKP3G+hw=; b=F8jmyvQukbGYiASMQsZRXYBAgV0Gnw2M5nkuujeTetPf3rsaauv9xqFMQYUT5FQ9Ud Kzm0YATZRoKU5vKU9gHFXBPOg/rD6S1vhqv6hIGfuZ5kcBrh5w6IZ1bhSSzfKiOObQNs UMP6K5+2vUvly2DoPvsBAZPTKeTBWcakE49W3hgUx0wDOWxMeujG93vUGfR/2vPwxihL glDzsN22bDxXHParQbQfmUPIxzQ9MwKrKB2doeaqcqTfN1AHs0Ug/bw/R+8scqA8scOF OPyhkNNPjjHd0G2cEEHkktgDhX8FLhEX05vFqHnfXkoPY5X7RhhgLUPRx+nOr1bA73L7 naew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=3muxJhNWv1hg7XONepRN26NwBDFTg3vZFivnKP3G+hw=; b=owAIRCTwM6A/D/NIdjOS7XreUu6WAg/mKstc/IVC7VTfG9nCbvsDog6IKYRbdZrEpp SabhYpETPM/GQLuCjcA693pH43KpnZ43w333ZU6zHwn+lgpYJQ2HLNRHPpsBJsBjdE/P D9hx2A6teVfQShYSyrnLa6HRMk/7HBXCBnnPa5OXX48PEoGfkd+0pPIq2U3aCOtqVjiU ykY6+3L06vZo6jlDKZprari0/YD5YmWMj3PsPEkb86I+6atqHdeHxv/RUfv9G3O84/pC M4YkqpNkC8hoi4qnWMiB2+uYAen/Uu2ftN1F0brLehcY2RGwOVVIyFfKy3d2R93PdPgK zaNw== X-Gm-Message-State: ACrzQf3AQUrw9XP4OxlkAup5XVOF1VopfjkkjWaPcO55ftmphEB6soFG 7FLpHkBdyspC20PVjHUfLFg= X-Received: by 2002:a65:5688:0:b0:3c2:1015:988e with SMTP id v8-20020a655688000000b003c21015988emr349335pgs.280.1665674356367; Thu, 13 Oct 2022 08:19:16 -0700 (PDT) Received: from localhost.localdomain (67.230.176.239.16clouds.com. [67.230.176.239]) by smtp.gmail.com with ESMTPSA id j63-20020a625542000000b00562e9f636e0sm2260596pfb.10.2022.10.13.08.19.14 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Oct 2022 08:19:15 -0700 (PDT) From: Xiaobo Liu <cppcoffee@gmail.com> To: davem@davemloft.net Cc: edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Xiaobo Liu <cppcoffee@gmail.com> Subject: [PATCH] net/atm: fix proc_mpc_write 1 byte less calculated Date: Thu, 13 Oct 2022 23:19:01 +0800 Message-Id: <20221013151901.29368-1-cppcoffee@gmail.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=ham 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746586380372188469?= X-GMAIL-MSGID: =?utf-8?q?1746586380372188469?= |
Series |
net/atm: fix proc_mpc_write 1 byte less calculated
|
|
Commit Message
Xiaobo Liu
Oct. 13, 2022, 3:19 p.m. UTC
Then the input contains '\0' or '\n', proc_mpc_write has read them,
so the return value needs +1.
Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
---
net/atm/mpoa_proc.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
Comments
On Thu, Oct 13, 2022 at 8:19 AM Xiaobo Liu <cppcoffee@gmail.com> 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 <cppcoffee@gmail.com> > --- > 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; }
Hi Xiaobo, Thank you for the patch! Yet something to improve: [auto build test ERROR on net-next/master] [also build test ERROR on net/master linus/master v6.0 next-20221013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Xiaobo-Liu/net-atm-fix-proc_mpc_write-1-byte-less-calculated/20221013-232130 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 0326074ff4652329f2a1a9c8685104576bd8d131 config: i386-randconfig-a013 compiler: clang version 14.0.6 (https://github.com/llvm/llvm-project f28c006a5895fc0e329fe15fead81e37457cb1d1) reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/a873bf31a6f0de49f99feab479736ec2555de73b git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Xiaobo-Liu/net-atm-fix-proc_mpc_write-1-byte-less-calculated/20221013-232130 git checkout a873bf31a6f0de49f99feab479736ec2555de73b # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=i386 SHELL=/bin/bash net/atm/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): >> net/atm/mpoa_proc.c:229:12: error: expected ';' after expression len += 1 ^ ; 1 error generated. vim +229 net/atm/mpoa_proc.c 205 206 static ssize_t proc_mpc_write(struct file *file, const char __user *buff, 207 size_t nbytes, loff_t *ppos) 208 { 209 char *page, *p; 210 unsigned int len; 211 212 if (nbytes == 0) 213 return 0; 214 215 if (nbytes >= PAGE_SIZE) 216 nbytes = PAGE_SIZE-1; 217 218 page = (char *)__get_free_page(GFP_KERNEL); 219 if (!page) 220 return -ENOMEM; 221 222 for (p = page, len = 0; len < nbytes; p++, len++) { 223 if (get_user(*p, buff++)) { 224 free_page((unsigned long)page); 225 return -EFAULT; 226 } 227 228 if (*p == '\0' || *p == '\n') { > 229 len += 1 230 break; 231 } 232 } 233 234 *p = '\0'; 235 236 if (!parse_qos(page)) 237 printk("mpoa: proc_mpc_write: could not parse '%s'\n", page); 238 239 free_page((unsigned long)page); 240 241 return len; 242 } 243
Hi Xiaobo, Thank you for the patch! Yet something to improve: [auto build test ERROR on net-next/master] [also build test ERROR on net/master linus/master v6.0 next-20221013] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Xiaobo-Liu/net-atm-fix-proc_mpc_write-1-byte-less-calculated/20221013-232130 base: https://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next.git 0326074ff4652329f2a1a9c8685104576bd8d131 config: openrisc-randconfig-r035-20221012 compiler: or1k-linux-gcc (GCC) 12.1.0 reproduce (this is a W=1 build): wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # https://github.com/intel-lab-lkp/linux/commit/a873bf31a6f0de49f99feab479736ec2555de73b git remote add linux-review https://github.com/intel-lab-lkp/linux git fetch --no-tags linux-review Xiaobo-Liu/net-atm-fix-proc_mpc_write-1-byte-less-calculated/20221013-232130 git checkout a873bf31a6f0de49f99feab479736ec2555de73b # save the config file mkdir build_dir && cp config build_dir/.config COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross W=1 O=build_dir ARCH=openrisc SHELL=/bin/bash net/atm/ If you fix the issue, kindly add following tag where applicable | Reported-by: kernel test robot <lkp@intel.com> All errors (new ones prefixed by >>): net/atm/mpoa_proc.c: In function 'proc_mpc_write': >> net/atm/mpoa_proc.c:229:33: error: expected ';' before 'break' 229 | len += 1 | ^ | ; 230 | break; | ~~~~~ vim +229 net/atm/mpoa_proc.c 205 206 static ssize_t proc_mpc_write(struct file *file, const char __user *buff, 207 size_t nbytes, loff_t *ppos) 208 { 209 char *page, *p; 210 unsigned int len; 211 212 if (nbytes == 0) 213 return 0; 214 215 if (nbytes >= PAGE_SIZE) 216 nbytes = PAGE_SIZE-1; 217 218 page = (char *)__get_free_page(GFP_KERNEL); 219 if (!page) 220 return -ENOMEM; 221 222 for (p = page, len = 0; len < nbytes; p++, len++) { 223 if (get_user(*p, buff++)) { 224 free_page((unsigned long)page); 225 return -EFAULT; 226 } 227 228 if (*p == '\0' || *p == '\n') { > 229 len += 1 230 break; 231 } 232 } 233 234 *p = '\0'; 235 236 if (!parse_qos(page)) 237 printk("mpoa: proc_mpc_write: could not parse '%s'\n", page); 238 239 free_page((unsigned long)page); 240 241 return len; 242 } 243
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';