Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1944591ima; Mon, 22 Oct 2018 01:06:50 -0700 (PDT) X-Google-Smtp-Source: ACcGV61k8vcV+Ow7Q+J+CmiNNo3oSAnd0IwC/1+a7f902fYbnJaybRAt+yyTdqr/sYI+Jeb+z00i X-Received: by 2002:a62:569d:: with SMTP id h29-v6mr16301776pfj.42.1540195610546; Mon, 22 Oct 2018 01:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540195610; cv=none; d=google.com; s=arc-20160816; b=rhjLN4xnXLfnqmMWZhKrtq9FYaSBrb7xNdhNK4KxzH4Cu288G9frNit50FQAmdK4hd sdK8Pf9w10KtkSmHYihA2Iwfwuxci1oO51cyi8SrpwsQibhRUNJ4B15eEpBSbkn+VYYh M6dvlajw6UE8olN5jGNG87Ltx/Tj6J1sEh6cF3X8H8ZyyG4hFS8KN7Hi1RRPXcwcdCb9 4/h+rJwWvRQ7MlklsNDUe2jdUs9UWm4C6FWpksQMX1fKTJQ40KtW5lFTwoSQsTf7COPs zHKTDrYakrJ46XcCmkg3b/59sfpAHzkba/fyQEV8xCUJvZwxlxcbPm2gDtBBdBn7KEvu mz3w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=AKGwO0iKg+EbaW3eNBMSeeiY9xOau8G1hoba4TFd+nU=; b=qLVsaunlu8by+C+bl6Hl029LbQcXUQeA/E3jGEbIZ3oJlV1yoB6Yojq8BLMeZXnNpd f5ZndSQcZvq0lpYnncPqNSnC7NLbveRxGA/so9ni0ZEIx0zWBIhy5MJQa+x+qsJYsKMy xfEAdNz0aCUhEUKs1kJazFU6BtDTTkBHnUgZvEWD8lqBYRGxV07ayy59GxIA/evQdaQQ r1LndMPD6TDh+LHCQSjNLfS2Vs6ZzX+eNJeFxShDu59zbMHHMkWPcQO8KI5sJRtWQywI RBe8DowHnduEEGO5xN7cvPxTpTPK3fn/6EtJrlVu+LkKmKkc5XdUW1YtRHwF224QtmG7 ilBw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ba7-v6si10068501plb.8.2018.10.22.01.06.35; Mon, 22 Oct 2018 01:06:50 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbeJVQXY (ORCPT + 99 others); Mon, 22 Oct 2018 12:23:24 -0400 Received: from mga12.intel.com ([192.55.52.136]:32555 "EHLO mga12.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727523AbeJVQXY (ORCPT ); Mon, 22 Oct 2018 12:23:24 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 01:05:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,411,1534834800"; d="scan'208";a="101516638" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga001.jf.intel.com with SMTP; 22 Oct 2018 01:05:54 -0700 Received: by lahna (sSMTP sendmail emulation); Mon, 22 Oct 2018 11:05:53 +0300 Date: Mon, 22 Oct 2018 11:05:53 +0300 From: Mika Westerberg To: Wenwen Wang Cc: Kangjie Lu , Andreas Noever , Michael Jamet , Yehezkel Bernat , open list Subject: Re: [PATCH] thunderbolt: fix a missing-check bug Message-ID: <20181022080553.GM2302@lahna.fi.intel.com> References: <1540064869-17849-1-git-send-email-wang6495@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1540064869-17849-1-git-send-email-wang6495@umn.edu> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, Oct 20, 2018 at 02:47:49PM -0500, Wenwen Wang wrote: > In ring_work(), the first while loop is used to collect all completed > frames from the ring buffer. In each iteration of this loop, the flag of > the frame, i.e., 'ring->descriptors[ring->tail].flags' is firstly check to > see whether the frame is completed. If yes, the descriptor of the frame, > including the flag, is then copied. It is worth noting that the descriptor > is actually in a DMA region, which is allocated through > dma_alloc_coherent() in tb_ring_alloc(). Given that the device can also > access the DMA region, a malicious device controlled by an attacker can > race to modify the flag of the frame after the check but before the copy. > By doing so, the attacker can bypass the check and supply uncompleted > frame, which can cause undefined behavior of the kernel and introduce > potential security risk. > > This patch firstly copies the flag into a local variable 'desc_flags' and > then performs the check and copy using 'desc_flags'. Through this way, the > above issue can be avoided. Ditto :)