Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp395082rwr; Thu, 27 Apr 2023 02:58:22 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6Kl0HcaAT+s1m4S+lLf1ebAgr1vWd4kycf/yqlI3V1WFjlPOWVOY0TNbxCyQYH/8CDXrrY X-Received: by 2002:a05:6a20:8e19:b0:f6:9492:93b8 with SMTP id y25-20020a056a208e1900b000f6949293b8mr1068347pzj.3.1682589502181; Thu, 27 Apr 2023 02:58:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682589502; cv=none; d=google.com; s=arc-20160816; b=cZ2UbO/MHBxv3bphLp6otgYTVcyw9/vrEhQ8MgZW3AvmBt3gLzdb7S8xpnaQ8x250y 5vUgtBnwmmamSXS+f24Qy+DKNwLo7G7xM4KECfF7xgxTAb6UVn0nIUSWsdi2AThfJS63 HrB1k+mP+hRCy+0xrFPnncZ1JrdHvnACpapIUL2WrcfYyNu8biLnrU051m5EZM2eTrX8 8ZvZQRVLYE2PCT8e79xJGSzO8kFD0t4XJYIMNjs6jPWxMyW5cXuK+9zfMd0NQudZ2038 clm88AFQ3JXb+UTXYg7TTy61DkTEReR1uh4YOfOOX3yK+K5T5UMIAvlSKKxTyzZCskGk CwPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=2HrYL16OJO223tRxmXN/Upupp/FTnRlXxHzdSfG87Z4=; b=xzuuTmfBlQSdohBGLD+Bo1JS2U9HRSMJHIrPRlDyzj8aN5TqYazWFYx1ayu5MEplnn OehbQODC0TDEhnb2eUVw/Mucj7M7DN1XKnoxA35fgyKpF2dWl87eIl1l6bs9uSWJvy5d Rlpd5KxItivv5Ay7ljly7BHt8XZf9iTZajPhE29YjiapDW5M/uRowzPj5EBZvwjWTyOI jyywaysl6tB1Kds7AmaNwWoHmwPfyo8t7SXkxcKelT3sGWr2thItySpCP/IMqVP/a5RJ uXUtEqXX7wdBbTpAxaXTTk/yHjcN97rLzcqFaO8BDByIV0lrbXB4n5yUHJ+vKoidly6V taGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZuX6BWDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k4-20020a6555c4000000b0051b2893b8c9si18500169pgs.442.2023.04.27.02.58.10; Thu, 27 Apr 2023 02:58:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=ZuX6BWDP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243394AbjD0Jwg (ORCPT + 99 others); Thu, 27 Apr 2023 05:52:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37260 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243051AbjD0Jwf (ORCPT ); Thu, 27 Apr 2023 05:52:35 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5C2A092; Thu, 27 Apr 2023 02:52:34 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id E698B63C25; Thu, 27 Apr 2023 09:52:33 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 022C6C433EF; Thu, 27 Apr 2023 09:52:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1682589153; bh=lDpLhb6oF6to7W+j3Bea839ZLvE12k39h5dsPWICeB8=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=ZuX6BWDPYBtsbX8/2NU06aJrEdJZKJzgCLUP5duPvTh3xA6MHn5wjq4sY2c7y2eDM sMifHQnS9CBzV0TU4SncLFWx90ofXHC9uuSDf5J40GUkKzjRIavWLrTBNPl9VC8JnK EChbATmCfGQzWZHtoaYfxEwInABGzSJM+LHd8/Cs= Date: Thu, 27 Apr 2023 11:52:30 +0200 From: Greg Kroah-Hartman To: sangsup lee Cc: Srinivas Kandagatla , Amol Maheshwari , Arnd Bergmann , linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] misc: fastrpc: Fix a Use after-free-bug by race condition Message-ID: <2023042702-shuffling-tweet-d9f6@gregkh> References: <20230323013655.366-1-k1rh4.lee@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Apr 27, 2023 at 06:29:16PM +0900, sangsup lee wrote: > Is there any comment for this issue? What issue? > (reference: https://www.spinics.net/lists/kernel/msg4731408.html) Please use lore.kernel.org links, we have no control over any other random email archive . And the above link just points to this proposed patch. > > > 2023년 3월 23일 (목) 오전 10:37, Sangsup Lee 님이 작성: > > > > From: Sangsup lee > > > > This patch adds mutex_lock for fixing an Use-after-free bug. > > fastrpc_req_munmap_impl can be called concurrently in multi-threded environments. > > The buf which is allocated by list_for_each_safe can be used after another thread frees it. How was this tested? > > > > Signed-off-by: Sangsup lee > > --- > > V1 -> V2: moving the locking to ioctl. > > > > drivers/misc/fastrpc.c | 2 ++ > > 1 file changed, 2 insertions(+) > > > > diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c > > index 93ebd174d848..aa1cf0e9f4ed 100644 > > --- a/drivers/misc/fastrpc.c > > +++ b/drivers/misc/fastrpc.c > > @@ -1901,7 +1901,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int cmd, > > err = fastrpc_req_mmap(fl, argp); > > break; > > case FASTRPC_IOCTL_MUNMAP: > > + mutex_lock(&fl->mutex); > > err = fastrpc_req_munmap(fl, argp); > > + mutex_unlock(&fl->mutex); Are you sure you can call this function with the lock? If so, why isn't the mmap ioctl also locked? thanks, greg k-h