From patchwork Tue Jun 26 00:58:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139898 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4615985lji; Mon, 25 Jun 2018 17:59:33 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJlGfmLV4yjWYNjhR8EePxZBSvip+jd/zvD4LwkIJFylzLi6mmRoE0EEqHhFnR4LgMTROWI X-Received: by 2002:a62:3cd7:: with SMTP id b84-v6mr7869953pfk.9.1529974772904; Mon, 25 Jun 2018 17:59:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974772; cv=none; d=google.com; s=arc-20160816; b=i1CsGeOVRYV9qWtdVf4dZV2JZlA21ePkn9NcE+UqQPL/CP5A3ZlcOZl9bWMuYtokfZ gKjed/M9jgkR8QtFHD3iDdPbzoH/s4fraSEg8P97Tg0B8/hB7lgWxgPCkmMSVL4dFEvp DFL2+IJ1U1n3bJTzjQVx381vSLNNn/3Rogf8EeZu5tK5aABeO78q8uJWTJKT7oh/j2Jk Y+dZAYllatdvyZGFCkB1365DHEjD/4AB4dPHsKYJtBYt9xHYbL47dihuTms4NV5UdF/J LtxzqaTexLi4EoKdX9cHy+c3424DX4sUfxBxKGxepn/pa7GvVJ7k4WBdL1LbJxIFwlnE 1PmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=LwlTZa7ltMifdbiSxNbEGr+9P2HZjUvusjhZiYazdLs+AM0L4lc+ujDDSX2fK7wRYi vGMLN5vpH/rjHk++qWjcDZxHQwZKls7y0xCTVbeW7sEKUdVDxaGejlz1ZgxirjM6Tyl3 XX+xZ49eKeJY3qa43AxNJZn9FSsPyc2jZOhYk0puK2eSfsxDQ8ALBrFCUfjkr7zx97ia Q+P3OovbMij0YWm7rxjRyO2kx9JPE6A7WeSsWzzqjCp1NssEuTk6tAeR55erGJ/f5f/c yfJq5CETqya7ggd3aK7OuPW+1j+h13CP+Bz0rA18UOaL22HaGS/2j7ze27KcU4eitjl8 mFGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=g+DmuyN5; 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=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e9-v6si341895pls.325.2018.06.25.17.59.32; Mon, 25 Jun 2018 17:59:32 -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; dkim=pass header.i=@linaro.org header.s=google header.b=g+DmuyN5; 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=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935100AbeFZA7T (ORCPT + 31 others); Mon, 25 Jun 2018 20:59:19 -0400 Received: from mail-it0-f68.google.com ([209.85.214.68]:50812 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S934844AbeFZA7K (ORCPT ); Mon, 25 Jun 2018 20:59:10 -0400 Received: by mail-it0-f68.google.com with SMTP id u4-v6so15219556itg.0 for ; Mon, 25 Jun 2018 17:59:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=g+DmuyN5g7Pa85Aui/dA6zzbZ/kDMw/bfmuSfHi9dLRwzwb8qRasQ1xDceVE01x2a8 oKBCDnj4SEYOEhZP82OA3MdxuAV72Y0v9Zb+kF3EkOuScM7Xql3NxG65AJInRnpsRdq9 OTaFVAzbTWMxTg1AuqjhyxSfQhg8UrO1B1OXs= 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:in-reply-to :references; bh=WXW2CQ4taCc5cvUraPVxkiewob/irwXrM2tspZPurSM=; b=t9jldL0Vn5uIqeiwtmMRO/M+lRHHIMI1kJ5YEtXsj9+WqKCRqQUlMVW+GqmXkG0IuM eKFZ2sPxg+E5dYGCEdue0RNhf32s6a8tx47LbKxEw2D5sklE4PECy9yndQ7GwOg/GKtX FMihMy3yUyfFk3J3afas3Pe1lO2y5ZaEKxFTJc7Qn8QeFQVJMAxzNAOGxUxuNcyVrEET Br7n/eTjiVArzf3i7dDGq7ry06ZSq2Oga0SxB/OXXseIswI2b/6SYPLc091JPxlmWS9p X5lvii87DJXhiykbReibVeajbrkjFzRxu2/jKNbmkaOw+6f/BP4IQ8Uwj9qQmP557JT9 oxiw== X-Gm-Message-State: APt69E16gAiPhuMQ+A8KzRJShM42acOEXpeiF0zjTjTXroEjqI+dvd2t wdpwZutYKw+bEAtqdyOxecDy5Q== X-Received: by 2002:a24:fc83:: with SMTP id b125-v6mr366151ith.13.1529974749884; Mon, 25 Jun 2018 17:59:09 -0700 (PDT) Received: from localhost.localdomain (c-71-195-29-92.hsd1.mn.comcast.net. [71.195.29.92]) by smtp.gmail.com with ESMTPSA id f193-v6sm372556itf.9.2018.06.25.17.59.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:09 -0700 (PDT) From: Alex Elder To: andy.gross@linaro.org Cc: clew@codeaurora.org, aneela@codeaurora.org, david.brown@linaro.org, linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH resend 09/12] soc: qcom: smem: verify partition offset_free_uncached Date: Mon, 25 Jun 2018 19:58:53 -0500 Message-Id: <20180626005856.14174-10-elder@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180626005856.14174-1-elder@linaro.org> References: <20180626005856.14174-1-elder@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add verification in qcom_smem_partition_header() that the offset_free_uncached field in a partition's header structure does not exceed the partition's size. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) -- 2.17.1 diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 95d218d3a595..f5d7af1623a9 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -755,6 +755,12 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + if (le32_to_cpu(header->offset_free_uncached) > size) { + dev_err(smem->dev, "bad partition free uncached (%u > %u)\n", + le32_to_cpu(header->offset_free_uncached), size); + return NULL; + } + return header; } @@ -763,7 +769,7 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) struct smem_partition_header *header; struct smem_ptable_entry *entry; struct smem_ptable *ptable; - u32 host0, host1, size; + u32 host0, host1; bool found = false; int i; @@ -803,13 +809,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - size = le32_to_cpu(header->offset_free_uncached); - if (size > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Global partition has invalid free pointer\n"); - return -EINVAL; - } - smem->global_partition = header; smem->global_cacheline = le32_to_cpu(entry->cacheline); @@ -873,12 +872,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (le32_to_cpu(header->offset_free_uncached) > le32_to_cpu(header->size)) { - dev_err(smem->dev, - "Partition %d has invalid free pointer\n", i); - return -EINVAL; - } - smem->partitions[remote_host] = header; smem->cacheline[remote_host] = le32_to_cpu(entry->cacheline); }