Received: by 2002:a05:7412:31a9:b0:e2:908c:2ebd with SMTP id et41csp4925246rdb; Fri, 15 Sep 2023 17:34:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEpzXAyRLStu+/EHMnRsKsdmzylBCTxD0StSVb1q2i53uZxKU3/iXea4qyZjf2LkGU1p8UG X-Received: by 2002:a05:6a00:b83:b0:68f:b537:afb4 with SMTP id g3-20020a056a000b8300b0068fb537afb4mr4200883pfj.13.1694824481593; Fri, 15 Sep 2023 17:34:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694824481; cv=none; d=google.com; s=arc-20160816; b=F/H3FftHz/2d3ynkMjQ+oStSzdYJNj/x4XPeKkb5oIHrQrW8HCJKdLfQPNO5xN12Sw UKbLLxE8vg+Yyc/j6dBkdzW1TKAg4tDGtB+9YEYZ+JrLFnQSnBJDvsBUQiWlv7MWE1ET arrtTjP2kHpitLdDs/56ix+K6WzhMcUTcvlPzaaHTeWDZcMya+dTT2DvQdjfnfQ+ARu2 ES4sOfXlvsBkOm7TqvAVRJCgrhZwh6VXmpVHj0jdLr33kuIbjlLUVWfZFq6ND0WgYn/6 /prfjwmsQuDJMcEmb01dKhoEkp5wQjUdyN5mEg0+y4JiBBJi5UWtV9oHYbrFa4zIO4vx 0VUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id:dkim-signature; bh=FyfUX0X2fmtB6PX68eelYyAoJB8jxcCYoU3jaj8MsYM=; fh=13Zo5wKTStNhA+Ahwl30NE3zX3HJXaMkIhiN867sbmc=; b=VBXGTbZ3xjSx7xp+NLAtiz6K0M6YwZmhA5b4B6G2J4eOP2Js+q1EBA+OVPlyhIwAut KQFrwlWynZWHIB3vsYIPJd75YaHoccDQovVOOIC6X1c0yhlmLq8+DO19xBbGhMMZLnsy /QHgp1dn4123gk8w19flfLcWX9YPTzQl5xQzg8eTOvSz+hF5yT4USd6BJq5f0AwqXGyQ xWHKSprDdldyVmma8VE2iAM4eXvncdz6YqbHP65rcB9WqiPDTf7XaG2M2gBvr7XEIJ0f WZn+4uONVS5Xlfbw2cj6Pmv496SSbXRXAWA59tNRaaZaigJSNhlmYkreQVLEPCVGzKSh Je8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ydn4D9Jf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id z11-20020a6552cb000000b0056a670ebd6fsi3916118pgp.669.2023.09.15.17.34.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 15 Sep 2023 17:34:41 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel-dk.20230601.gappssmtp.com header.s=20230601 header.b=ydn4D9Jf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 1A79F8042C25; Fri, 15 Sep 2023 06:36:50 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235386AbjIONgu (ORCPT + 99 others); Fri, 15 Sep 2023 09:36:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54240 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235370AbjIONgt (ORCPT ); Fri, 15 Sep 2023 09:36:49 -0400 Received: from mail-io1-xd2b.google.com (mail-io1-xd2b.google.com [IPv6:2607:f8b0:4864:20::d2b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41DF62130 for ; Fri, 15 Sep 2023 06:36:43 -0700 (PDT) Received: by mail-io1-xd2b.google.com with SMTP id ca18e2360f4ac-77dcff76e35so32128839f.1 for ; Fri, 15 Sep 2023 06:36:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1694785002; x=1695389802; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=FyfUX0X2fmtB6PX68eelYyAoJB8jxcCYoU3jaj8MsYM=; b=ydn4D9Jfxv5BuKoSlCNrEbvb0wmF/UhEs+33XosPhhKT/yK+jMCISrZt2wgU4HM87v 7KCXIviagDEc8M7npSAwopV0CkjU8APIaZPrZxk+TLvqRSEezoC3ZIpQCjSIBaQxANVK biaVcG0RgFfe94C6GxLy9OSgNAXZHmFD38xMHM4ee4yX7mvOaZG/ucotanKldb1ciNIA pwD8BOE0GACYkaxnmil2tFmNtlj1vwN+8aw9OqRqby4m/JpHwA6riYYpJZ7MnvSJCba8 bHCFt6A5CDU3LboM1AyBTUxoRG36YW/tzua93QCiPMyEKHsndpENAp9VlejjaE2tqKn+ rkYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694785002; x=1695389802; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=FyfUX0X2fmtB6PX68eelYyAoJB8jxcCYoU3jaj8MsYM=; b=YZlnofUqd7BZFAZC1PXh5reAJc183pIL2hBeOBRy1ggCtzgBFO8gvCXJ6rCVBFoqyN I9RtylNW9QYYaA7eXU51mBHH3upwMCX8s7kLcT0i6cI2kj5PjNNLk1XD8VRYOFfQ2Aei NjIC+wVk14Sf+uLVlle5CNSEedpvws+/+pN/OabIgfBM6SjP3EpAIgBid6i0CNOPuBHF LCqQDKu/btmEofpaKzU1JeQrdLrdDn2DRfJ2F0VW08oDndZuhPBweyEv6uBQWWSeEOUl rn5d1j4umr6ZpKY8kTW6larzfC9fi4n71Wi0nwaDzyjO8HWtDf8YdshKOKiuRLNfW46H UlAg== X-Gm-Message-State: AOJu0YwkpVQdEe8VZ6cKJEnkqCN60ZnnLX4IdXWluILUHE/Hj4FhNapi //JL5bPP6J25qcN/DvFyH5RgWA== X-Received: by 2002:a05:6602:17c9:b0:792:6dd8:a65f with SMTP id z9-20020a05660217c900b007926dd8a65fmr1530583iox.0.1694785002301; Fri, 15 Sep 2023 06:36:42 -0700 (PDT) Received: from [192.168.1.94] ([96.43.243.2]) by smtp.gmail.com with ESMTPSA id b12-20020a02c98c000000b0042b6940b793sm1024607jap.17.2023.09.15.06.36.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 15 Sep 2023 06:36:41 -0700 (PDT) Message-ID: <6338fbac-0177-43eb-be4f-7c586956953f@kernel.dk> Date: Fri, 15 Sep 2023 07:36:40 -0600 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] aoe: refactor deprecated strncpy Content-Language: en-US To: Kees Cook , Justin Stitt Cc: Justin Sanders , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Xu Panda , Yang Yang References: <20230911-strncpy-drivers-block-aoe-aoenet-c-v1-1-9643d6137ff9@google.com> <202309142019.23A7D80A@keescook> From: Jens Axboe In-Reply-To: <202309142019.23A7D80A@keescook> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, 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 morse.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 (morse.vger.email [0.0.0.0]); Fri, 15 Sep 2023 06:36:50 -0700 (PDT) On 9/14/23 9:21 PM, Kees Cook wrote: > On Mon, Sep 11, 2023 at 09:09:07PM +0000, Justin Stitt wrote: >> `strncpy` is deprecated for use on NUL-terminated destination strings [1]. >> >> `aoe_iflist` is expected to be NUL-terminated which is evident by its >> use with string apis later on like `strspn`: >> | p = aoe_iflist + strspn(aoe_iflist, WHITESPACE); >> >> It also seems `aoe_iflist` does not need to be NUL-padded which means >> `strscpy` [2] is a suitable replacement due to the fact that it >> guarantees NUL-termination on the destination buffer while not >> unnecessarily NUL-padding. >> >> 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 >> Cc: Kees Cook >> Cc: Xu Panda >> Cc: Yang Yang >> Signed-off-by: Justin Stitt > > Agreed, truncation is the current behavior, and padding isn't needed. > (Or more precisely, it's already zeroed and this function is called > once.) > > Reviewed-by: Kees Cook Change looks fine to me too, but for the love of $deity, please use a proper subject line for these kinds of patches. It's not refactoring anything. -- Jens Axboe