Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1946566ima; Mon, 22 Oct 2018 01:09:21 -0700 (PDT) X-Google-Smtp-Source: AJdET5fsqWHIlr7/MDFKrG37MoRejbfUwAqDvFDLq/Wmf/9LxYKs6fHghElG5R0P+bWAIqR5jMj0 X-Received: by 2002:a63:588:: with SMTP id 130mr311680pgf.273.1540195761400; Mon, 22 Oct 2018 01:09:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540195761; cv=none; d=google.com; s=arc-20160816; b=wfrjkO8SQFA5ARt9DfLeu4tAn4tUKCAASDLviZ9ME6e+45G6G48gdJBx2+KJJCtXAO S0bdyCJg2k+G29ZafHQOS0cud8wOGcWURsQQvZZiIpWqwPdAXg8nWXtDhSv/c28v4wgY B2fG4CP60w6RxJANlTekFE1KoTnQQ4TLF4CSEpblk77YYnxpRtF8IHrn24vtdixkwK6s rN8I2E/0OVNFZ8mOb0/JoXwY92nedSC3Dmrh+Med0xSJ+CJuPEbfQQgJjCywCTBnGN7o CXccjd8NAM5Wn+4oDErdzsVQr5SQIRdyXMrXSSCN1X0PkfIiglh0ZhgjUQXlxBWpiFqc 5bTw== 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=wJJ7xv7yXocBmI+GX1AhZaFUG317gotNnbQe12Gnx8I=; b=L2Osx1Sw8pXEHghZBlMzkpyZ9tGcWpx182HU5NtZQpDSgx++PEVqD1TGapk3s7Oz7o lXX+CkTbjCto06zkN4gslj9J9b4i2dXB1+USCbWU8s/cpRFlqNE0g2Ek2tXw20ubmLIX wTxfWRKON5c8r3XGK/tz4T6v+gQygcH201bKC8vvuY0ooKnHfljI1Owr6m15B68GLYQH iOEyocU5Ed/gVgBEU/mjPsZ19kUfjnm3bBiQlgg23EtjT9pE3jXoZWdr81/sXmB7kApY e8er5n3uX0Ht1csOwiHtqMWj+/UN0VSnv3si7I5ZnST3raZR0pQxEz3HxxvRJGXaFqBe 0Jnw== 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 f11-v6si37311697plm.244.2018.10.22.01.09.06; Mon, 22 Oct 2018 01:09:21 -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 S1727981AbeJVQXl (ORCPT + 99 others); Mon, 22 Oct 2018 12:23:41 -0400 Received: from mga14.intel.com ([192.55.52.115]:44872 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727523AbeJVQXl (ORCPT ); Mon, 22 Oct 2018 12:23:41 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 01:06:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,411,1534834800"; d="scan'208";a="274462046" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by fmsmga006.fm.intel.com with SMTP; 22 Oct 2018 01:06:10 -0700 Received: by lahna (sSMTP sendmail emulation); Mon, 22 Oct 2018 11:06:09 +0300 Date: Mon, 22 Oct 2018 11:06:09 +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: <20181022080609.GN2302@lahna.fi.intel.com> References: <1540066556-18088-1-git-send-email-wang6495@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1540066556-18088-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 03:15:56PM -0500, Wenwen Wang wrote: > In tb_ring_poll(), the flag of the frame, i.e., > 'ring->descriptors[ring->tail].flags', is checked to see whether the frame > is completed. If yes, the frame including the flag will be read from the > ring and returned to the caller. The problem here is that the flag is > actually in a DMA region, which is allocated through dma_alloc_coherent() > in tb_ring_alloc(). Given that the device can also access this DMA region, > it is possible that a malicious device controlled by an attacker can modify > the flag between the check and 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. Same here :)