linux-security-module.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] LSM: fix return value check in safesetid_init_securityfs()
@ 2019-02-12  7:58 Wei Yongjun
  2019-02-12 16:55 ` Kees Cook
  2019-02-12 19:01 ` James Morris
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2019-02-12  7:58 UTC (permalink / raw)
  To: James Morris, Serge E. Hallyn, Kees Cook, Micah Morton
  Cc: Wei Yongjun, linux-security-module, kernel-janitors

In case of error, the function securityfs_create_dir() returns ERR_PTR()
and never returns NULL. The NULL test in the return value check should
be replaced with IS_ERR().

Fixes: aeca4e2ca65c ("LSM: add SafeSetID module that gates setid calls")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 security/safesetid/securityfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
index 61be4ee459cc..2c6c829be044 100644
--- a/security/safesetid/securityfs.c
+++ b/security/safesetid/securityfs.c
@@ -167,7 +167,7 @@ static int __init safesetid_init_securityfs(void)
 		return 0;
 
 	safesetid_policy_dir = securityfs_create_dir("safesetid", NULL);
-	if (!safesetid_policy_dir) {
+	if (IS_ERR(safesetid_policy_dir)) {
 		ret = PTR_ERR(safesetid_policy_dir);
 		goto error;
 	}




^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] LSM: fix return value check in safesetid_init_securityfs()
  2019-02-12  7:58 [PATCH -next] LSM: fix return value check in safesetid_init_securityfs() Wei Yongjun
@ 2019-02-12 16:55 ` Kees Cook
  2019-02-12 19:01 ` James Morris
  1 sibling, 0 replies; 3+ messages in thread
From: Kees Cook @ 2019-02-12 16:55 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: James Morris, Serge E. Hallyn, Micah Morton,
	linux-security-module, kernel-janitors

On Mon, Feb 11, 2019 at 11:44 PM Wei Yongjun <weiyongjun1@huawei.com> wrote:
>
> In case of error, the function securityfs_create_dir() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should
> be replaced with IS_ERR().
>
> Fixes: aeca4e2ca65c ("LSM: add SafeSetID module that gates setid calls")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Nice catch! Thanks,

Acked-by: Kees Cook <keescook@chromium.org>

-Kees

> ---
>  security/safesetid/securityfs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/security/safesetid/securityfs.c b/security/safesetid/securityfs.c
> index 61be4ee459cc..2c6c829be044 100644
> --- a/security/safesetid/securityfs.c
> +++ b/security/safesetid/securityfs.c
> @@ -167,7 +167,7 @@ static int __init safesetid_init_securityfs(void)
>                 return 0;
>
>         safesetid_policy_dir = securityfs_create_dir("safesetid", NULL);
> -       if (!safesetid_policy_dir) {
> +       if (IS_ERR(safesetid_policy_dir)) {
>                 ret = PTR_ERR(safesetid_policy_dir);
>                 goto error;
>         }
>
>
>


-- 
Kees Cook

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH -next] LSM: fix return value check in safesetid_init_securityfs()
  2019-02-12  7:58 [PATCH -next] LSM: fix return value check in safesetid_init_securityfs() Wei Yongjun
  2019-02-12 16:55 ` Kees Cook
@ 2019-02-12 19:01 ` James Morris
  1 sibling, 0 replies; 3+ messages in thread
From: James Morris @ 2019-02-12 19:01 UTC (permalink / raw)
  To: Wei Yongjun
  Cc: Serge E. Hallyn, Kees Cook, Micah Morton, linux-security-module,
	kernel-janitors

On Tue, 12 Feb 2019, Wei Yongjun wrote:

> In case of error, the function securityfs_create_dir() returns ERR_PTR()
> and never returns NULL. The NULL test in the return value check should
> be replaced with IS_ERR().
> 
> Fixes: aeca4e2ca65c ("LSM: add SafeSetID module that gates setid calls")
> Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>

Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git next-general

-- 
James Morris
<jmorris@namei.org>


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-02-12 19:02 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-12  7:58 [PATCH -next] LSM: fix return value check in safesetid_init_securityfs() Wei Yongjun
2019-02-12 16:55 ` Kees Cook
2019-02-12 19:01 ` James Morris

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).