mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: liqiong <liqiong@nfschina.com>
To: Julian Anastasov <ja@ssi.bg>
Cc: Dan Carpenter <error27@gmail.com>,
	Peilin Ye <yepeilin.cs@gmail.com>,
	Simon Horman <horms@verge.net.au>,
	Pablo Neira Ayuso <pablo@netfilter.org>,
	netdev@vger.kernel.org,
	linux-kernel <linux-kernel@vger.kernel.org>,
	lvs-devel@vger.kernel.org, netfilter-devel@vger.kernel.org,
	kernel-janitors@vger.kernel.org, Yu Zhe <yuzhe@nfschina.com>
Subject: Re: [PATCH] ipvs: initialize 'ret' variable in do_ip_vs_set_ctl()
Date: Mon, 12 Dec 2022 15:05:30 +0800	[thread overview]
Message-ID: <272315c8-5e3b-e8ca-3c7f-68eccd0f2430@nfschina.com> (raw)
In-Reply-To: <7758482-42e8-9057-b568-3980858267f@ssi.bg>



在 2022年12月02日 19:26, Julian Anastasov 写道:
> 	Hello,
>
> On Fri, 2 Dec 2022, Dan Carpenter wrote:
>
>> On Fri, Dec 02, 2022 at 06:18:37PM +0800, liqiong wrote:
>>>
>>> 在 2022年12月02日 18:07, Dan Carpenter 写道:
>>>> On Fri, Dec 02, 2022 at 11:25:11AM +0800, Li Qiong wrote:
>>>>> The 'ret' should need to be initialized to 0, in case
>>>>> return a uninitialized value because no default process
>>>>> for "switch (cmd)".
>>>>>
>>>>> Signed-off-by: Li Qiong <liqiong@nfschina.com>
>>>> If this is a real bug, then it needs a fixes tag.  The fixes tag helps
>>>> us know whether to back port or not and it also helps in reviewing the
>>>> patch.  Also get_maintainer.pl will CC the person who introduced the
>>>> bug so they can review it.  They are normally the best person to review
>>>> their own code.
>>>>
>>>> Here it would be:
>>>> Fixes: c5a8a8498eed ("ipvs: Fix uninit-value in do_ip_vs_set_ctl()")
>>>>
>>>> Which is strange...  Also it suggest that the correct value is -EINVAL
>>>> and not 0.
>>>>
>>>> The thing about uninitialized variable bugs is that Smatch and Clang
>>>> both warn about them so they tend to get reported pretty quick.
>>>> Apparently neither Nathan nor I sent forwarded this static checker
>>>> warning.  :/
>>>>
>>>> regards,
>>>> dan carpenter
>>> It is not a real bug,   I  use tool (eg: smatch, sparse) to audit the
>>> code,  got this warning and check it, found may be a real problem.
>> Yeah.  If it is a false positive just ignore it, do not bother to
>> silence wrong static checker warnings.
>>
>> The code in question here is:
>>
>> 	if (len != set_arglen[CMDID(cmd)]) {
>>
>> The only time that condition can be true is for the cases in the switch
>> statement.  So Peilin's patch is correct.
>>
>> Smatch is bad at understanding arrays so Smatch cannot parse the if
>> statement above as a human reader can.
> 	Yes, no bug in current code. But it is better to return the 
> default switch case with -EINVAL (not 0), in case new commands are added.
> Such patch should target net-next, it is just for compilers/tools
> that do not look into set_arglen[].
>
> Regards
>
> --
> Julian Anastasov <ja@ssi.bg>
Thanks, I will send a v2 patch.


  reply	other threads:[~2022-12-12  7:05 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-02  3:25 Li Qiong
2022-12-02 10:02 ` Simon Horman
2022-12-02 10:07 ` Dan Carpenter
2022-12-02 10:18   ` liqiong
2022-12-02 10:26     ` Dan Carpenter
2022-12-02 11:26       ` Julian Anastasov
2022-12-12  7:05         ` liqiong [this message]
2022-12-12  7:43           ` [PATCH v2] ipvs: add a 'default' case " Li Qiong
2022-12-12 14:20             ` Julian Anastasov
2022-12-13 11:28               ` Pablo Neira Ayuso

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=272315c8-5e3b-e8ca-3c7f-68eccd0f2430@nfschina.com \
    --to=liqiong@nfschina.com \
    --cc=error27@gmail.com \
    --cc=horms@verge.net.au \
    --cc=ja@ssi.bg \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lvs-devel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    --cc=yepeilin.cs@gmail.com \
    --cc=yuzhe@nfschina.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®