Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp626413ybi; Wed, 19 Jun 2019 05:18:46 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJBFFMOnB3fbKm8hNghM/oHkQGLPcIYpIEejHlFhnCdPQup+Nlw5HiQ6zyheJcGTHvWU+y X-Received: by 2002:a17:902:e40f:: with SMTP id ci15mr40958374plb.103.1560946725923; Wed, 19 Jun 2019 05:18:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560946725; cv=none; d=google.com; s=arc-20160816; b=oImrFDXw1zRGkfnum4TQOZRlF0aH/n/PmRVbf3nYPph3If6PCfcETyUEUhdXH1zov5 YkDAJZkNYOsg8INqPvOeMU7ukCSgneEZAjo/p+ceOQpAyijssUQE/DvIxaro8E+v2Zej rIbwnCLxu1pwvhG057XsrNcgVtpwa1gjaOXs7uC0yrZw1DS3BYjC4a3YKZsie7gkgyOT MAszzMceCsbLHYPqKSMlNYi72U+I5w8LVbZXYpwhkCekFms/gXkS8zFFENPmT7tK/TBn bvxv3zFZhSEvZLWQUDYWyMwfIiEJS3WWe+LFXs8d9lCJkCWCERjMJP9ifqteiRtH41XR Wjwg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=76BMk/WPoYr/JswLwOQN/gMdcSyGJuxxsHCJj5vHwNI=; b=gbo3jJU1VL2dInEdfMu4ggVhpBxYcb4Jrjkd2EKxLsdDnpA0E+/4Yb3qoXnMlFgkLN R3xG72cChIhKYtmKGPZ1AksDEz5QzjAL9AB7FUVyYhzC/E/8uk8H4XRwZSNEzgDP/klQ VzsC59po9pE5Vc76kR85r3CcJ1cfKEox17PNZkCtcGlEKoikYbim85Vr5BxmcUiveKlh VGzUCDLzUOE5IjckJHoU/OUA00vlrxk2KN7kZ4sO4ujRYK+rGT5HoT6p7KhkVB8h8m/L SNTzEZUuMvBRis/J6RFOAOMt9MKpZS7jHkoy7lSfNsm5iiPAX23BoN2cf3/3g6wGhIg/ e5Wg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g90si15728078plb.282.2019.06.19.05.18.30; Wed, 19 Jun 2019 05:18:45 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731861AbfFSMQm (ORCPT + 99 others); Wed, 19 Jun 2019 08:16:42 -0400 Received: from atrey.karlin.mff.cuni.cz ([195.113.26.193]:60171 "EHLO atrey.karlin.mff.cuni.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731568AbfFSMQm (ORCPT ); Wed, 19 Jun 2019 08:16:42 -0400 Received: by atrey.karlin.mff.cuni.cz (Postfix, from userid 512) id DF92780470; Wed, 19 Jun 2019 14:16:27 +0200 (CEST) Date: Wed, 19 Jun 2019 14:16:38 +0200 From: Pavel Machek To: Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org, syzbot+e4c8abb920efa77bace9@syzkaller.appspotmail.com, Takashi Iwai , Sasha Levin Subject: Re: [PATCH 5.1 043/115] ALSA: seq: Protect in-kernel ioctl calls with mutex Message-ID: <20190619121637.GA19792@amd> References: <20190617210759.929316339@linuxfoundation.org> <20190617210802.258998943@linuxfoundation.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="cNdxnHkX5QqsyA0e" Content-Disposition: inline In-Reply-To: <20190617210802.258998943@linuxfoundation.org> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --cNdxnHkX5QqsyA0e Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi! > [ Upstream commit feb689025fbb6f0aa6297d3ddf97de945ea4ad32 ] >=20 > ALSA OSS sequencer calls the ioctl function indirectly via > snd_seq_kernel_client_ctl(). While we already applied the protection > against races between the normal ioctls and writes via the client's > ioctl_mutex, this code path was left untouched. And this seems to be > the cause of still remaining some rare UAF as spontaneously triggered > by syzkaller. >=20 > For the sake of robustness, wrap the ioctl_mutex also for the call via > snd_seq_kernel_client_ctl(), too. This is reverted with patch after the next one. Should simply this and the revert be deleted from the queue? Thanks, Pavel > diff --git a/sound/core/seq/seq_clientmgr.c b/sound/core/seq/seq_clientmg= r.c > index 38e7deab6384..b3280e81bfd1 100644 > --- a/sound/core/seq/seq_clientmgr.c > +++ b/sound/core/seq/seq_clientmgr.c > @@ -2343,14 +2343,19 @@ int snd_seq_kernel_client_ctl(int clientid, unsig= ned int cmd, void *arg) > { > const struct ioctl_handler *handler; > struct snd_seq_client *client; > + int err; > =20 > client =3D clientptr(clientid); > if (client =3D=3D NULL) > return -ENXIO; > =20 > for (handler =3D ioctl_handlers; handler->cmd > 0; ++handler) { > - if (handler->cmd =3D=3D cmd) > - return handler->func(client, arg); > + if (handler->cmd =3D=3D cmd) { > + mutex_lock(&client->ioctl_mutex); > + err =3D handler->func(client, arg); > + mutex_unlock(&client->ioctl_mutex); > + return err; > + } > } > =20 > pr_debug("ALSA: seq unknown ioctl() 0x%x (type=3D'%c', number=3D0x%02x)= \n", --=20 (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blo= g.html --cNdxnHkX5QqsyA0e Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iEYEARECAAYFAl0KJ6UACgkQMOfwapXb+vLRIACgpxVaZo8G/mYONSgkmeOfcYQ/ XHMAoJXByHRwnAmMnp39J/t+b2fnMDfk =8kd5 -----END PGP SIGNATURE----- --cNdxnHkX5QqsyA0e--