Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp5608188imu; Wed, 26 Dec 2018 05:58:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN51t4zBshmtGexqtkGiZbsY+Yla5R6E351zAQU2luZKm5/7ldbvBcdAAt30D4mEY9Km0PAJ X-Received: by 2002:a63:7154:: with SMTP id b20mr18940644pgn.342.1545832685183; Wed, 26 Dec 2018 05:58:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545832685; cv=none; d=google.com; s=arc-20160816; b=fc83I7/AXhE8Nkdn6ctTi8ZeINswq2bqzORtya7mpW5mvRuzUHi8wE4KPO57OSPop2 /LrKL8/Daipn5UQc/lNxgH6f7mp3VL4akH9o80hezQY8GAimuZ2zCg7QjaQ40PwcixRD en8y3APxavVohZ//wezuaaxeCQdNWWWi4A2jiZxhWULgQV9kS447r6Ugx4j2x8lvUYmw Qrn34k0L4h5CLhJuuSxMEMn9B+D10rOyIYG+yp7j6YfOD4Uzg2K/YSrJhv1C3GMeqiW6 aIt2/CYtvOow0vxHOmw8hjc8XOK6JkNIVFV/0OitKcnbsmk7K9TLqNnGPBLGPgciD73D c3fg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=Qhjg8LblQ0WGbiz7CbwsvK0KdMnAAmu57szDmISm94I=; b=FIs0RC/yAKQIEv4p+f4yOxmKZIxIyecslDo/M99CpAO9AAg8uaRZRUQFCdJ//XW2uL 1L+tIiE1jKS5uVWyHdxpxa9+x8Q5c+R/oZDZOJVP1sdEd05FClynwl6ztt8h29xMWig6 WzRenAoSEXy5QJ4F6Yf3B1NEOsx0t6qTvwUfmxqwPtWXRpaJaHlz2etxZOyfUABh1K6d abzgciE0mtjAU33AKrki7a5ZJvP7B3wSDfkHHPeQtqxk4JtJw2bl389ZYw3BG3Ky1Wm/ KXKfuUjW9XF5SwsUqrXCtmX586iFaJTMT2hVFcO6yZDCTQJXwUfOH3u4X9caY8ymzHXu mXSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bCx2F6qe; 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 b7si33934608plk.206.2018.12.26.05.57.50; Wed, 26 Dec 2018 05:58:05 -0800 (PST) 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=bCx2F6qe; 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 S1727057AbeLZN4f (ORCPT + 99 others); Wed, 26 Dec 2018 08:56:35 -0500 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43905 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726666AbeLZN4f (ORCPT ); Wed, 26 Dec 2018 08:56:35 -0500 Received: by mail-pl1-f196.google.com with SMTP id gn14so7574393plb.10 for ; Wed, 26 Dec 2018 05:56:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Qhjg8LblQ0WGbiz7CbwsvK0KdMnAAmu57szDmISm94I=; b=bCx2F6qe1vdyqKXcQ44k0wdGD+PDCcombv9NkQ61kvMnmzijR03FyDX8WqXR6Mo5wC sqBBI30o/byeoNudrk+znOWOXyG95jIynL2IyumGxr9hTmgx/wSNOb0SKZW8RN8KL9IN BAmOV76XQkYN8IdGYHVYsucUx3Q9t/IaQ+bd6xOgox9He4dt2uWpvPPHUFQU56llp9iQ rS1b1DRvPg6LZXK80AeA/8IIJzmIO8Ub19LYFgwmNsRFycQr7SzBwA+ey6QFGoPC45o4 HfiZ9lllmHCVIbS7u+iZhXWUEetE9nTWKJnCb91gEuMCsG8JojtsC4udJnFplAy4C3g6 uMWw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Qhjg8LblQ0WGbiz7CbwsvK0KdMnAAmu57szDmISm94I=; b=j5J0+aRPiGsvLTqLzDz3YvH9Uxi1wd204z56j80eZc/PBu7lmgBEczVhMFWksN15Mv GF7xtrlUQzcxh5omC2UuM31f8Z/wlmjDKNOM3gGDnhOMt989O/Y/z8tbN9M8NnHXTCCm wum9B9XoYzSwovMDrnRiTfDcAqyd+pSv79FtTVhlqD6Fw2pHoQ0A1KxwjthK+ljWUZ3u LOSsyB9xp98eSPUM5TrL8MSqZoejW2w/RCmP1lhb/FJF9yvBWGj96f31kzH285ALsibz ax0M8U3i7b8himoeOdvqGtcmktF4M+P4CLlT0dbMNoY29f9Wq1GtSr75BwF6r/nBONbL azOA== X-Gm-Message-State: AJcUukeFFbuuOl/ZPZFCoQrOmKDlkfCiNC04bocXu+qEPqmFdY3HwAIg DIYQwy67tUklp+cL98J6soI= X-Received: by 2002:a17:902:70c6:: with SMTP id l6mr20360552plt.30.1545832594695; Wed, 26 Dec 2018 05:56:34 -0800 (PST) Received: from localhost.localdomain ([2402:f000:1:4414:a8df:74f3:1213:8d3d]) by smtp.gmail.com with ESMTPSA id u137sm63256258pfc.140.2018.12.26.05.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Dec 2018 05:56:33 -0800 (PST) From: Jia-Ju Bai To: benh@kernel.crashing.org, dhowells@redhat.com, joel@jms.id.au, eajames@linux.vnet.ibm.com, andrew@aj.id.au Cc: linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] fsi:fsi-sbefifo: Fix possible concurrency use-after-free bugs in sbefifo_user_release Date: Wed, 26 Dec 2018 21:56:18 +0800 Message-Id: <20181226135618.12784-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In drivers/fsi/fsi-sbefifo.c, the functions sbefifo_user_release(), sbefifo_user_read() and sbefifo_user_write() may be concurrently executed. sbefifo_user_release() sbefifo_release_command() vfree(user->pending_cmd); sbefifo_user_read() mutex_lock(); rc = __sbefifo_submit(sbefifo, user->pending_cmd, ...); sbefifo_user_write() mutex_lock(); user->pending_cmd = user->cmd_page; user->pending_cmd = vmalloc(len); Thus, possible concurrency use-after-free bugs may occur in sbefifo_user_release(). To fix these bugs, the calls to mutex_lock() and mutex_unlock() are added in sbefifo_user_release(). Signed-off-by: Jia-Ju Bai --- drivers/fsi/fsi-sbefifo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index d92f5b87c251..e278a9014b8f 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -900,8 +900,10 @@ static int sbefifo_user_release(struct inode *inode, struct file *file) if (!user) return -EINVAL; + mutex_lock(&user->file_lock); sbefifo_release_command(user); free_page((unsigned long)user->cmd_page); + mutex_unlock(&user->file_lock); kfree(user); return 0; -- 2.17.0