Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp95444img; Thu, 21 Mar 2019 15:01:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqxkM5tFp7jIuUoIpq5kyncMzNg20W4RWag7TFxEGrfJZKtZOtAe7oxvahtd6eiL/a574LFh X-Received: by 2002:a17:902:a5c3:: with SMTP id t3mr5941676plq.293.1553205684913; Thu, 21 Mar 2019 15:01:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553205684; cv=none; d=google.com; s=arc-20160816; b=CT7ujkKGyHeyBz5rfZihkirYXzGZqi7/qHDwN4CEAQLEJF17dKkJIM9wYwr+D6/cSK 0nQDfeXCpyFA3MaU/2U14OVsH+h0R6FfA3f9eUfcrYNHOn1fXUKXehSjhuCjr0pyOt6m ft8Ix5mz/DoeCs6OGZnIRnRZM4h1NlHkHM2KzrYdzDAtNfXpUxqzhtEs8W3JJ9zC5VbY AasopZf+zxphmGxJ9QrAtU0Di3QZh14CPuFIIHQAkFfHJgvmutM04gEXV/ghAxQ7/Swp Vd7+kHjCoNlgmdKfh99R6dnq8xguPNZeT2ZSodV4eU2bgDCVUl62MG5CQO4tUh1qjjiY hqmQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ui3mqqXK6C3UIidvHM9+bPWelhe5/DLbuSXEKBxI870=; b=heNwUjoBfEwGVXefgq+IShK8XRJ+fy2tKMYW+hp/r9bioAufb4dWZMfAFs0m/bfLVW VuOKoCnLm1MdC4pOyOsE/43whdp3gsBlrKXvZcDoxUqxG50IEr5XBX7Fsq/dJ5AtO04C SYYNJ6hAOMkAxPUO3PceJiab9IZl33ZFGfDMeH2AiV9m17ZvZCCEpVEYcsZshl7SafZq IHkP8eTvStJDKsM0xENSZxi2HJk7cqZRUpNzf7CdqJWMvIQ4BonWMxZGpPxNYYvIGGRZ bY5TS4+RbfblZnwXzkFdUui2ynqEEnEGmMJCeCIiBsKJpLZugs8KgBKV1i7cMLUrS5k4 FbXQ== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i196si3935935pgd.113.2019.03.21.15.01.10; Thu, 21 Mar 2019 15:01:24 -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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727379AbfCUWAb (ORCPT + 99 others); Thu, 21 Mar 2019 18:00:31 -0400 Received: from mga06.intel.com ([134.134.136.31]:53201 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727247AbfCUWA1 (ORCPT ); Thu, 21 Mar 2019 18:00:27 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 21 Mar 2019 15:00:23 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,254,1549958400"; d="scan'208";a="127513569" Received: from tassilo.jf.intel.com (HELO tassilo.localdomain) ([10.7.201.137]) by orsmga008.jf.intel.com with ESMTP; 21 Mar 2019 15:00:23 -0700 Received: by tassilo.localdomain (Postfix, from userid 1000) id 50E0F30214C; Thu, 21 Mar 2019 15:00:23 -0700 (PDT) From: Andi Kleen To: x86@kernel.org Cc: akpm@linux-foundation.org, linux-kernel@vger.kernel.org, Andi Kleen , hugues.fruchet@st.com, mchehab@s-opensource.com Subject: [PATCH 10/17] delta: Fix buffer overrun in delta_ipc_open Date: Thu, 21 Mar 2019 15:00:02 -0700 Message-Id: <20190321220009.29334-11-andi@firstfloor.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321220009.29334-1-andi@firstfloor.org> References: <20190321220009.29334-1-andi@firstfloor.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andi Kleen delta_ipc_open is always called with a single constant string as name, but it uses a longer memcpy to copy the string to a different structure. The memcpy would read outside the bounds of the string, potentially accessing unmapped memory. Just use strcpy instead after clearing the area. This fixes a build error with LTO, which can detect this. Cc: hugues.fruchet@st.com Cc: mchehab@s-opensource.com Fixes: 91c83f395fbe [media] st-delta: rpmsg ipc support Signed-off-by: Andi Kleen --- drivers/media/platform/sti/delta/delta-ipc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/sti/delta/delta-ipc.c b/drivers/media/platform/sti/delta/delta-ipc.c index a4603d573c34..bd1bbbeedec3 100644 --- a/drivers/media/platform/sti/delta/delta-ipc.c +++ b/drivers/media/platform/sti/delta/delta-ipc.c @@ -175,8 +175,8 @@ int delta_ipc_open(struct delta_ctx *pctx, const char *name, msg.ipc_buf_size = ipc_buf_size; msg.ipc_buf_paddr = ctx->ipc_buf->paddr; - memcpy(msg.name, name, sizeof(msg.name)); - msg.name[sizeof(msg.name) - 1] = 0; + memset(msg.name, 0, sizeof(msg.name)); + strcpy(msg.name, name); msg.param_size = param->size; memcpy(ctx->ipc_buf->vaddr, param->data, msg.param_size); -- 2.20.1