* [PATCH 02/24] bpfilter: fix up a sparse annotation
@ 2020-07-20 12:47 Christoph Hellwig
2020-07-21 2:40 ` Luc Van Oostenryck
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-07-20 12:47 UTC (permalink / raw)
To: dccp
The __user doesn't make sense when casting to an integer type.
Signed-off-by: Christoph Hellwig <hch@lst.de>
---
net/bpfilter/bpfilter_kern.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c
index 977e9dad72ca4f..713b4b3d02005d 100644
--- a/net/bpfilter/bpfilter_kern.c
+++ b/net/bpfilter/bpfilter_kern.c
@@ -49,7 +49,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname,
req.is_set = is_set;
req.pid = current->pid;
req.cmd = optname;
- req.addr = (long __force __user)optval;
+ req.addr = (__force long)optval;
req.len = optlen;
if (!bpfilter_ops.info.tgid)
goto out;
--
2.27.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 02/24] bpfilter: fix up a sparse annotation
2020-07-20 12:47 [PATCH 02/24] bpfilter: fix up a sparse annotation Christoph Hellwig
@ 2020-07-21 2:40 ` Luc Van Oostenryck
2020-07-21 5:23 ` Christoph Hellwig
2020-07-21 5:28 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: Luc Van Oostenryck @ 2020-07-21 2:40 UTC (permalink / raw)
To: dccp
On Mon, Jul 20, 2020 at 02:47:15PM +0200, Christoph Hellwig wrote:
> The __user doesn't make sense when casting to an integer type.
>
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> net/bpfilter/bpfilter_kern.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/bpfilter/bpfilter_kern.c b/net/bpfilter/bpfilter_kern.c
> index 977e9dad72ca4f..713b4b3d02005d 100644
> --- a/net/bpfilter/bpfilter_kern.c
> +++ b/net/bpfilter/bpfilter_kern.c
> @@ -49,7 +49,7 @@ static int __bpfilter_process_sockopt(struct sock *sk, int optname,
> req.is_set = is_set;
> req.pid = current->pid;
> req.cmd = optname;
> - req.addr = (long __force __user)optval;
> + req.addr = (__force long)optval;
For casts to integers, even '__force' is not needed (since integers
can't be dereferenced, the concept of address-space is meaningless
for them, so it's never useful to warn when it's dropped and
'__force' is thus not needed).
-- Luc
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 02/24] bpfilter: fix up a sparse annotation
2020-07-20 12:47 [PATCH 02/24] bpfilter: fix up a sparse annotation Christoph Hellwig
2020-07-21 2:40 ` Luc Van Oostenryck
@ 2020-07-21 5:23 ` Christoph Hellwig
2020-07-21 5:28 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: Christoph Hellwig @ 2020-07-21 5:23 UTC (permalink / raw)
To: dccp
On Tue, Jul 21, 2020 at 04:40:16AM +0200, Luc Van Oostenryck wrote:
> > req.pid = current->pid;
> > req.cmd = optname;
> > - req.addr = (long __force __user)optval;
> > + req.addr = (__force long)optval;
>
> For casts to integers, even '__force' is not needed (since integers
> can't be dereferenced, the concept of address-space is meaningless
> for them, so it's never useful to warn when it's dropped and
> '__force' is thus not needed).
That's what I thought. but if I remove it here I actually do get a
warning:
CHECK net/bpfilter/bpfilter_kern.c
net/bpfilter/bpfilter_kern.c:52:21: warning: cast removes address space '__user' of expression
Using this recent sparse build:
hch@brick:~/work/linux$ sparse --version
v0.6.2-49-g707c5017
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 02/24] bpfilter: fix up a sparse annotation
2020-07-20 12:47 [PATCH 02/24] bpfilter: fix up a sparse annotation Christoph Hellwig
2020-07-21 2:40 ` Luc Van Oostenryck
2020-07-21 5:23 ` Christoph Hellwig
@ 2020-07-21 5:28 ` Al Viro
2 siblings, 0 replies; 4+ messages in thread
From: Al Viro @ 2020-07-21 5:28 UTC (permalink / raw)
To: dccp
On Tue, Jul 21, 2020 at 07:23:26AM +0200, Christoph Hellwig wrote:
> On Tue, Jul 21, 2020 at 04:40:16AM +0200, Luc Van Oostenryck wrote:
> > > req.pid = current->pid;
> > > req.cmd = optname;
> > > - req.addr = (long __force __user)optval;
> > > + req.addr = (__force long)optval;
> >
> > For casts to integers, even '__force' is not needed (since integers
> > can't be dereferenced, the concept of address-space is meaningless
> > for them, so it's never useful to warn when it's dropped and
> > '__force' is thus not needed).
>
> That's what I thought. but if I remove it here I actually do get a
> warning:
>
> CHECK net/bpfilter/bpfilter_kern.c
> net/bpfilter/bpfilter_kern.c:52:21: warning: cast removes address space '__user' of expression
Cast to unsigned long. Or to uintptr_t if you want to be fancy.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2020-07-21 5:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-20 12:47 [PATCH 02/24] bpfilter: fix up a sparse annotation Christoph Hellwig
2020-07-21 2:40 ` Luc Van Oostenryck
2020-07-21 5:23 ` Christoph Hellwig
2020-07-21 5:28 ` Al Viro
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).