lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20181014202807.16412-1-uwe@kleine-koenig.org>
Date:   Sun, 14 Oct 2018 22:28:07 +0200
From:   Uwe Kleine-König <uwe@...ine-koenig.org>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Alessandro Rubini <rubini@...dd.com>,
        Jonathan Corbet <corbet@....net>
Cc:     linux-kernel@...r.kernel.org,
        Thierry Reding <thierry.reding@...il.com>,
        Vokáč Michal <Michal.Vokac@...ft.com>,
        Andrew Morton <akpm@...ux-foundation.org>,
        kernel@...gutronix.de
Subject: [PATCH RFC] err.h: document that PTR_ERR should only be used if IS_ERR returns true

I have no idea about the rationale, but that's what LDD3 recommends.

Signed-off-by: Uwe Kleine-König <uwe@...ine-koenig.org>
---
Hello,

during a review I claimed that PTR_ERR should only be used if IS_ERR was
already checked. The rationale isn't obvious though and Thierry
suggested to keep the code as is and not introduce an IS_ERR check.

I found in Linux Device Drivers 3[1]:

	You should use PTR_ERR only on a value for which IS_ERR returns
	a true value; any other value is a valid pointer

I wonder if there is a relevant reason that LDD3 suggests to check
IS_ERR first, maybe something like "On an Alpha it is important because
not doing it results in a bus error there." There are no details
mentioned there however. If there is a reason, this patch should be
adapted such that the comment includes it.

Any ideas?

Best regards
Uwe

[1] https://static.lwn.net/images/pdf/LDD3/ch11.pdf, on page 295

 include/linux/err.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/err.h b/include/linux/err.h
index 87be24350e91..8f052983108e 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -26,6 +26,9 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
+/*
+ * You should use PTR_ERR only on a value for which IS_ERR returns a true value.
+ */
 static inline long __must_check PTR_ERR(__force const void *ptr)
 {
 	return (long) ptr;
-- 
2.19.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ