From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99375C43603 for ; Tue, 17 Dec 2019 13:38:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 73ABA206B7 for ; Tue, 17 Dec 2019 13:38:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728426AbfLQNiA (ORCPT ); Tue, 17 Dec 2019 08:38:00 -0500 Received: from mx2.suse.de ([195.135.220.15]:40836 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726164AbfLQNiA (ORCPT ); Tue, 17 Dec 2019 08:38:00 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 4F1CFAD5E; Tue, 17 Dec 2019 13:37:58 +0000 (UTC) Date: Tue, 17 Dec 2019 14:37:56 +0100 Message-ID: From: Takashi Iwai To: Jia-Ju Bai Cc: perex@perex.cz, tiwai@suse.com, rfontana@redhat.com, gregkh@linuxfoundation.org, allison@lohutok.net, tglx@linutronix.de, alsa-devel@alsa-project.org, LKML Subject: Re: [BUG] ALSA: seq: a possible sleep-in-atomic-context bug in snd_virmidi_dev_receive_event() In-Reply-To: References: User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI/1.14.6 (Maruoka) FLIM/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL/10.8 Emacs/25.3 (x86_64-suse-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 17 Dec 2019 14:24:21 +0100, Jia-Ju Bai wrote: > > The driver may sleep while holding a read lock. > The function call path (from bottom to top) in Linux 4.19 is: > > sound/core/seq/seq_memory.c, 96: >     copy_from_user in snd_seq_dump_var_event > sound/core/seq/seq_virmidi.c, 97: >     snd_seq_dump_var_event in snd_virmidi_dev_receive_event > sound/core/seq/seq_virmidi.c, 88: >     _raw_read_lock in snd_virmidi_dev_receive_event This can't happen. snd_virmidi_dev_receive_event() takes conditionally either read_lock or rw_sem depending on the atomic argument. And the data including user-space pointer is handled always with atomic=1, hence down_read() is used instead of read_lock() here. thanks, Takashi > copy_from_user() can sleep at runtime. > > I am not sure how to properly fix this possible bug, so I only report it. > > This bug is found by a static analysis tool STCheck written by myself. > > > Best wishes, > Jia-Ju Bai >