Received: by 10.192.165.148 with SMTP id m20csp1473631imm; Wed, 2 May 2018 23:15:54 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqsVbuT3mCIhg1GZ9pzygdzW0Y0PhI7CqvxhD0q/DYkRAC4KQcg4Rm1SFsx7qdtTGqa1P5F X-Received: by 2002:a65:5509:: with SMTP id f9-v6mr18462212pgr.317.1525328154531; Wed, 02 May 2018 23:15:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525328154; cv=none; d=google.com; s=arc-20160816; b=ohlA6cWC3ZKlSfEY+ddx34hBcibfJ0OcZqxJ5fpQi4/K5EHID0yrcfYN91hHaH//Kp Trlyja8MYxOLbZn0WyQaXVKOsSMUbZJmZDOU7LaWwfcek0RorG7wJVX974muTWkUAoZa O+qf/NCadSKE1niXgNN1SBWvgCp3mXRJ5XT2Pky3MCiZzKKZCJSILD872Qk+pglk4zZy sAQDo89efyThCcvQ0nLbJQClWlDBXfsNIglQficXZ4uBGnOwzPeD57aRGnNUlG1UgQNx 8v4On27YjR10F8rkalPRv0ghHqi6fl/EUohqs1/bZqAXbGZ4lpNmG1jOV7LMi6xedH5p +quQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:arc-authentication-results; bh=tMEESU8qKGwgfnhHpL4Fmyw7Il/kZVMlSX4FM3H9DVc=; b=lM8Zhn8ZdHkSUWmhK9Rtmci+NJN3nkI7YLRqXbMSrHxBS9iErQyVQxkPGYhVs301xJ 8L7C0CoJuevF5MKp8St5YLCdWCTXXWc+3LjjlEzx3IDANzkdsqYNDI0/sD/BBlHbCkP0 QMiIsmHh2HSebHB3GiN8+qz+yVkU76iVpwq+6nvTbSPdDz0jP79tvi4w3ZEyGp/LlWPg hQZqpCcnxezMomldTatmoX2fUszcUiKjtDMuLQ2BPC0UuFfXvKBf6/hZCMC9ylOtCb7O LvbBatzdFZ5Q8KWsANsiGf+5Vy9dKD0Ennb7b3U6e1dpUsF02mJDbQtmPstsncJD8RkU AJTg== 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 e12-v6si13117747plj.143.2018.05.02.23.15.40; Wed, 02 May 2018 23:15:54 -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 S1752006AbeECGP0 convert rfc822-to-8bit (ORCPT + 99 others); Thu, 3 May 2018 02:15:26 -0400 Received: from mout.gmx.net ([212.227.15.19]:53441 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750923AbeECGPX (ORCPT ); Thu, 3 May 2018 02:15:23 -0400 Received: from [172.17.46.226] ([122.224.77.194]) by mail.gmx.com (mrgmx001 [212.227.17.184]) with ESMTPSA (Nemesis) id 0LslCb-1eCUIu1TMf-012L0U; Thu, 03 May 2018 08:15:01 +0200 Content-Type: text/plain; charset=gb2312 Mime-Version: 1.0 (Mac OS X Mail 11.3 \(3445.6.18\)) Subject: Re: [V9fs-developer] [PATCH v2 1/2] net/9p: detecting invalid options as much as possible From: "cgxu519@gmx.com" In-Reply-To: <20180502153258.39b65209a0a85063441c6d85@linux-foundation.org> Date: Thu, 3 May 2018 14:14:55 +0800 Cc: "cgxu519@gmx.com" , ericvh@gmail.com, rminnich@sandia.gov, lucho@ionkov.net, v9fs-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8BIT Message-Id: <71B73328-C3E3-4472-986F-644A19209F65@gmx.com> References: <1523947502-6103-1-git-send-email-cgxu519@gmx.com> <20180502153258.39b65209a0a85063441c6d85@linux-foundation.org> To: Andrew Morton X-Mailer: Apple Mail (2.3445.6.18) X-Provags-ID: V03:K1:5MkK+O7QUzyMeP2xvEzeb+xyK5O6jKu232LV+PJhypY8KC9Ykch adMWBJGyokRwrgeuH77qTjOPez4uDEedOSfm39MHDBH1QQDRzNKgjkNI7aF6x9gjLsCKAog zqEKZ2ji+XLHh8Y7UcS4C4g/nfXdhD+DWwl9pbvARBPHW7Dh6hSEW78kRitLniKONEctACP LaoLZUuO8FbdLxyb+ALAg== X-UI-Out-Filterresults: notjunk:1;V01:K0:t9OH/jBzkWc=:fR4ZmYnCeKszhBiHfXiA3p h3ZXE40/aS2l6MK4FM8GZv8VcN+dtELyLX6odRv7bM0Pb/tzQfFalvLKDvtI6DClqUbXRPyiW bZCs1Cciz/+YXvQ8GZ1KJ4n90OZ7g5/gCEkSPPqMXosxLqpMhOFpV64Dv0LypLbXAXUEwhi4e /qjS4QElp6FmiWXTG7HWMxnJkweNGRSenNs7+AJyvWBwpsjOcdDFSxOy8jHnIwMm2MUV9tj3O LiClIXfrqfdMvqdQEM1J4yJ0GzrNAzkb22iFX6O4+MSqqMRgJB82iTcQBVcODu4mbnlm6DvDh CxvP3Z6EKrOTs3O0DkWJzH53vvzECZRkX6oe7uH3rx0RfsUj/Zc7q63JEiRo0FcPRRXxnAO9m DDVw92jEH7YnMLaxFr1F+spokE+0K2DxIoOslCWP/N9CBjplLv48JIjnIgf1UZJHPr3PabBCb yiRvtCqIi2hf1tykrOFi170PVskAS5XWEL5ERZ8OdJp3yeOwcqq2/EiMakmoECft4MaVeNQdR ZpHUcHSMCZyQAN4f4DczFLtZFhc7Tftih0SLdwCLh/lH37CPgjc/5BYCP3BP6ranxKWxNNg8X LpSxOVB/pr/YKeP5oYS91HtmhIiW/NXwRgBt/ef29/f5+xOv63bqh8aRs8/ip0wV6Kjkj4abX 9D+MQ3bDoq0FcrmyJiCPv+edwawkXtPV1OuxLhTZ7765E2VEd/ziHG0DhhNG+HIWcdhxvGtxf SfxNL7dmAH8iJH59vdgkI1H7JOPGlGcm9VtOKG+GYfUe0jUjKpDL0v8HEl7PhIWbEZrK0pCFA ahSWLHF Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for your review, I??ll fix the issue in v3. > ?? 2018??5??3?գ?????6:32??Andrew Morton д???? > > On Tue, 17 Apr 2018 14:45:01 +0800 Chengguang Xu wrote: > >> Currently when detecting invalid options in option parsing, >> some options(e.g. msize) just set errno and allow to continuously >> validate other options so that it can detect invalid options >> as much as possible and give proper error messages together. >> >> This patch applies same rule to option 'trans' and 'version' >> when detecting EINVAL. >> >> ... > > A few issues: > >> --- a/net/9p/client.c >> +++ b/net/9p/client.c >> @@ -199,7 +199,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) >> s); >> ret = -EINVAL; >> kfree(s); >> - goto free_and_return; >> + continue; >> } >> kfree(s); >> break; > > Here we can just do > > --- a/net/9p/client.c~net-9p-detecting-invalid-options-as-much-as-possible-fix > +++ a/net/9p/client.c > @@ -198,8 +198,6 @@ static int parse_opts(char *opts, struct > pr_info("Could not find request transport: %s\n", > s); > ret = -EINVAL; > - kfree(s); > - continue; > } > kfree(s); > break; > >> @@ -217,7 +217,7 @@ static int parse_opts(char *opts, struct p9_client *clnt) >> ret = get_protocol_version(s); > > And here's the patch introduces a bug: if `ret' has value -EINVAL from > an earlier parsing error, this code will overwrite that error code with > zero. > > So you'll need to introduce a new temporary variable here. And I > suggest that for future-safety, we permit all error returns from > get_protocol_version(), not just -EINVAL. So something like: > > --- a/net/9p/client.c~net-9p-detecting-invalid-options-as-much-as-possible-fix > +++ a/net/9p/client.c > @@ -214,13 +214,12 @@ static int parse_opts(char *opts, struct > "problem allocating copy of version arg\n"); > goto free_and_return; > } > - ret = get_protocol_version(s); > - if (ret == -EINVAL) { > - kfree(s); > - continue; > - } > + pv = get_protocol_version(s); > + if (pv >= 0) > + clnt->proto_version = pv; > + else > + ret = pv; > kfree(s); > - clnt->proto_version = ret; > break; > default: > continue; > _ > > > Similar changes can be made to patch 2/2. >