Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp335492imm; Wed, 29 Aug 2018 01:00:17 -0700 (PDT) X-Google-Smtp-Source: ANB0Vdbg5+872FjpDLg39YjZ2MdmczHfGxR5KKKhp26zN7rN+CnF538wXpWPTvZsfuHwhFPG++zQ X-Received: by 2002:a17:902:7488:: with SMTP id h8-v6mr4878907pll.16.1535529617043; Wed, 29 Aug 2018 01:00:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535529617; cv=none; d=google.com; s=arc-20160816; b=aA1S8wL7k09X1Gbn2YaMMb47t2j4z4PCNnvKKra3c29CJctuDn1fC0t/e1V+3scb/t U05hmzcVU0FPcH+gGVSGmFzoSLLjUOkvrmoQeyzMpbgRPomiO4VCMMfzyL1Bd3ff+whQ F01hzVKav+A0odhyNMyanba4ZCz62NuR5QV79ZGfuSs4EhzGR6ogFs4/bxVQkENMiHEm R5qdQj2DLCS0YCVwpXeSG1g5zzyY5kVHydwucjzOWNkmw6tspGYW07d2dKHTvT2KugSL yC2kHFFZnGp9Hln7thtmjRtXJisUDGkMmbz65JSjRMVGeaczIKV7cc0C/50H9wFvBdFF WaCw== 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=WGcGxBYbMR3lYiFeso6+j/q0sgMwNMyzkoeytqhrrrw=; b=ihoTkbnqm47KmotbwRIj91cOmOObyrPoPXQ/oX8sjUtUlWD30nmSUmKAEfW7CQLoDm 6NeOimbtt6lDGOuI9Lh8Xj69DZxmKN49tp8On4lCkOXjX0gii9xs5tDLB+lengBApixV cvLOGr7Vg/+kpZxBVMVltEE4qeBCtdk2R+pQHopxXE97QQCTMOJsY4ySGJNYMmxJxZ29 jgregjOpyQ53JH67o2jSvRFIEfgJ9WnLONdMrTV9q22VHytKnNURG1hGpcqx0gaomEbk fjJ5T4hrjRhPRTQxSahmHICfT+bKOLjMI0OsuH6cL0ItoQ9Ki+zgo7xda2pXZTkkj244 IxWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WPxuH4FE; 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 f34-v6si3269537plf.322.2018.08.29.01.00.02; Wed, 29 Aug 2018 01:00:17 -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=WPxuH4FE; 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 S1728076AbeH2Lxq (ORCPT + 99 others); Wed, 29 Aug 2018 07:53:46 -0400 Received: from mail-lf1-f65.google.com ([209.85.167.65]:43728 "EHLO mail-lf1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728038AbeH2Lxp (ORCPT ); Wed, 29 Aug 2018 07:53:45 -0400 Received: by mail-lf1-f65.google.com with SMTP id h64-v6so3496339lfi.10 for ; Wed, 29 Aug 2018 00:58:06 -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=WGcGxBYbMR3lYiFeso6+j/q0sgMwNMyzkoeytqhrrrw=; b=WPxuH4FEJqGnE517ARbt1uzfFsPp8ytr1oMwjBDUNHNo5fmIpTQAAm9y3sI9brHI6A tdqnUm2Ed0vS+hZ9vrptewg9I8ejvYK6kQd+oAq107kuxp5OJ7qNkfC9fwYNgCNdxNoM OhtlFc4FsSCXYJ5lABPkWmE/YP03pcxk6Y4lE= 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=WGcGxBYbMR3lYiFeso6+j/q0sgMwNMyzkoeytqhrrrw=; b=dZ+Zh1NfWT9uYG7aDCty8TFi7UogdRp0t7slKkx6sy6GPKlUsd8mslCsvii8ZUcHBT uHRxSR6oejyAskeeeqoqykS02lI4AXYj/0gLHFeiItWO+wXr6Ow69coZZELrF+gep9oo hloFKB9lXGkSlratlXwd36mnrUtHZfwrAJ4zXISEu6zg1ygxaoG3eLnD4e374Bgqk75h iPYRbIPqrN4qWXuU9ZMx52dUvXeurr6Rm6/Sv9Dm5fBpH9KL65WpdtGApLsZ9HGjtGhc V3OL0tWFiMhqgwirgFbcg1dLkZ/79ZVv+oQP51TvgUKuLQhz9Wgrh8hmZQeye+vDuHnT USDA== X-Gm-Message-State: APzg51C3+A2kFbu5OhsIan/VMqf6CiO6aYZfF7N4su1pef3zkDTv13yv EzMQFF6aecg/RlDa62ABNLf1XA== X-Received: by 2002:a19:be55:: with SMTP id o82-v6mr3353559lff.58.1535529486221; Wed, 29 Aug 2018 00:58:06 -0700 (PDT) Received: from centauri.ideon.se ([85.235.10.227]) by smtp.gmail.com with ESMTPSA id j9-v6sm592303ljh.40.2018.08.29.00.58.05 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 29 Aug 2018 00:58:05 -0700 (PDT) From: Niklas Cassel To: Andy Gross , David Brown Cc: Niklas Cassel , linux-arm-msm@vger.kernel.org, linux-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v6 8/9] soc: qcom: apr: Avoid string overflow Date: Wed, 29 Aug 2018 09:57:22 +0200 Message-Id: <20180829075724.9095-9-niklas.cassel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180829075724.9095-1-niklas.cassel@linaro.org> References: <20180829075724.9095-1-niklas.cassel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 'adev->name' is used as a NUL-terminated string, but using strncpy() with the length equal to the buffer size may result in lack of the termination: In function 'apr_add_device', inlined from 'of_register_apr_devices' at drivers//soc/qcom/apr.c:264:7, inlined from 'apr_probe' at drivers//soc/qcom/apr.c:290:2: drivers//soc/qcom/apr.c:222:3: warning: 'strncpy' specified bound 32 equals destination size [-Wstringop-truncation] strncpy(adev->name, np->name, APR_NAME_SIZE); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This changes it to use the safer strscpy() instead. Signed-off-by: Niklas Cassel --- drivers/soc/qcom/apr.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c index 57af8a537332..ee9197f5aae9 100644 --- a/drivers/soc/qcom/apr.c +++ b/drivers/soc/qcom/apr.c @@ -219,9 +219,9 @@ static int apr_add_device(struct device *dev, struct device_node *np, adev->domain_id = id->domain_id; adev->version = id->svc_version; if (np) - strncpy(adev->name, np->name, APR_NAME_SIZE); + strscpy(adev->name, np->name, APR_NAME_SIZE); else - strncpy(adev->name, id->name, APR_NAME_SIZE); + strscpy(adev->name, id->name, APR_NAME_SIZE); dev_set_name(&adev->dev, "aprsvc:%s:%x:%x", adev->name, id->domain_id, id->svc_id); -- 2.17.1