All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben@fluff.org>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: ben-linux@fluff.org, linux-riscv@lists.infradead.org,
	Paul Walmsley <paul.walmsley@sifive.com>,
	linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu
Subject: Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
Date: Thu, 29 Dec 2022 17:34:47 +0000	[thread overview]
Message-ID: <20221229173447.qhcaamchxv5jkbpo@hetzy.fluff.org> (raw)
In-Reply-To: <mhng-33b9aafc-448a-4400-9a06-cb222724363a@palmer-ri-x1c9>

On Thu, Dec 29, 2022 at 09:31:27AM -0800, Palmer Dabbelt wrote:
> On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.org wrote:
> > If the get_user(x, ptr) has x as a pointer, then the setting
> > of (x) = 0 is going to produce the following sparse warning,
> > so fix this by forcing the type of 'x' when access_ok() fails.
> > 
> > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer
> > 
> > Signed-off-by: Ben Dooks <ben-linux@fluff.org>
> > ---
> >  arch/riscv/include/asm/uaccess.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> > index 855450bed9f5..ec0cab9fbddd 100644
> > --- a/arch/riscv/include/asm/uaccess.h
> > +++ b/arch/riscv/include/asm/uaccess.h
> > @@ -165,7 +165,7 @@ do {								\
> >  	might_fault();						\
> >  	access_ok(__p, sizeof(*__p)) ?		\
> >  		__get_user((x), __p) :				\
> > -		((x) = 0, -EFAULT);				\
> > +		((x) = (__force __typeof__(x))0, -EFAULT);	\
> >  })
> > 
> >  #define __put_user_asm(insn, x, ptr, err)			\
> 
> Looks like arm64 has a pretty similar pattern.  They've got the __force
> __typeof__ already, but given the similarity it might be worth refactoring
> these to share the error checking code.

I looked there for an idea on how to fix.

> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
> 
> I'll give this a bit of time like usual, unless anyone's opposed I'll put it
> on fixes.  I wasn't planning on sending a PR this week anyway due to the
> holidays.

Ok, it's a warning which would be nice to be fixed.

-- 
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.


_______________________________________________
linux-riscv mailing list
linux-riscv@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-riscv

WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben@fluff.org>
To: Palmer Dabbelt <palmer@dabbelt.com>
Cc: ben-linux@fluff.org, linux-riscv@lists.infradead.org,
	Paul Walmsley <paul.walmsley@sifive.com>,
	linux-kernel@vger.kernel.org, aou@eecs.berkeley.edu
Subject: Re: [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user()
Date: Thu, 29 Dec 2022 17:34:47 +0000	[thread overview]
Message-ID: <20221229173447.qhcaamchxv5jkbpo@hetzy.fluff.org> (raw)
In-Reply-To: <mhng-33b9aafc-448a-4400-9a06-cb222724363a@palmer-ri-x1c9>

On Thu, Dec 29, 2022 at 09:31:27AM -0800, Palmer Dabbelt wrote:
> On Thu, 29 Dec 2022 09:05:45 PST (-0800), ben-linux@fluff.org wrote:
> > If the get_user(x, ptr) has x as a pointer, then the setting
> > of (x) = 0 is going to produce the following sparse warning,
> > so fix this by forcing the type of 'x' when access_ok() fails.
> > 
> > fs/aio.c:2073:21: warning: Using plain integer as NULL pointer
> > 
> > Signed-off-by: Ben Dooks <ben-linux@fluff.org>
> > ---
> >  arch/riscv/include/asm/uaccess.h | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/arch/riscv/include/asm/uaccess.h b/arch/riscv/include/asm/uaccess.h
> > index 855450bed9f5..ec0cab9fbddd 100644
> > --- a/arch/riscv/include/asm/uaccess.h
> > +++ b/arch/riscv/include/asm/uaccess.h
> > @@ -165,7 +165,7 @@ do {								\
> >  	might_fault();						\
> >  	access_ok(__p, sizeof(*__p)) ?		\
> >  		__get_user((x), __p) :				\
> > -		((x) = 0, -EFAULT);				\
> > +		((x) = (__force __typeof__(x))0, -EFAULT);	\
> >  })
> > 
> >  #define __put_user_asm(insn, x, ptr, err)			\
> 
> Looks like arm64 has a pretty similar pattern.  They've got the __force
> __typeof__ already, but given the similarity it might be worth refactoring
> these to share the error checking code.

I looked there for an idea on how to fix.

> Reviewed-by: Palmer Dabbelt <palmer@rivosinc.com>
> 
> I'll give this a bit of time like usual, unless anyone's opposed I'll put it
> on fixes.  I wasn't planning on sending a PR this week anyway due to the
> holidays.

Ok, it's a warning which would be nice to be fixed.

-- 
Ben Dooks, ben@fluff.org, http://www.fluff.org/ben/

Large Hadron Colada: A large Pina Colada that makes the universe disappear.


  reply	other threads:[~2022-12-29 17:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-29 17:05 [PATCH] riscv: uaccess: fix type of 0 variable on error in get_user() Ben Dooks
2022-12-29 17:05 ` Ben Dooks
2022-12-29 17:31 ` Palmer Dabbelt
2022-12-29 17:31   ` Palmer Dabbelt
2022-12-29 17:34   ` Ben Dooks [this message]
2022-12-29 17:34     ` Ben Dooks
2023-01-05 22:52 ` Palmer Dabbelt
2023-01-05 22:52   ` Palmer Dabbelt
2023-01-05 23:00 ` patchwork-bot+linux-riscv
2023-01-05 23:00   ` patchwork-bot+linux-riscv

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=20221229173447.qhcaamchxv5jkbpo@hetzy.fluff.org \
    --to=ben@fluff.org \
    --cc=aou@eecs.berkeley.edu \
    --cc=ben-linux@fluff.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-riscv@lists.infradead.org \
    --cc=palmer@dabbelt.com \
    --cc=paul.walmsley@sifive.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.