Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp2918329ybi; Sun, 28 Jul 2019 21:01:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbTSvN3ceEXmpT5FWf2bsKOiXsjPby5+huS1hln3VGkRefrftW034RmSh2RAAtsyFAzn/7 X-Received: by 2002:a17:902:7c96:: with SMTP id y22mr110175413pll.39.1564372862317; Sun, 28 Jul 2019 21:01:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564372862; cv=none; d=google.com; s=arc-20160816; b=O5MYZuFF4dnwOH0qcOjJ7sQEV7CleRkFCzXOQ1r6dytaHo8+H00+H4j/yKQIGHoz9a MdEslK8nYyOfH4E6EMSctoE4zAesRRdJjz98biRTwhfAiHGgkepVd4ysBB7iTVqYYfLW u0KRrtpJ7Ya8q0agk0h521MPRT5xv3Wn1Rn8BhXLDodox3SozAh6o2Sjwf+14pUGMDv0 2+LRapdQ4KkJaX67D2ebDD9b+9WajH+FXFniKXhOhl3oTLIRe9WOj/ynaSPe4T2ZpH0s h8EyGnbAuWQs7BH+x6asz1yGcjO/kwTW5Vl4E5HpcYPQm0/mY/eTJdp4J5mQH6Y9klDI NiLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:mime-version:user-agent:date:message-id :cc:to:subject:from:dkim-signature; bh=8PRy5r0RLK0DMjkOaMUsvRFz+2ENwpqQIfeTXdyxYK0=; b=fy2m6B2r3h/81C16+p6EseTKgX/MB0Y6Byb6b5VbvnEvZkJDpGWEQEYc7He7r3A9qV tqSAQVopUD3+KWne+mxwPfhFSBLuEgzYXBM6Bp9CSMiauOcjpS3oR9/iyqvK70gl9hJw foUUZeK5ccZ2iUSKSpjnbRiNDxESP8xxvXqI+sBYa+D/Rkd3YXWPOcHOk/uWxaAs0amw Kdf/aKutM3RZylfi6GB7egHnuqM/6SFrrG/7FMFTejYQJlK/1lz2ohxXpg+yKr576p5I TAFXqQK9wPHyGdywZvtXaczRR2gT3UiniQ6q1QyU4Anp4CM6RZAPWtu+xh0YZe7RHkDj 7ZjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ya4JdOTt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z10si24339151pln.285.2019.07.28.21.00.45; Sun, 28 Jul 2019 21:01:02 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ya4JdOTt; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726432AbfG2DyH (ORCPT + 99 others); Sun, 28 Jul 2019 23:54:07 -0400 Received: from mail-pf1-f169.google.com ([209.85.210.169]:32885 "EHLO mail-pf1-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726134AbfG2DyG (ORCPT ); Sun, 28 Jul 2019 23:54:06 -0400 Received: by mail-pf1-f169.google.com with SMTP id g2so27276669pfq.0 for ; Sun, 28 Jul 2019 20:54:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:to:cc:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=8PRy5r0RLK0DMjkOaMUsvRFz+2ENwpqQIfeTXdyxYK0=; b=Ya4JdOTtk+x6/WCvUjb2tHR2eBqA9nEE7GaNgrR9Cvp3n4aNQiBKTO/KUreWTbnn+I MTw4x1ddRkXHwAKdh8LnjiCPvxOcHgL+YAZPVlKrrtTOjqXGQpGyJmbSiojE4I3VeEsJ XFdtruFZadpL1WH+7cgoJoaEDiYNoHjhklqRZ2XXh7sNfA/aD3hmU63YIU76FHfEWGTW NRAga2YcRMPVlu8PRBmHMG/aMnb571NUgr/oUgLjVDwinjlx57p8GKlm0NtElrS8G8dd GeIDFa6sNLkG5/q22rnueLxVheiqt9kPwgzU1SScz5K3Xg3PCNUz5Ulst/Ob3zmUqgSh 8/WQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:cc:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=8PRy5r0RLK0DMjkOaMUsvRFz+2ENwpqQIfeTXdyxYK0=; b=ZDzYGzRIzpzVh6b1MrKWwn5gy3Gya/Wi7EKwA0lj4poRg9nEn1gRffLT2paIoN+tUf M90xB2lg4xCDVJvFB7yWsLv2+RROUOYEOMRUz8sj/C7R7itYPYJbtjzeGKLRDJ1gulqO +P5RVXsTAGa+IU5V10UWPRT8mnBnk2B4nSejNkMkkFgfN7bA6HwCBSSucTD/gNhff6I0 XRwjKj9MtzaE8FEcors8il14nv1DZZAqt/4F4I8Hxe/nN2nVM52I9PoWOoGwrh4sagAy BZQSVXZdkPuzg14QN75mzDWclGNh1Vbgbwg+a0n606F8BMHWwagdbeeJyilOOKPNMMAt vm3w== X-Gm-Message-State: APjAAAW+yzWC79RT9maXEcxYq/dHNWF+buiLPUGoHWggOnHq39QQWGzW 95+VcPeM7PVzdoAH6qX1EVRyeRcCrVw= X-Received: by 2002:a65:5183:: with SMTP id h3mr9557074pgq.250.1564372446085; Sun, 28 Jul 2019 20:54:06 -0700 (PDT) Received: from ?IPv6:2402:f000:4:72:808::177e? ([2402:f000:4:72:808::177e]) by smtp.gmail.com with ESMTPSA id p26sm5438031pgl.64.2019.07.28.20.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 28 Jul 2019 20:54:05 -0700 (PDT) From: Jia-Ju Bai Subject: [BUG] ALSA: core: seq: a possible double-lock bug in snd_seq_midisynth_remove() To: perex@perex.cz, Takashi Iwai , gregkh@linuxfoundation.org, rfontana@redhat.com, allison@lohutok.net, tglx@linutronix.de Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Message-ID: <50b3b4c4-fe36-8c65-345b-f0a51193726c@gmail.com> Date: Mon, 29 Jul 2019 11:54:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In snd_seq_midisynth_remove(), there is a possible double-lock bug: snd_seq_midisynth_remove()     mutex_lock(®ister_mutex); -- line 421     snd_seq_delete_kernel_client() --- line 436         seq_free_client() -- line 2244             mutex_lock(®ister_mutex); -- line 294 This bug is found by a static analysis tool STCheck written by us. I do not know how to correctly fix this bug, so I only report it. A possible fix is to release the mutex lock before calling seq_free_client() in snd_seq_delete_kernel_client() and then acquiring the lock again after calling seq_free_client(). Best wishes, Jia-Ju Bai