From patchwork Wed Aug 29 07:57:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Niklas Cassel X-Patchwork-Id: 145402 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp380096ljw; Wed, 29 Aug 2018 00:58:10 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYN7sQCardG53hiFSRRaiJ+2HVi/9ZvHxVvt0bQTXvxV/Pc1T8+WnHUKBbij6E36iBCbcXf X-Received: by 2002:a63:a309:: with SMTP id s9-v6mr4558534pge.90.1535529490344; Wed, 29 Aug 2018 00:58:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535529490; cv=none; d=google.com; s=arc-20160816; b=Ap4y2tCBAxRLwTxiaT3jKJxubNRkHSHdRzy9E8ZTGuJI8Z2FIkQkTm6o1/VXcCrmq2 qVs/qVnKjxAeyXVS3R0I0XF8P/7YRIIPvfIXo5Hs71E3/5N73LOJ5aJ7vZmfhImHLLnf otNc5DfTBxGK4ynsUgkNpd8PPvLcDfSoxmA0GGVOOn/QCzwJ+pRiMFEQdfTY2r7KEatd ZtFoM/laoaG1Bp/K72+cQaJHXPnn2IVLa9hzlHFC1zLELRux0h6De8/cG6NMbAr2/4s7 XtaGS83n8N78QO+Y3u/oFhM0oWKoNwSti6ixGIMtEJACJ+QSYAdjlBY5Sz7ZgizJW+hE RP7g== 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=tQmlwCwJSVoYP6D2xnc17B1/hP5mz9BZ77ThrTB3V8NDln2cXQTY9VwyndXuHtb2WX 9nnAd9NpPhLEoJHjWhuquBTef1oBfDUswUnYrZniTl9vMCmMV2aL0Vxu/lpz5NJ+nwXA rk0m6192BLmJZBScL9UtjqSFwgpW3CF6aBXU+7cVDJFOc6AY2oyEXIUMED9TCyAoAVEd JbHB3dCZD4iHDQ78D8/mj51dIBp4JUwcjbtOc5OtDzPH3qalgqqP56gtzKfv53ppSpnG 1DuC86cy2HTCeGl6vUeYs5E0+t26pwJYnaiN2K+k2LNsmXdj/KhsvZtqiXArJ7Wg2STC +i2A== 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-arm-msm-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-arm-msm-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 v1-v6si3333304plb.387.2018.08.29.00.58.10; Wed, 29 Aug 2018 00:58:10 -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=pass header.i=@linaro.org header.s=google header.b=WPxuH4FE; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728024AbeH2Lxp (ORCPT + 13 others); Wed, 29 Aug 2018 07:53:45 -0400 Received: from mail-lf1-f67.google.com ([209.85.167.67]:45446 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727668AbeH2Lxo (ORCPT ); Wed, 29 Aug 2018 07:53:44 -0400 Received: by mail-lf1-f67.google.com with SMTP id r4-v6so3502358lff.12 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=GqzuRc7h7Kdf3lLujdnCJ4WsHXGFTQYI0mMBi+IqA63E1eIX48gljyMYN+XeQgcnbB bKJvQuV5ekTxoNKDyagaEEkNSftAPeDUwnNquFkKibHEsZKlfVRenNIGY+rW4ZxMdDva soW5ZB4sRzh4i/I3T2qYnIj13qC0T1npgC3rplgo9m/cGpDnIk2v/NIT0saUQT5PndTC vIRqBQiS2L9uR7VYvs7c2nUreAsOlxFv1nWl654XZDBr4g4qdzB+NSF12Y+SQsbmPUt1 /CYuf1RqYXlSdEunTqVy/4vnEDMitG8mm7pnhXe0RIP/Qmd2UbN3xm3FSnp5+8N4hq+2 eDkg== X-Gm-Message-State: APzg51Bm4Ac0meTEX9N+M7Mhh5NMNDBtI0HXTgk+gNbBS8GAWYA1xvca ZJWCWXR/oDekxHWEp7KDsCM8qw== 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-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@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(-) -- 2.17.1 Reviewed-by: Bjorn Andersson 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);