* [PATCH] net/sunrpc: Fix return value from proc_do_xprt()
@ 2020-10-24 14:52 Alex Dewar
2020-11-06 22:07 ` J. Bruce Fields
0 siblings, 1 reply; 4+ messages in thread
From: Alex Dewar @ 2020-10-24 14:52 UTC (permalink / raw)
Cc: Alex Dewar, J. Bruce Fields, Chuck Lever, Trond Myklebust,
Anna Schumaker, David S. Miller, Jakub Kicinski, Artur Molchanov,
linux-nfs, netdev, linux-kernel
Commit c09f56b8f68d ("net/sunrpc: Fix return value for sysctl
sunrpc.transports") attempted to add error checking for the call to
memory_read_from_buffer(), however its return value was assigned to a
size_t variable, so any negative values would be lost in the cast. Fix
this.
Addresses-Coverity-ID: 1498033: Control flow issues (NO_EFFECT)
Fixes: c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports")
Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
---
net/sunrpc/sysctl.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
index a18b36b5422d..c95a2b84dd95 100644
--- a/net/sunrpc/sysctl.c
+++ b/net/sunrpc/sysctl.c
@@ -62,6 +62,7 @@ rpc_unregister_sysctl(void)
static int proc_do_xprt(struct ctl_table *table, int write,
void *buffer, size_t *lenp, loff_t *ppos)
{
+ ssize_t bytes_read;
char tmpbuf[256];
size_t len;
@@ -70,12 +71,14 @@ static int proc_do_xprt(struct ctl_table *table, int write,
return 0;
}
len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
- *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
+ bytes_read = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
- if (*lenp < 0) {
+ if (bytes_read < 0) {
*lenp = 0;
return -EINVAL;
}
+
+ *lenp = bytes_read;
return 0;
}
--
2.29.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sunrpc: Fix return value from proc_do_xprt()
2020-10-24 14:52 [PATCH] net/sunrpc: Fix return value from proc_do_xprt() Alex Dewar
@ 2020-11-06 22:07 ` J. Bruce Fields
2020-11-07 13:49 ` Alex Dewar
0 siblings, 1 reply; 4+ messages in thread
From: J. Bruce Fields @ 2020-11-06 22:07 UTC (permalink / raw)
To: Alex Dewar
Cc: Chuck Lever, Trond Myklebust, Anna Schumaker, David S. Miller,
Jakub Kicinski, Artur Molchanov, linux-nfs, netdev, linux-kernel
Whoops, got 3 independent patches for this and overlooked this one. See
https://lore.kernel.org/linux-nfs/20201106205959.GB26028@fieldses.org/T/#t
--b.
On Sat, Oct 24, 2020 at 03:52:40PM +0100, Alex Dewar wrote:
> Commit c09f56b8f68d ("net/sunrpc: Fix return value for sysctl
> sunrpc.transports") attempted to add error checking for the call to
> memory_read_from_buffer(), however its return value was assigned to a
> size_t variable, so any negative values would be lost in the cast. Fix
> this.
>
> Addresses-Coverity-ID: 1498033: Control flow issues (NO_EFFECT)
> Fixes: c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports")
> Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> ---
> net/sunrpc/sysctl.c | 7 +++++--
> 1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
> index a18b36b5422d..c95a2b84dd95 100644
> --- a/net/sunrpc/sysctl.c
> +++ b/net/sunrpc/sysctl.c
> @@ -62,6 +62,7 @@ rpc_unregister_sysctl(void)
> static int proc_do_xprt(struct ctl_table *table, int write,
> void *buffer, size_t *lenp, loff_t *ppos)
> {
> + ssize_t bytes_read;
> char tmpbuf[256];
> size_t len;
>
> @@ -70,12 +71,14 @@ static int proc_do_xprt(struct ctl_table *table, int write,
> return 0;
> }
> len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
> - *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> + bytes_read = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
>
> - if (*lenp < 0) {
> + if (bytes_read < 0) {
> *lenp = 0;
> return -EINVAL;
> }
> +
> + *lenp = bytes_read;
> return 0;
> }
>
> --
> 2.29.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sunrpc: Fix return value from proc_do_xprt()
2020-11-06 22:07 ` J. Bruce Fields
@ 2020-11-07 13:49 ` Alex Dewar
2020-11-07 15:39 ` J. Bruce Fields
0 siblings, 1 reply; 4+ messages in thread
From: Alex Dewar @ 2020-11-07 13:49 UTC (permalink / raw)
To: J. Bruce Fields
Cc: Alex Dewar, Chuck Lever, Trond Myklebust, Anna Schumaker,
David S. Miller, Jakub Kicinski, Artur Molchanov, linux-nfs,
netdev, linux-kernel
On Fri, Nov 06, 2020 at 05:07:21PM -0500, J. Bruce Fields wrote:
> Whoops, got 3 independent patches for this and overlooked this one. See
> https://lore.kernel.org/linux-nfs/20201106205959.GB26028@fieldses.org/T/#t
>
> --b.
That looks like a cleaner fix. Thanks for looking anyhow and sorry for
the noise!
>
> On Sat, Oct 24, 2020 at 03:52:40PM +0100, Alex Dewar wrote:
> > Commit c09f56b8f68d ("net/sunrpc: Fix return value for sysctl
> > sunrpc.transports") attempted to add error checking for the call to
> > memory_read_from_buffer(), however its return value was assigned to a
> > size_t variable, so any negative values would be lost in the cast. Fix
> > this.
> >
> > Addresses-Coverity-ID: 1498033: Control flow issues (NO_EFFECT)
> > Fixes: c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports")
> > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > ---
> > net/sunrpc/sysctl.c | 7 +++++--
> > 1 file changed, 5 insertions(+), 2 deletions(-)
> >
> > diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
> > index a18b36b5422d..c95a2b84dd95 100644
> > --- a/net/sunrpc/sysctl.c
> > +++ b/net/sunrpc/sysctl.c
> > @@ -62,6 +62,7 @@ rpc_unregister_sysctl(void)
> > static int proc_do_xprt(struct ctl_table *table, int write,
> > void *buffer, size_t *lenp, loff_t *ppos)
> > {
> > + ssize_t bytes_read;
> > char tmpbuf[256];
> > size_t len;
> >
> > @@ -70,12 +71,14 @@ static int proc_do_xprt(struct ctl_table *table, int write,
> > return 0;
> > }
> > len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
> > - *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> > + bytes_read = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> >
> > - if (*lenp < 0) {
> > + if (bytes_read < 0) {
> > *lenp = 0;
> > return -EINVAL;
> > }
> > +
> > + *lenp = bytes_read;
> > return 0;
> > }
> >
> > --
> > 2.29.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] net/sunrpc: Fix return value from proc_do_xprt()
2020-11-07 13:49 ` Alex Dewar
@ 2020-11-07 15:39 ` J. Bruce Fields
0 siblings, 0 replies; 4+ messages in thread
From: J. Bruce Fields @ 2020-11-07 15:39 UTC (permalink / raw)
To: Alex Dewar
Cc: Chuck Lever, Trond Myklebust, Anna Schumaker, David S. Miller,
Jakub Kicinski, Artur Molchanov, linux-nfs, netdev, linux-kernel
On Sat, Nov 07, 2020 at 01:49:40PM +0000, Alex Dewar wrote:
> On Fri, Nov 06, 2020 at 05:07:21PM -0500, J. Bruce Fields wrote:
> > Whoops, got 3 independent patches for this and overlooked this one. See
> > https://lore.kernel.org/linux-nfs/20201106205959.GB26028@fieldses.org/T/#t
> >
> > --b.
>
> That looks like a cleaner fix. Thanks for looking anyhow and sorry for
> the noise!
Not noise, all these efforts are appreciated.---b.
>
> >
> > On Sat, Oct 24, 2020 at 03:52:40PM +0100, Alex Dewar wrote:
> > > Commit c09f56b8f68d ("net/sunrpc: Fix return value for sysctl
> > > sunrpc.transports") attempted to add error checking for the call to
> > > memory_read_from_buffer(), however its return value was assigned to a
> > > size_t variable, so any negative values would be lost in the cast. Fix
> > > this.
> > >
> > > Addresses-Coverity-ID: 1498033: Control flow issues (NO_EFFECT)
> > > Fixes: c09f56b8f68d ("net/sunrpc: Fix return value for sysctl sunrpc.transports")
> > > Signed-off-by: Alex Dewar <alex.dewar90@gmail.com>
> > > ---
> > > net/sunrpc/sysctl.c | 7 +++++--
> > > 1 file changed, 5 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/net/sunrpc/sysctl.c b/net/sunrpc/sysctl.c
> > > index a18b36b5422d..c95a2b84dd95 100644
> > > --- a/net/sunrpc/sysctl.c
> > > +++ b/net/sunrpc/sysctl.c
> > > @@ -62,6 +62,7 @@ rpc_unregister_sysctl(void)
> > > static int proc_do_xprt(struct ctl_table *table, int write,
> > > void *buffer, size_t *lenp, loff_t *ppos)
> > > {
> > > + ssize_t bytes_read;
> > > char tmpbuf[256];
> > > size_t len;
> > >
> > > @@ -70,12 +71,14 @@ static int proc_do_xprt(struct ctl_table *table, int write,
> > > return 0;
> > > }
> > > len = svc_print_xprts(tmpbuf, sizeof(tmpbuf));
> > > - *lenp = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> > > + bytes_read = memory_read_from_buffer(buffer, *lenp, ppos, tmpbuf, len);
> > >
> > > - if (*lenp < 0) {
> > > + if (bytes_read < 0) {
> > > *lenp = 0;
> > > return -EINVAL;
> > > }
> > > +
> > > + *lenp = bytes_read;
> > > return 0;
> > > }
> > >
> > > --
> > > 2.29.1
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-11-07 15:39 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-24 14:52 [PATCH] net/sunrpc: Fix return value from proc_do_xprt() Alex Dewar
2020-11-06 22:07 ` J. Bruce Fields
2020-11-07 13:49 ` Alex Dewar
2020-11-07 15:39 ` J. Bruce Fields
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).