From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933515AbcIEKdj (ORCPT ); Mon, 5 Sep 2016 06:33:39 -0400 Received: from mail.ispras.ru ([83.149.199.45]:35780 "EHLO mail.ispras.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933454AbcIEKdh (ORCPT ); Mon, 5 Sep 2016 06:33:37 -0400 Subject: Re: A potential race in drivers/staging/speakup/speakup.ko To: Samuel Thibault , William Hubbs , Chris Brannon , Kirk Reiser , speakup@linux-speakup.org, devel@driverdev.osuosl.org, linux-kernel@vger.kernel.org, Vaishali Thakkar , ldv-project@linuxtesting.org References: <2b13ceb6-9494-7bec-d0e5-8033c66a8721@ispras.ru> <20160905094317.GB15376@var.bordeaux.inria.fr> <58cca2ca-e73c-b7ae-9da9-36be6084caf4@ispras.ru> <20160905095638.GL15376@var.bordeaux.inria.fr> From: Pavel Andrianov Message-ID: Date: Mon, 5 Sep 2016 13:33:33 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <20160905095638.GL15376@var.bordeaux.inria.fr> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 05.09.2016 12:56, Samuel Thibault пишет: > Pavel Andrianov, on Mon 05 Sep 2016 12:54:10 +0300, wrote: >> 05.09.2016 12:43, Samuel Thibault пишет: >>> Pavel Andrianov, on Mon 05 Sep 2016 11:51:50 +0300, wrote: >>>> There is a potential race in drivers/staging/speakup/speakup.ko. >>>> All operations with global pointers buff_in and buff_out are performed >>>> without any locks. Thus, a simultaneous write (via synth_buffer_clear or >>>> synth_buffer_add) to the pointers may lead to inconsistent data. >>>> >>>> Should a local lock be used here? >>> >>> AIUI, all callers of these functions have speakup_info.spinlock held. >> >> Regard a call stack >> >> -> synth_direct_store >> -> synth_printf >> -> synth_buffer_add >> >> The functions have not held speakup_info.spinlock. > > Apparently there is currently no caller of synth_direct_store and > synth_store. But taking the lock here would be needed indeed. > > Samuel > synth_direct_store may be called via device_attributes interface. In which function the lock should be added? -- Pavel Andrianov Linux Verification Center, ISPRAS web: http://linuxtesting.org e-mail: andrianov@ispras.ru