ipc: Free mq_sysctls if ipc namespace creation fails

This fixes a bug with error handling if ipc creation fails that
 was reported by syzbot.
 
 Alexey Gladkov (1):
       ipc: Free mq_sysctls if ipc namespace creation failed
 
  ipc/namespace.c | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEgjlraLDcwBA2B+6cC/v6Eiajj0AFAmLMfwQACgkQC/v6Eiaj
 j0DFahAAjYtgqmSDyIhdkD+vvv4342KDar9apH0bB++Sxv5FaAtrjDWgcI2MvLMB
 Xo347ZuMLV08KtiF3/y13kpQMcMKN+IcU+kGeACPRQC7J9XqBwJaF+odCgGl0V9M
 VBaVdUhFmiW5XI5an2MaXRz8CriX3Wrjclkn4Mhk7svfdfajY5IyDQkIBpo+Ku7y
 3pIkgryWQOvMga4WY7gURf9ehuJVdoZ80SSplWhiEj87bW7g59cX2ZSQ4xiUGMGe
 j/RR9BM4iO/wqRZr8BEeQa3D4O7VGtEVUKL4QLo/COPRBE9Nyv492Fa/W98makWB
 cbYUEHSnaBYCIG9CdALzsr/EXfix1f1N36SPMabQvR6CQSvEAd9ACg4HUkjNr4Gq
 07SBI8MokFIkOFkVJrqfH7+ePUlJ+ZOMF902dUjxx9MhRgnhPjv3aWhuglW9uAEm
 aIYIoxjGmA0x6KBPTn0O2RoBLb0QUMwVoLDVPZIoLy0KgFpsoFvs1KiqQHcxksnz
 fjdYKALyIyg/c1KCaLd2YNI2WSf1wtLgXjZZOm5ofGxe5Z2U934eSYsgQZ8YWpQE
 MMVk7b8EJ9XnRYYoK/nX7IC6Zej4LUD4KRc8U2wirtb5KDcxiWBveSd6cgpfMRxr
 tLRJbauo9NkWdpCBQageW38XC3g84Cs04DP7jClNTUZb3zxvNUc=
 =4sfy
 -----END PGP SIGNATURE-----
mergetag object 3418357a32
 type commit
 tag ptrace_unfreeze_fix-for-v5.19
 tagger Eric W. Biederman <ebiederm@xmission.com> 1657569245 -0500
 
 ptrace: fix clearing of JOBCTL_TRACED in ptrace_unfreeze_traced()
 
 This change fixes a small but very annoying typo.
 
 Sven Schnelle (1):
       ptrace: fix clearing of JOBCTL_TRACED in ptrace_unfreeze_traced()
 
  kernel/ptrace.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
 
 Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCgAdFiEEgjlraLDcwBA2B+6cC/v6Eiajj0AFAmLMf9wACgkQC/v6Eiaj
 j0Bx4BAAs0a/QPG4PeHWfHBAydW81qr1DX95MZLN5Neec8abMe5hel0Z0JMpAnlq
 yM2hjxBy3kux6MbKbaqkIpdcKH0TMNg/D+11vyfID6hMzzPNr7SKzoyePWy07kNa
 gLv5BLEuyg9tvs7fVI26SxEBOyK+DhrBMr8pADWlakMOshorvuQWOmyiHdWgWtRU
 d0SQm310fdltTqX6x6PJ2cXrRtXU3Kg7zUVfw8twu7Z1yYXJG8UpXkyKXAl1ttt2
 GtCpPsy788TrmHfUJQUKPyGMRvsOKu1kkP3caKMdT8k0oEpXAppAFsE7maEEkodp
 YLyUSnTwobPg6TmnwrbmYPPI+QdWDpzltQPVvV1Jun6cU41qXbES+2ULq0AKJIOG
 NtY1QIQxy49BRxudXu3hDiR185JA6x3BrhnBKTpoe4A53EvejH8K2CWStuMq35qU
 X0AhahEcd86Ol192gKUo69F0d8v8CbR/z3E0ULOzY+jIDXg2b470jLADBSktRLXT
 WpMp1nGOVy5TZb6R7U3kDDkBPG4+yLB+aIRAWM5NE5Bb4rzBBt4wBrsJ0Vhhf+sf
 CUwTDftKo7pNNjeRV+ad7DrW0rcHZ++YgQB8kpG/VwrypRmR77zc39Qtn0+OXwq4
 2rhR8NxLnu5pxblLMzb0IQXuTG4Llr6olmao1imfS78XsrP4DZc=
 =gOnj
 -----END PGP SIGNATURE-----

Merge tags 'free-mq_sysctls-for-v5.19' and 'ptrace_unfreeze_fix-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace

Pull ipc namespace fix from Eric Biederman:
 "This fixes a bug with error handling if ipc creation fails that was
  reported by syzbot"

For completeness, this also pulls the ptrace_unfreeze_fix tag that
contains the original version of one of the hotfixes that I manually
applied earlier so that it would be fixed in rc6.

* tag 'free-mq_sysctls-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  ipc: Free mq_sysctls if ipc namespace creation failed

* tag 'ptrace_unfreeze_fix-for-v5.19' of git://git.kernel.org/pub/scm/linux/kernel/git/ebiederm/user-namespace:
  ptrace: fix clearing of JOBCTL_TRACED in ptrace_unfreeze_traced()
This commit is contained in:
Linus Torvalds 2022-07-11 14:33:41 -07:00
commit 23458ac91d

View File

@ -64,7 +64,7 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
goto fail_put;
if (!setup_ipc_sysctls(ns))
goto fail_put;
goto fail_mq;
sem_init_ns(ns);
msg_init_ns(ns);
@ -72,6 +72,9 @@ static struct ipc_namespace *create_ipc_ns(struct user_namespace *user_ns,
return ns;
fail_mq:
retire_mq_sysctls(ns);
fail_put:
put_user_ns(ns->user_ns);
ns_free_inum(&ns->ns);