From: Simon Horman <simon.horman@corigine.com>
To: Gavrilov Ilia <Ilia.Gavrilov@infotecs.ru>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>,
Jozsef Kadlecsik <kadlec@netfilter.org>,
Florian Westphal <fw@strlen.de>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Patrick McHardy <kaber@trash.net>,
"netfilter-devel@vger.kernel.org"
<netfilter-devel@vger.kernel.org>,
"coreteam@netfilter.org" <coreteam@netfilter.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>
Subject: Re: [PATCH] netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value.
Date: Tue, 2 May 2023 17:38:19 +0200 [thread overview]
Message-ID: <ZFEuazEvNWHfEH93@corigine.com> (raw)
In-Reply-To: <f9d9ac80-704a-91d7-b120-449b921e8bb0@infotecs.ru>
On Tue, May 02, 2023 at 02:16:09PM +0000, Gavrilov Ilia wrote:
> On 5/2/23 17:05, Simon Horman wrote:
> > On Tue, May 02, 2023 at 11:43:19AM +0000, Gavrilov Ilia wrote:
> >> On 4/28/23 22:24, Simon Horman wrote:
> >>> On Wed, Apr 26, 2023 at 03:04:31PM +0000, Gavrilov Ilia wrote:
> >>>> ct_sip_parse_numerical_param() returns only 0 or 1 now.
> >>>> But process_register_request() and process_register_response() imply
> >>>> checking for a negative value if parsing of a numerical header parameter
> >>>> failed. Let's fix it.
> >>>>
> >>>> Found by InfoTeCS on behalf of Linux Verification Center
> >>>> (linuxtesting.org) with SVACE.
> >>>>
> >>>> Fixes: 0f32a40fc91a ("[NETFILTER]: nf_conntrack_sip: create signalling expectations")
> >>>> Signed-off-by: Ilia.Gavrilov <Ilia.Gavrilov@infotecs.ru>
> >>>
> >>> Hi Gavrilov,
> >>>
> >>
> >> Hi Simon, thank you for your answer.
> >>
> >>> although it is a slightly unusual convention for kernel code,
> >>> I believe the intention is that this function returns 0 when
> >>> it fails (to parse) and 1 on success. So I think that part is fine.
> >>>
> >>> What seems a bit broken is the way that callers use the return value.
> >>>
> >>> 1. The call in process_register_response() looks like this:
> >>>
> >>> ret = ct_sip_parse_numerical_param(...)
> >>> if (ret < 0) {
> >>> nf_ct_helper_log(skb, ct, "cannot parse expires");
> >>> return NF_DROP;
> >>> }
> >>>
> >>> But ret can only be 0 or 1, so the error handling is never inoked,
> >>> and a failure to parse is ignored. I guess failure doesn't occur in
> >>> practice.
> >>>
> >>> I suspect this should be:
> >>>
> >>> ret = ct_sip_parse_numerical_param(...)
> >>> if (!ret) {
> >>> nf_ct_helper_log(skb, ct, "cannot parse expires");
> >>> return NF_DROP;
> >>> }
> >>>
> >>
> >> ct_sip_parse_numerical_param() returns 0 in to cases 1) when the
> >> parameter 'expires=' isn't found in the header or 2) it's incorrectly set.
> >> In the first case, the return value should be ignored, since this is a
> >> normal situation
> >> In the second case, it's better to write to the log and return NF_DROP,
> >> or ignore it too, then checking the return value can be removed as
> >> unnecessary.
> >
> > Sorry, I think I misunderstood the intention of your patch earlier.
> >
> > Do I (now) understand correctly that you are proposing a tristate?
> >
> > a) return 1 if value is found; *val is set
> > b) return 0 if value is not found; *val is unchanged
> > c) return -1 on error; *val is undefined
>
> Yes, it seems to me that this was originally intended.
Thanks. With my new found understanding, this looks good to me.
Reviewed-by: Simon Horman <simon.horman@corigine.com>
next prev parent reply other threads:[~2023-05-02 15:38 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 15:04 [PATCH] netfilter: nf_conntrack_sip: fix the ct_sip_parse_numerical_param() return value Gavrilov Ilia
2023-04-28 19:24 ` Simon Horman
2023-05-02 11:43 ` Gavrilov Ilia
2023-05-02 14:05 ` Simon Horman
2023-05-02 14:16 ` Gavrilov Ilia
2023-05-02 15:38 ` Simon Horman [this message]
2023-06-22 13:55 ` Gavrilov Ilia
2023-06-22 14:43 ` Florian Westphal
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=ZFEuazEvNWHfEH93@corigine.com \
--to=simon.horman@corigine.com \
--cc=Ilia.Gavrilov@infotecs.ru \
--cc=coreteam@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=kaber@trash.net \
--cc=kadlec@netfilter.org \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lvc-project@linuxtesting.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pablo@netfilter.org \
/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;
as well as URLs for NNTP newsgroup(s).