Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2581951rdh; Wed, 27 Sep 2023 07:00:27 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJh7bQz2YUKgBKenKq1DMk0v83moI+5RxSs7suGS/WxTKq/TXQ51P8B+K6Od54u5xYNJfe X-Received: by 2002:a17:902:da8a:b0:1b8:6cae:3570 with SMTP id j10-20020a170902da8a00b001b86cae3570mr2354532plx.11.1695823227487; Wed, 27 Sep 2023 07:00:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695823227; cv=none; d=google.com; s=arc-20160816; b=cI+Nti/r21ISWQtClB9iSPh3mnYMzaRQIQsB/iUg3Hj4pIedXVB+LzYIxiLQSBPgi1 rY/ZHwhX5rE5lFDLJI9SsPPr+xWm1b1vITQGdBBR79leWbp30/MMlS2ctyastepeT1/6 RUGF5cmspATzCUEVMPkvbpcr6IdzHxLGgvgB7R/iZy8IIJS/7rPM4/bjpY0GG61EKHO1 auCsDQPj7J5hLBY0f8nJg4eogFANszroUqPorsHGZ59kdrqjy1Ob6yxGdjT62d40NMNG MbyaCMTnFBsyWZQv8g28KW9JcyC4YsxwF780wB4a97kNOnf9HYHFNzuUG8UwfDR4Fcih sIyg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:mail-followup-to:message-id:subject:cc:to:from:date :dkim-signature; bh=ozgRDTC+2UK6mD107LVNtKBM9DQ8506FxPydFp9FLHU=; fh=eS5eoCxE0K3l/TvW4k7f+NnU1BZUYaeTFnpuS6zn1GY=; b=UJdNQIXrVEBGSaCa7yg9hTeprLHQ+I3iFvpGtzq+9LB7xhc4/UmUssu8kgeNwREBR+ Fsyu9EodpQxGg0ZGF1yEtGex7rffMFnM6Nhd8tNaw7CzC79RZkB+EELdP6O0ImRXlEhh 1DBgUIzk54GyMt6cf+LwOY3FfCxBVzaTwrA50ELXk2tsQjz0uWED1OP8uduslmKuk63r e/ED4S+5v3AzUTQwK67qL2RZ4GvLDjYjHXwuk3cjRVKOhFtTi89GEVKA8roi146+VdVR gHQPzTzqyvec0Y6Kq2GKK0z2OpDic6nAmP8SdO6Ty3OLsZAbqWBlEZVNaRmKXi4m6HTC bdlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WP8qZHGL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id l9-20020a170902f68900b001bdc10170casi11375793plg.36.2023.09.27.07.00.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 07:00:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=WP8qZHGL; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 969798080C71; Wed, 27 Sep 2023 03:44:00 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230027AbjI0Knx (ORCPT + 99 others); Wed, 27 Sep 2023 06:43:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229539AbjI0Knv (ORCPT ); Wed, 27 Sep 2023 06:43:51 -0400 Received: from mail-ej1-x629.google.com (mail-ej1-x629.google.com [IPv6:2a00:1450:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849FB139; Wed, 27 Sep 2023 03:43:50 -0700 (PDT) Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso1376384566b.1; Wed, 27 Sep 2023 03:43:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1695811429; x=1696416229; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date:from:to:cc :subject:date:message-id:reply-to; bh=ozgRDTC+2UK6mD107LVNtKBM9DQ8506FxPydFp9FLHU=; b=WP8qZHGLln5e3/FHLTK6pZxxr2azrFmDxBAkmMdndcBcsc36I7iOqZO7E1CLMuJbZ5 MNxlnR9wvrHC3rT0PTVeKnp+nJFF3oLshQEOR5hCq8UFHSge/3jM0MYLdFQy+QOu5Knc OnzTrHTtKuM1sUksq+3H+Y04cX2V6YzNMuM6zc1Bo9zL2gFTC/0WjR4vHOW7ySn4UwRC VhiBoLHtRYw4adbTTqZEzCNpzhbN8O55xHJYWMU6eyrSidFJvWHplxnSZngq1zCq2ZVa II4NYVnIWOkMEWzk1H8KzU2vg2FsBBLdPRgwgcqPY3O8c2FS1Caz27qPLK308MU7ZYNb UQ4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695811429; x=1696416229; h=in-reply-to:content-disposition:mime-version:references :mail-followup-to:message-id:subject:cc:to:from:date :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=ozgRDTC+2UK6mD107LVNtKBM9DQ8506FxPydFp9FLHU=; b=nSV/UJyc6i6gaYLNp2ZGE1eduqU7iiIMvdkIaDHPxBXsWZvCg/lxHX/QbCxgYe5+Yj QrW7NRpOUKAQKku6+Cn2eveECaOvHk+vgfnVAvgmFWbxJcv2IqKSeS3dTTA9HcEz8otn uvsXv1D5RFf1OU7SFme6tKWG4QCygq/dwqYG9ief/FWVDxZlVenujXLRIfx/a7lccJgC s6MyflqkyXqFHZfgv+5F/ooth2Z9OOweHBcBxYtemOX6k4rqi8lHR4epbfRNLaxSIRW8 nuD4wz2uyCtbytq/q+O0Hikf9UNX1EHeww6P6L7e8plrt04XDZdEJq1gImWlpvf/Et5I QCmA== X-Gm-Message-State: AOJu0YxaPuEaGEmMcBPo2Q4ML+hgGUVMpihHrcg8lJmVSiOvV4qpniR5 XLBzs3bd3Z4I0MTY68I5eXMGEl8bVpI= X-Received: by 2002:a17:906:d41:b0:9ae:4843:66ee with SMTP id r1-20020a1709060d4100b009ae484366eemr1400373ejh.36.1695811428590; Wed, 27 Sep 2023 03:43:48 -0700 (PDT) Received: from localhost (81-226-149-122-no518.tbcn.telia.com. [81.226.149.122]) by smtp.gmail.com with ESMTPSA id lw3-20020a170906bcc300b009ade1a4f795sm9013116ejb.168.2023.09.27.03.43.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 03:43:48 -0700 (PDT) Date: Wed, 27 Sep 2023 12:43:46 +0200 From: Patrik Jakobsson To: Justin Stitt Cc: David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: Re: [PATCH v2] drm/gma500: refactor deprecated strncpy Message-ID: Mail-Followup-To: Justin Stitt , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org References: <20230919-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-v2-1-9ebe6983b4cb@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230919-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-v2-1-9ebe6983b4cb@google.com> X-Spam-Status: No, score=-0.6 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 03:44:00 -0700 (PDT) On Tue, Sep 19, 2023 at 04:41:16AM +0000, Justin Stitt wrote: > `strncpy` is deprecated for use on NUL-terminated destination strings [1]. > > We should prefer more robust and less ambiguous string interfaces. > > Since `chan->base.name` is expected to be NUL-terminated, a suitable > replacement is `strscpy` [2] due to the fact that it guarantees > NUL-termination on the destination buffer without also unnecessarily > NUL-padding (since `chan` is kzalloc'd already). > > Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] > Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [2] > Link: https://github.com/KSPP/linux/issues/90 > Cc: linux-hardening@vger.kernel.org > Signed-off-by: Justin Stitt Applied to drm-misc-next. Thanks Patrik > --- > Changes in v2: > - use sizeof() instead of I2C_NAME_SIZE (thanks Kees, Patrik) > - Link to v1: https://lore.kernel.org/r/20230914-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-v1-1-0a53a076ce20@google.com > --- > drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c b/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c > index 06b5b2d70d48..939c53fd09e8 100644 > --- a/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c > +++ b/drivers/gpu/drm/gma500/oaktrail_lvds_i2c.c > @@ -141,7 +141,7 @@ struct gma_i2c_chan *oaktrail_lvds_i2c_init(struct drm_device *dev) > > chan->drm_dev = dev; > chan->reg = dev_priv->lpc_gpio_base; > - strncpy(chan->base.name, "gma500 LPC", I2C_NAME_SIZE - 1); > + strscpy(chan->base.name, "gma500 LPC", sizeof(chan->base.name)); > chan->base.owner = THIS_MODULE; > chan->base.algo_data = &chan->algo; > chan->base.dev.parent = dev->dev; > > --- > base-commit: 3669558bdf354cd352be955ef2764cde6a9bf5ec > change-id: 20230914-drivers-gpu-drm-gma500-oaktrail_lvds_i2c-c-a53c6d8bd62f > > Best regards, > -- > Justin Stitt >