2018-07-22 09:27:02

by Xiaoming Ni

[permalink] [raw]
Subject: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id

dummy = be32_to_cpup(p++);
dummy = be32_to_cpup(p++);
Assigning value to "dummy" here, but that stored value
is overwritten before it can be used.

delete invalid assignment statements in nfsd4_decode_exchange_id

Signed-off-by: n00202754 <[email protected]>
---
fs/nfsd/nfs4xdr.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
index a96843c..8e78541 100644
--- a/fs/nfsd/nfs4xdr.c
+++ b/fs/nfsd/nfs4xdr.c
@@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp,

/* ssp_window and ssp_num_gss_handles */
READ_BUF(8);
- dummy = be32_to_cpup(p++);
- dummy = be32_to_cpup(p++);
+ be32_to_cpup(p++);
+ be32_to_cpup(p++);
break;
default:
goto xdr_error;
--
2.10.1



2018-07-22 18:13:39

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id



> On Jul 22, 2018, at 4:50 AM, nixiaoming <[email protected]> wrote:
>
> dummy = be32_to_cpup(p++);
> dummy = be32_to_cpup(p++);
> Assigning value to "dummy" here, but that stored value
> is overwritten before it can be used.
>
> delete invalid assignment statements in nfsd4_decode_exchange_id
>
> Signed-off-by: n00202754 <[email protected]>
> ---
> fs/nfsd/nfs4xdr.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> index a96843c..8e78541 100644
> --- a/fs/nfsd/nfs4xdr.c
> +++ b/fs/nfsd/nfs4xdr.c
> @@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct nfsd4_compoundargs *argp,
>
> /* ssp_window and ssp_num_gss_handles */
> READ_BUF(8);
> - dummy = be32_to_cpup(p++);
> - dummy = be32_to_cpup(p++);
> + be32_to_cpup(p++);
> + be32_to_cpup(p++);

If these values are not used, what's the point of byte swapping them?
Surely "p += 2;" should be enough.


> break;
> default:
> goto xdr_error;

--
Chuck Lever




2018-07-22 18:34:25

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id

On Sun, 2018-07-22 at 14:12 -0400, Chuck Lever wrote:
> > On Jul 22, 2018, at 4:50 AM, nixiaoming <[email protected]>
> > wrote:
> >
> > dummy = be32_to_cpup(p++);
> > dummy = be32_to_cpup(p++);
> > Assigning value to "dummy" here, but that stored value
> > is overwritten before it can be used.
> >
> > delete invalid assignment statements in nfsd4_decode_exchange_id
> >
> > Signed-off-by: n00202754 <[email protected]>
> > ---
> > fs/nfsd/nfs4xdr.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> > index a96843c..8e78541 100644
> > --- a/fs/nfsd/nfs4xdr.c
> > +++ b/fs/nfsd/nfs4xdr.c
> > @@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct
> > nfsd4_compoundargs *argp,
> >
> > /* ssp_window and ssp_num_gss_handles */
> > READ_BUF(8);
> > - dummy = be32_to_cpup(p++);
> > - dummy = be32_to_cpup(p++);
> > + be32_to_cpup(p++);
> > + be32_to_cpup(p++);
>
> If these values are not used, what's the point of byte swapping them?
> Surely "p += 2;" should be enough.
>
>
> > break;
> > default:
> > goto xdr_error;
>

Given that the value of 'p' isn't used either, why not just delete
those two lines altogether?

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]


2018-07-22 19:02:30

by Chuck Lever III

[permalink] [raw]
Subject: Re: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id



> On Jul 22, 2018, at 2:33 PM, Trond Myklebust <[email protected]> wrote:
>
> On Sun, 2018-07-22 at 14:12 -0400, Chuck Lever wrote:
>>> On Jul 22, 2018, at 4:50 AM, nixiaoming <[email protected]>
>>> wrote:
>>>
>>> dummy = be32_to_cpup(p++);
>>> dummy = be32_to_cpup(p++);
>>> Assigning value to "dummy" here, but that stored value
>>> is overwritten before it can be used.
>>>
>>> delete invalid assignment statements in nfsd4_decode_exchange_id
>>>
>>> Signed-off-by: n00202754 <[email protected]>
>>> ---
>>> fs/nfsd/nfs4xdr.c | 4 ++--
>>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>>
>>> diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
>>> index a96843c..8e78541 100644
>>> --- a/fs/nfsd/nfs4xdr.c
>>> +++ b/fs/nfsd/nfs4xdr.c
>>> @@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct
>>> nfsd4_compoundargs *argp,
>>>
>>> /* ssp_window and ssp_num_gss_handles */
>>> READ_BUF(8);
>>> - dummy = be32_to_cpup(p++);
>>> - dummy = be32_to_cpup(p++);
>>> + be32_to_cpup(p++);
>>> + be32_to_cpup(p++);
>>
>> If these values are not used, what's the point of byte swapping them?
>> Surely "p += 2;" should be enough.
>>
>>
>>> break;
>>> default:
>>> goto xdr_error;
>>
>
> Given that the value of 'p' isn't used either, why not just delete
> those two lines altogether?

Sounds OK, READ_BUF is tracking progress through the buffer,
and it already updates "p" as a side-effect.

Might there be some nearby instances of open-coded "p" updates
that could also be removed, for similar reasons?


--
Chuck Lever




2018-07-22 19:09:21

by Trond Myklebust

[permalink] [raw]
Subject: Re: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id

On Sun, 2018-07-22 at 15:01 -0400, Chuck Lever wrote:
> > On Jul 22, 2018, at 2:33 PM, Trond Myklebust <
> > [email protected]> wrote:
> >
> > On Sun, 2018-07-22 at 14:12 -0400, Chuck Lever wrote:
> > > > On Jul 22, 2018, at 4:50 AM, nixiaoming <[email protected]>
> > > > wrote:
> > > >
> > > > dummy = be32_to_cpup(p++);
> > > > dummy = be32_to_cpup(p++);
> > > > Assigning value to "dummy" here, but that stored value
> > > > is overwritten before it can be used.
> > > >
> > > > delete invalid assignment statements in
> > > > nfsd4_decode_exchange_id
> > > >
> > > > Signed-off-by: n00202754 <[email protected]>
> > > > ---
> > > > fs/nfsd/nfs4xdr.c | 4 ++--
> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
> > > >
> > > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
> > > > index a96843c..8e78541 100644
> > > > --- a/fs/nfsd/nfs4xdr.c
> > > > +++ b/fs/nfsd/nfs4xdr.c
> > > > @@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct
> > > > nfsd4_compoundargs *argp,
> > > >
> > > > /* ssp_window and ssp_num_gss_handles */
> > > > READ_BUF(8);
> > > > - dummy = be32_to_cpup(p++);
> > > > - dummy = be32_to_cpup(p++);
> > > > + be32_to_cpup(p++);
> > > > + be32_to_cpup(p++);
> > >
> > > If these values are not used, what's the point of byte swapping
> > > them?
> > > Surely "p += 2;" should be enough.
> > >
> > >
> > > > break;
> > > > default:
> > > > goto xdr_error;
> >
> > Given that the value of 'p' isn't used either, why not just delete
> > those two lines altogether?
>
> Sounds OK, READ_BUF is tracking progress through the buffer,
> and it already updates "p" as a side-effect.
>
> Might there be some nearby instances of open-coded "p" updates
> that could also be removed, for similar reasons?
>

Probably, yes. I believe that we've said before (and Bruce agreed at
the time) that we should get rid of READ_BUF() in knfsd as it tends to
obfuscate these assignments to 'p'. Does anyone have any free cycles to
work on that?

--
Trond Myklebust
Linux NFS client maintainer, Hammerspace
[email protected]


2018-07-23 02:18:29

by Xiaoming Ni

[permalink] [raw]
Subject: RE: [PATCH] fs/nfsd: Delete invalid assignment statements in nfsd4_decode_exchange_id

On Mon, Jul 23, 2018 at 3:08 AM, Trond Myklebust wrote:
>On Sun, 2018-07-22 at 15:01 -0400, Chuck Lever wrote:
>> > On Jul 22, 2018, at 2:33 PM, Trond Myklebust <
>> > [email protected]> wrote:
>> >
>> > On Sun, 2018-07-22 at 14:12 -0400, Chuck Lever wrote:
>> > > > On Jul 22, 2018, at 4:50 AM, nixiaoming <[email protected]>
>> > > > wrote:
>> > > >
>> > > > dummy = be32_to_cpup(p++);
>> > > > dummy = be32_to_cpup(p++);
>> > > > Assigning value to "dummy" here, but that stored value
>> > > > is overwritten before it can be used.
>> > > >
>> > > > delete invalid assignment statements in
>> > > > nfsd4_decode_exchange_id
>> > > >
>> > > > Signed-off-by: n00202754 <[email protected]>
>> > > > ---
>> > > > fs/nfsd/nfs4xdr.c | 4 ++--
>> > > > 1 file changed, 2 insertions(+), 2 deletions(-)
>> > > >
>> > > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c
>> > > > index a96843c..8e78541 100644
>> > > > --- a/fs/nfsd/nfs4xdr.c
>> > > > +++ b/fs/nfsd/nfs4xdr.c
>> > > > @@ -1392,8 +1392,8 @@ nfsd4_decode_exchange_id(struct
>> > > > nfsd4_compoundargs *argp,
>> > > >
>> > > > /* ssp_window and ssp_num_gss_handles */
>> > > > READ_BUF(8);
>> > > > - dummy = be32_to_cpup(p++);
>> > > > - dummy = be32_to_cpup(p++);
>> > > > + be32_to_cpup(p++);
>> > > > + be32_to_cpup(p++);
>> > >
>> > > If these values are not used, what's the point of byte swapping
>> > > them?
>> > > Surely "p += 2;" should be enough.
>> > >
>> > >
>> > > > break;
>> > > > default:
>> > > > goto xdr_error;
>> >
>> > Given that the value of 'p' isn't used either, why not just delete
>> > those two lines altogether?
>>
>> Sounds OK, READ_BUF is tracking progress through the buffer,
>> and it already updates "p" as a side-effect.
>>
>> Might there be some nearby instances of open-coded "p" updates
>> that could also be removed, for similar reasons?
>>
>
>Probably, yes. I believe that we've said before (and Bruce agreed at
>the time) that we should get rid of READ_BUF() in knfsd as it tends to
>obfuscate these assignments to 'p'. Does anyone have any free cycles to
>work on that?
>
>--
>Trond Myklebust
>Linux NFS client maintainer, Hammerspace
>[email protected]
>
>

Thank you for your review,
I will update the patch as soon as possible based on your comments.

Thanks