All of lore.kernel.org
 help / color / mirror / Atom feed
* [dhowells-fs:keys-intercept 20/21] kernel/pid_namespace.c:120 create_pid_namespace() warn: passing zero to 'ERR_PTR'
@ 2021-02-10  5:58 kernel test robot
  0 siblings, 0 replies; 2+ messages in thread
From: kernel test robot @ 2021-02-10  5:58 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 5088 bytes --]

CC: kbuild-all(a)lists.01.org
TO: David Howells <dhowells@redhat.com>

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git keys-intercept
head:   c851eb7ccfe5790cf61e58980a4020a7515fdac0
commit: eff294a56406acb033f57450097c21dd5177de6d [20/21] Add namespace tags that can be used for matching without pinning a ns
:::::: branch date: 6 days ago
:::::: commit date: 6 days ago
config: i386-randconfig-m021-20210209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/pid_namespace.c:120 create_pid_namespace() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +120 kernel/pid_namespace.c

f333c700c6100b Eric W. Biederman 2016-08-08   69  
49f4d8b93ccf94 Eric W. Biederman 2012-08-02   70  static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns,
49f4d8b93ccf94 Eric W. Biederman 2012-08-02   71  	struct pid_namespace *parent_pid_ns)
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   72  {
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   73  	struct pid_namespace *ns;
ed469a63c37a99 Alexey Dobriyan   2009-06-17   74  	unsigned int level = parent_pid_ns->level + 1;
f333c700c6100b Eric W. Biederman 2016-08-08   75  	struct ucounts *ucounts;
f2302505775fd1 Andrew Vagin      2012-10-25   76  	int err;
f2302505775fd1 Andrew Vagin      2012-10-25   77  
a2b426267c5677 Eric W. Biederman 2017-04-29   78  	err = -EINVAL;
a2b426267c5677 Eric W. Biederman 2017-04-29   79  	if (!in_userns(parent_pid_ns->user_ns, user_ns))
a2b426267c5677 Eric W. Biederman 2017-04-29   80  		goto out;
a2b426267c5677 Eric W. Biederman 2017-04-29   81  
df75e7748bae1c Eric W. Biederman 2016-09-22   82  	err = -ENOSPC;
f333c700c6100b Eric W. Biederman 2016-08-08   83  	if (level > MAX_PID_NS_LEVEL)
f333c700c6100b Eric W. Biederman 2016-08-08   84  		goto out;
f333c700c6100b Eric W. Biederman 2016-08-08   85  	ucounts = inc_pid_namespaces(user_ns);
f333c700c6100b Eric W. Biederman 2016-08-08   86  	if (!ucounts)
f2302505775fd1 Andrew Vagin      2012-10-25   87  		goto out;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   88  
f2302505775fd1 Andrew Vagin      2012-10-25   89  	err = -ENOMEM;
84406c153a5bfa Pavel Emelyanov   2008-07-25   90  	ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   91  	if (ns == NULL)
f333c700c6100b Eric W. Biederman 2016-08-08   92  		goto out_dec;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   93  
95846ecf9dac50 Gargi Sharma      2017-11-17   94  	idr_init(&ns->idr);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   95  
eff294a56406ac David Howells     2021-02-04   96  	err = init_ns_common(&ns->ns, false);
98f842e675f96f Eric W. Biederman 2011-06-15   97  	if (err)
eff294a56406ac David Howells     2021-02-04   98  		goto out_free;
33c429405a2c8d Al Viro           2014-11-01   99  	ns->ns.ops = &pidns_operations;
98f842e675f96f Eric W. Biederman 2011-06-15  100  
eff294a56406ac David Howells     2021-02-04  101  	ns->pid_cachep = create_pid_cachep(level);
eff294a56406ac David Howells     2021-02-04  102  	if (ns->pid_cachep == NULL)
eff294a56406ac David Howells     2021-02-04  103  		goto out_free;
eff294a56406ac David Howells     2021-02-04  104  
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  105  	ns->level = level;
ed469a63c37a99 Alexey Dobriyan   2009-06-17  106  	ns->parent = get_pid_ns(parent_pid_ns);
49f4d8b93ccf94 Eric W. Biederman 2012-08-02  107  	ns->user_ns = get_user_ns(user_ns);
f333c700c6100b Eric W. Biederman 2016-08-08  108  	ns->ucounts = ucounts;
e8cfbc245e2488 Gargi Sharma      2017-11-17  109  	ns->pid_allocated = PIDNS_ADDING;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  110  
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  111  	return ns;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  112  
eff294a56406ac David Howells     2021-02-04  113  out_free:
95846ecf9dac50 Gargi Sharma      2017-11-17  114  	idr_destroy(&ns->idr);
eff294a56406ac David Howells     2021-02-04  115  	destroy_ns_common(&ns->ns);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  116  	kmem_cache_free(pid_ns_cachep, ns);
f333c700c6100b Eric W. Biederman 2016-08-08  117  out_dec:
f333c700c6100b Eric W. Biederman 2016-08-08  118  	dec_pid_namespaces(ucounts);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  119  out:
4308eebbeb2026 Eric W. Biederman 2011-03-23 @120  	return ERR_PTR(err);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  121  }
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  122  

:::::: The code at line 120 was first introduced by commit
:::::: 4308eebbeb2026827d4492ce8c23d99f7f144a82 pidns: call pid_ns_prepare_proc() from create_pid_namespace()

:::::: TO: Eric W. Biederman <ebiederm@xmission.com>
:::::: CC: Linus Torvalds <torvalds@linux-foundation.org>

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37153 bytes --]

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

* [dhowells-fs:keys-intercept 20/21] kernel/pid_namespace.c:120 create_pid_namespace() warn: passing zero to 'ERR_PTR'
@ 2021-02-10  6:49 Dan Carpenter
  0 siblings, 0 replies; 2+ messages in thread
From: Dan Carpenter @ 2021-02-10  6:49 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 4751 bytes --]

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/dhowells/linux-fs.git  keys-intercept
head:   c851eb7ccfe5790cf61e58980a4020a7515fdac0
commit: eff294a56406acb033f57450097c21dd5177de6d [20/21] Add namespace tags that can be used for matching without pinning a ns
config: i386-randconfig-m021-20210209 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
kernel/pid_namespace.c:120 create_pid_namespace() warn: passing zero to 'ERR_PTR'

vim +/ERR_PTR +120 kernel/pid_namespace.c

49f4d8b93ccf94 Eric W. Biederman 2012-08-02   70  static struct pid_namespace *create_pid_namespace(struct user_namespace *user_ns,
49f4d8b93ccf94 Eric W. Biederman 2012-08-02   71  	struct pid_namespace *parent_pid_ns)
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   72  {
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   73  	struct pid_namespace *ns;
ed469a63c37a99 Alexey Dobriyan   2009-06-17   74  	unsigned int level = parent_pid_ns->level + 1;
f333c700c6100b Eric W. Biederman 2016-08-08   75  	struct ucounts *ucounts;
f2302505775fd1 Andrew Vagin      2012-10-25   76  	int err;
f2302505775fd1 Andrew Vagin      2012-10-25   77  
a2b426267c5677 Eric W. Biederman 2017-04-29   78  	err = -EINVAL;
a2b426267c5677 Eric W. Biederman 2017-04-29   79  	if (!in_userns(parent_pid_ns->user_ns, user_ns))
a2b426267c5677 Eric W. Biederman 2017-04-29   80  		goto out;
a2b426267c5677 Eric W. Biederman 2017-04-29   81  
df75e7748bae1c Eric W. Biederman 2016-09-22   82  	err = -ENOSPC;
f333c700c6100b Eric W. Biederman 2016-08-08   83  	if (level > MAX_PID_NS_LEVEL)
f333c700c6100b Eric W. Biederman 2016-08-08   84  		goto out;
f333c700c6100b Eric W. Biederman 2016-08-08   85  	ucounts = inc_pid_namespaces(user_ns);
f333c700c6100b Eric W. Biederman 2016-08-08   86  	if (!ucounts)
f2302505775fd1 Andrew Vagin      2012-10-25   87  		goto out;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   88  
f2302505775fd1 Andrew Vagin      2012-10-25   89  	err = -ENOMEM;
84406c153a5bfa Pavel Emelyanov   2008-07-25   90  	ns = kmem_cache_zalloc(pid_ns_cachep, GFP_KERNEL);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   91  	if (ns == NULL)
f333c700c6100b Eric W. Biederman 2016-08-08   92  		goto out_dec;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   93  
95846ecf9dac50 Gargi Sharma      2017-11-17   94  	idr_init(&ns->idr);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08   95  
eff294a56406ac David Howells     2021-02-04   96  	err = init_ns_common(&ns->ns, false);
98f842e675f96f Eric W. Biederman 2011-06-15   97  	if (err)
eff294a56406ac David Howells     2021-02-04   98  		goto out_free;
33c429405a2c8d Al Viro           2014-11-01   99  	ns->ns.ops = &pidns_operations;
98f842e675f96f Eric W. Biederman 2011-06-15  100  
eff294a56406ac David Howells     2021-02-04  101  	ns->pid_cachep = create_pid_cachep(level);
eff294a56406ac David Howells     2021-02-04  102  	if (ns->pid_cachep == NULL)
eff294a56406ac David Howells     2021-02-04  103  		goto out_free;

"err" not set on this path.

eff294a56406ac David Howells     2021-02-04  104  
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  105  	ns->level = level;
ed469a63c37a99 Alexey Dobriyan   2009-06-17  106  	ns->parent = get_pid_ns(parent_pid_ns);
49f4d8b93ccf94 Eric W. Biederman 2012-08-02  107  	ns->user_ns = get_user_ns(user_ns);
f333c700c6100b Eric W. Biederman 2016-08-08  108  	ns->ucounts = ucounts;
e8cfbc245e2488 Gargi Sharma      2017-11-17  109  	ns->pid_allocated = PIDNS_ADDING;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  110  
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  111  	return ns;
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  112  
eff294a56406ac David Howells     2021-02-04  113  out_free:
95846ecf9dac50 Gargi Sharma      2017-11-17  114  	idr_destroy(&ns->idr);
eff294a56406ac David Howells     2021-02-04  115  	destroy_ns_common(&ns->ns);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  116  	kmem_cache_free(pid_ns_cachep, ns);
f333c700c6100b Eric W. Biederman 2016-08-08  117  out_dec:
f333c700c6100b Eric W. Biederman 2016-08-08  118  	dec_pid_namespaces(ucounts);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  119  out:
4308eebbeb2026 Eric W. Biederman 2011-03-23 @120  	return ERR_PTR(err);
74bd59bb39eb08 Pavel Emelyanov   2008-02-08  121  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org 

_______________________________________________
kbuild mailing list -- kbuild(a)lists.01.org
To unsubscribe send an email to kbuild-leave(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 37153 bytes --]

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

end of thread, other threads:[~2021-02-10  6:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-10  5:58 [dhowells-fs:keys-intercept 20/21] kernel/pid_namespace.c:120 create_pid_namespace() warn: passing zero to 'ERR_PTR' kernel test robot
2021-02-10  6:49 Dan Carpenter

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.