Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1964343ima; Mon, 22 Oct 2018 01:34:44 -0700 (PDT) X-Google-Smtp-Source: ACcGV62FNVSmrHyNEzywy0FLpfeF9se6q1HBM08TB5Uf6Ycm8Cvbo/LUrtXYINS2NZCGxW53Lj+A X-Received: by 2002:a17:902:6b82:: with SMTP id p2-v6mr44057499plk.50.1540197284475; Mon, 22 Oct 2018 01:34:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540197284; cv=none; d=google.com; s=arc-20160816; b=SgW00M1TrdTLTbReplE8i7Wo3oBpbQa14SlSPA9rssJP2rGc3HUg3+vE+qN8T5uh8q HW/6o0IAf7ARvreIhejjQokgkm2dETId/viodCjh4oXFCgbJyFhORMBvE3FOk6RzToc+ wYVIHlIS1tnZAUrnsxdy5DmWIm1e8S25IWMvoARtQexVn2Q7RFtKQZdbQBYET8b0USO1 4/9obcJTUNbswIUyB2UgF79bGq/TefJE5jSWYVADFlGYiG/HbrY87AubNjMul35GkCTu OPQY5+bpaL+uYAMaIQAhzDxmh2iDz4aXTEFC8Eietjw27a0T1dXwkz5FI/xUM32MxC0g 6u1g== 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=mMUqfblu/VJzCS2RF3qy5hATgZmbUfPMl39M0spowYs=; b=xq63MCRxmR8xeu+92z4EYYOJmAqnYm7gK2wWL9wLBDxvKq0DYKLqBtF+qzFnoIkzQi WOlPF+YcyCfcXWgEPqhUwzCJtdbgeL/e3VPqFFf7inPBUx9mjNt2Dz9NBQ1bSzOesbOg a1bqYMWNA0Q8axUduFx7jmeXGBIu6Ozk6ncMIpjWBNHkEhvg3irrKit53LTjb5URpA8g 7nGyVAg3SaVSr4Gt+DDHTFJrUiNUnetUNTTxhLx5a0l+9x4V8P36DV/njsX2QnZ+jcVz G6Vx0g3RAkLyl7gBDVZjNaIWLtlqKcqkIGpXeYa3D7gquuRMx+1p46sy+6kYGS24IdSN TD1A== 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 a18-v6si9370133pgh.408.2018.10.22.01.34.29; Mon, 22 Oct 2018 01:34:44 -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 S1727797AbeJVQW5 (ORCPT + 99 others); Mon, 22 Oct 2018 12:22:57 -0400 Received: from mga01.intel.com ([192.55.52.88]:24161 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727523AbeJVQW5 (ORCPT ); Mon, 22 Oct 2018 12:22:57 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Oct 2018 01:05:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,411,1534834800"; d="scan'208";a="84522669" Received: from lahna.fi.intel.com (HELO lahna) ([10.237.72.157]) by orsmga006.jf.intel.com with SMTP; 22 Oct 2018 01:05:27 -0700 Received: by lahna (sSMTP sendmail emulation); Mon, 22 Oct 2018 11:05:26 +0300 Date: Mon, 22 Oct 2018 11:05:26 +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: <20181022080526.GL2302@lahna.fi.intel.com> References: <1540060698-17331-1-git-send-email-wang6495@umn.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1540060698-17331-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 Hi, On Sat, Oct 20, 2018 at 01:38:18PM -0500, Wenwen Wang wrote: > In icm_copy(), the packet id 'hdr->packet_id' is firstly compared against > 'req->npackets'. If it is less than 'req->npackets', the received packet. > i.e., 'pkg->buffer', is then copied to 'req->response + offset' through > memcpy(). It is worth noting that 'offset' is also calculated based on > 'hdr->packet_id'. The problem here is that both the check and the > calculation are conducted directly on 'pkg->buffer', which is actually a > DMA memory region. Given that a device can also access the DMA region at > any time, it is possible that a malicious device controlled by an attacker > can modify the packet id after the check. By doing so, the attacker can > supply comprised value into 'offset' and thus cause unexpected errors. > > This patch firstly copies the header of the packet and performs the check > and the calculation on the copied version to fix the above issue. This > patch also rewrites the header in 'req->response + offset' using the > copied header to avoid a potential inconsistency issue. Same comment here than with the previous one.