From: Christoph Hellwig <hch@infradead.org>
To: "Clément Léger" <cleger@rivosinc.com>
Cc: Christoph Hellwig <hch@infradead.org>,
Ben Dooks <ben.dooks@codethink.co.uk>,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org,
paul.walmsley@sifive.com, palmer@dabbelt.com,
aou@eecs.berkeley.edu
Subject: Re: [PATCH] riscv: fix __user annotation in traps_misaligned.c
Date: Fri, 24 Nov 2023 02:45:00 -0800 [thread overview]
Message-ID: <ZWB+rPU4nm+Zxd7d@infradead.org> (raw)
In-Reply-To: <7232f08e-dfe3-43d6-a4f7-abf8360bbfc1@rivosinc.com>
On Fri, Nov 24, 2023 at 11:28:08AM +0100, Clément Léger wrote:
> I sent a similar patch two days ago with the same modification. I'm not
> sure to get it. Why is it better to pass the "unsigned long" type from
> the caller ? I mean, the resulting code would look like this right ?
Because you're legimitizing casting between address_space, which is a
horrible idea. By casting either from the unsigned long you make it
very clear that deep magic is coming in and you make an informed
decisions based on the user_mode() predicate. Witht a blind cast
to add/remove a __user you don't.
I'm actually surprised sparse even allows __user casts without __force.
next prev parent reply other threads:[~2023-11-24 10:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-23 14:16 Ben Dooks
2023-11-24 6:05 ` Christoph Hellwig
2023-11-24 10:28 ` Clément Léger
2023-11-24 10:45 ` Christoph Hellwig [this message]
2023-11-24 10:46 ` Clément Léger
2023-11-24 10:21 ` Clément Léger
2024-01-11 14:50 ` 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=ZWB+rPU4nm+Zxd7d@infradead.org \
--to=hch@infradead.org \
--cc=aou@eecs.berkeley.edu \
--cc=ben.dooks@codethink.co.uk \
--cc=cleger@rivosinc.com \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®