From patchwork Tue Jun 26 00:58:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alex Elder X-Patchwork-Id: 139901 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp4616545lji; Mon, 25 Jun 2018 18:00:22 -0700 (PDT) X-Google-Smtp-Source: ADUXVKLPaiaAlyLXze6Q4CPBYFVlKUOhh10M2tgHks4ojW7WfQMm8NQeW0KRHkyOfLFVK9zZCm6J X-Received: by 2002:a63:4346:: with SMTP id q67-v6mr12419718pga.328.1529974822017; Mon, 25 Jun 2018 18:00:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529974822; cv=none; d=google.com; s=arc-20160816; b=zsRBjcoTN+NzXVei3rh5FXeo7TL2uH1OM58sPMK0M6Kw5J8TvUuPkXz2WSDX0gVM5h uOpbX1X3eeV3uFqoHAofDXAUWt7NVBYp+aWB0OYBzqC2w1Bhytmn5Rw0TUxhnoBc3NOg bD1ZAwQi3ub4/122WUp6cROWDw4+1QfpSWzoJnjxXaIQI15VL6ygRBZuI6lJeaAVYL2X 9p4Z6n/WBz9FT26JfhCUtZkgg0CLrZjlvsHAIYDw7fZgJ+qLK8sLYq31dXC5/Ac5ciD8 wP23YB5SDPYlv6GKIaKoJ4+6Bj6g64jVL1yvYQl8FGbLRVd/TByR05ij5IowGhsa5CQb eqRg== 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=qQfRj7uf192FbUapBEgSRn41KtxQpeTGXwTk0wzHNL0=; b=GitizRSbdFbcT2k3efpic5RFrVz/SWKHXVRDm/py9ERwos4OXeHk9dGyKVQ4mmNOid QbVi8g47ePOd9I2JQ+6fbbr0TEQ5sAihBR+MrE8QjisGglErGXbVbgyPD+F0V6enJ5Gk 2CoA9QRqTzNAWxpb0ADaTrT4XXrqsmVqk+IfkC0AusayEDhNrutZnn+IuvUhVnGEsht1 bqMQ24LWl4PwEi/a7gNE9DfM8lNtxZZ9r2ERmYPGFjEGPpEEqGX2OQix/RFAJ1Te/Tv/ Vt1gbKpqe+W/OLzmMekM83uKjjkYNp8H8fRdlaUY1nt5c98yifZ+Q6bL760hS/HapiTB NtMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MKfcOPco; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (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 w11-v6si270160pge.422.2018.06.25.18.00.21; Mon, 25 Jun 2018 18:00:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=MKfcOPco; spf=pass (google.com: best guess record for domain of linux-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934869AbeFZBAU (ORCPT + 13 others); Mon, 25 Jun 2018 21:00:20 -0400 Received: from mail-it0-f67.google.com ([209.85.214.67]:33775 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755807AbeFZA7J (ORCPT ); Mon, 25 Jun 2018 20:59:09 -0400 Received: by mail-it0-f67.google.com with SMTP id k17-v6so13828757ita.0 for ; Mon, 25 Jun 2018 17:59:09 -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=kb0UYNwbePyrqiNt7GbnbXqyF1CVqdK0k2VzOr4z4tc=; b=MKfcOPcou+rP5ebOwGl3JSLih/nKY+mYyj6eXIhMPpoWYA1hqZeqlUj8aDr4yv6mVM i/ZLQDqRErALjCY/Ghl1D6xSW1Tpt1KJushEyEfhE+qsQDmAHskbyblcnDm6+iHxojLF qGpY+KTyxYKbDJoivQasLH0TWp67Mrw8p8HfU= 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=kb0UYNwbePyrqiNt7GbnbXqyF1CVqdK0k2VzOr4z4tc=; b=dNhNGu8icD5mPo/Mo3d8Bqvf3bgBHV4hQ73rtPA44GqJDWmLtf5RBg1leGEHTYMXT8 BlMcrj8Xi9/1gs1NNvT/BB9JyF1P9MiMOqZqZuC+sytFC1Kx/IcWuTLMco0IDNl7CMpr n1klJRsTqYF4oLN9DJRsmB13duqJTv6VW3skACqvCH3HIlA5caS/2JvL7DF1Kdp5uu94 sXKawg5LeoNhiTYKLhKGtSYg8UtyN/XBO8LbcgcTk5ASd6cegyIWMeLPHVAMDn4beTmi SXytwjX0zNTNBR1REYsF77A+qsCQEK09rgzk7+MKj7gWsyhrhUFK20SjUo8MIgg7ElPk 3KMw== X-Gm-Message-State: APt69E1Q3/51cI6yvemyyDhMlV/SB+Bb7pucPnOGBucNJxQ26rXRXa3X xwiVo131XmK6dlQnFGaLI6FMAw== X-Received: by 2002:a24:a0c2:: with SMTP id o185-v6mr2761337ite.34.1529974748959; Mon, 25 Jun 2018 17:59:08 -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.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 17:59:08 -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 08/12] soc: qcom: smem: verify partition header size Date: Mon, 25 Jun 2018 19:58:52 -0500 Message-Id: <20180626005856.14174-9-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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Add verification in qcom_smem_partition_header() that the size in a partition's header structure matches the size in its partition table entry. Signed-off-by: Alex Elder --- drivers/soc/qcom/smem.c | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) -- 2.17.1 -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/soc/qcom/smem.c b/drivers/soc/qcom/smem.c index 516a17d340af..95d218d3a595 100644 --- a/drivers/soc/qcom/smem.c +++ b/drivers/soc/qcom/smem.c @@ -737,6 +737,7 @@ qcom_smem_partition_header(struct qcom_smem *smem, struct smem_ptable_entry *entry) { struct smem_partition_header *header; + u32 size; header = smem->regions[0].virt_base + le32_to_cpu(entry->offset); @@ -747,6 +748,13 @@ qcom_smem_partition_header(struct qcom_smem *smem, return NULL; } + size = le32_to_cpu(header->size); + if (size != le32_to_cpu(entry->size)) { + dev_err(smem->dev, "bad partition size (%u != %u)\n", + size, le32_to_cpu(entry->size)); + return NULL; + } + return header; } @@ -795,11 +803,6 @@ static int qcom_smem_set_global_partition(struct qcom_smem *smem) return -EINVAL; } - if (le32_to_cpu(header->size) != le32_to_cpu(entry->size)) { - dev_err(smem->dev, "Global partition has invalid size\n"); - return -EINVAL; - } - size = le32_to_cpu(header->offset_free_uncached); if (size > le32_to_cpu(header->size)) { dev_err(smem->dev, @@ -870,12 +873,6 @@ static int qcom_smem_enumerate_partitions(struct qcom_smem *smem, return -EINVAL; } - if (le32_to_cpu(header->size) != le32_to_cpu(entry->size)) { - dev_err(smem->dev, - "Partition %d has invalid size\n", i); - 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);