[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ecqyyskx.ffs@tglx>
Date: Mon, 20 Oct 2025 08:50:54 +0200
From: Thomas Gleixner <tglx@...utronix.de>
To: Mathieu Desnoyers <mathieu.desnoyers@...icios.com>, LKML
<linux-kernel@...r.kernel.org>
Cc: kernel test robot <lkp@...el.com>, Russell King <linux@...linux.org.uk>,
linux-arm-kernel@...ts.infradead.org, Linus Torvalds
<torvalds@...ux-foundation.org>, x86@...nel.org, Madhavan Srinivasan
<maddy@...ux.ibm.com>, Michael Ellerman <mpe@...erman.id.au>, Nicholas
Piggin <npiggin@...il.com>, Christophe Leroy
<christophe.leroy@...roup.eu>, linuxppc-dev@...ts.ozlabs.org, Paul
Walmsley <pjw@...nel.org>, Palmer Dabbelt <palmer@...belt.com>,
linux-riscv@...ts.infradead.org, Heiko Carstens <hca@...ux.ibm.com>,
Christian Borntraeger <borntraeger@...ux.ibm.com>, Sven Schnelle
<svens@...ux.ibm.com>, linux-s390@...r.kernel.org, Andrew Cooper
<andrew.cooper3@...rix.com>, Julia Lawall <Julia.Lawall@...ia.fr>, Nicolas
Palix <nicolas.palix@...g.fr>, Peter Zijlstra <peterz@...radead.org>,
Darren Hart <dvhart@...radead.org>, Davidlohr Bueso <dave@...olabs.net>,
André Almeida <andrealmeid@...lia.com>, Alexander Viro
<viro@...iv.linux.org.uk>, Christian Brauner <brauner@...nel.org>, Jan
Kara <jack@...e.cz>, linux-fsdevel@...r.kernel.org
Subject: Re: [patch V3 08/12] uaccess: Provide put/get_user_masked()
On Fri, Oct 17 2025 at 09:45, Mathieu Desnoyers wrote:
> On 2025-10-17 09:41, Mathieu Desnoyers wrote:
> [...]
>>> +/**
>>> + * get_user_masked - Read user data with masked access
> [...]
>>> + * Return: true if successful, false when faulted
>
> I notice that __get_user() and get_user() return -EFAULT
> on error, 0 on success. I suspect the reversed logic
> will be rather confusing.
In most cases the return value of those is treated as a boolean
success/fail indicator. It's pretty confusing when a boolean return
value indicates success with 'false'. It's way more intuitive to read:
if (!do_something())
goto fail;
Just because we have this historic return '0' on success and error code
on fail concept does not mean we have to proliferate it forever.
In fact a lot of that 'hand an error code through the callchain' is just
pointless as in many cases that error code is completely ignored and
just used for a boolean decision at the end. So there is no point to
pretend that those error codes are meaningful except for places where
they need to be returned to user space.
Thanks,
tglx
Powered by blists - more mailing lists