From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1A56BC04AA7 for ; Wed, 20 Sep 2023 15:36:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236699AbjITPhC (ORCPT ); Wed, 20 Sep 2023 11:37:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236703AbjITPhA (ORCPT ); Wed, 20 Sep 2023 11:37:00 -0400 Received: from mail-ot1-x335.google.com (mail-ot1-x335.google.com [IPv6:2607:f8b0:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60611DE for ; Wed, 20 Sep 2023 08:36:53 -0700 (PDT) Received: by mail-ot1-x335.google.com with SMTP id 46e09a7af769-6c0bbbbad81so4553600a34.3 for ; Wed, 20 Sep 2023 08:36:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695224212; x=1695829012; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=AEqOVsBfHNygg8CIdhGnCqNhF4RLjlnuHSz1CJHC5ok=; b=gfb0x5RPkwjsO6E5uQGEJ/gGgzoFgjRyRWwj4KbQ3uFBen15i19BWd6Hrpng8HZlTu /9PCwEkCxTCpugQjy6PI6hyIqUskzUJd0rbdnxuqVjGh2f+FEWI6RCfezgFEcrCVcmIv OoY4b/9XSeS+wXIWkwpG/laIX49C69xcsXXWA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695224212; x=1695829012; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AEqOVsBfHNygg8CIdhGnCqNhF4RLjlnuHSz1CJHC5ok=; b=aRMMeLHN9RNjypfAcrwgTbM7DuxkttN0JF3sH41fFjc0cQmqvXLsi23V8+f6KanG6k sQRACN7vZwiOESY5e6GxXcyoeyo9J/rbWSpRcH9ahgGK0d1EZeS2RsMXSsrtp4G5la8e /SheJzk9iNJwqrGpIvw0E9lwM2cXOoZIsG5gegj+cYt3PMw9B4UpERO7bEGdEdRSWJQu RJslZI1eOhx7+anJ9WP1bWLhhgx3KWW+QFHjZfUXavRDQ2jinqmVR8L3qKwajyWeXYO1 oz8QQBQ8g7yAVLzJIQkFPFlHq1fXTOHURmNAkZ7s57d56nnISIa9hYktIpPQrKaLrz0V 5vdg== X-Gm-Message-State: AOJu0YzmNfiEZzbMkf5f7nHOE7NRtxMfcZb89vwbS596+Ne/huyhmvI7 ziIaY8WpJprmJdReFnwY32F/SQ== X-Google-Smtp-Source: AGHT+IGWSCopskarNhSyAkg0IaQsmJYsTyHTBcKn23oo3w5SI0EhhW3Si5DpZmqWvoMoEIJfEqxaPA== X-Received: by 2002:a05:6358:52cb:b0:142:dfc2:a441 with SMTP id z11-20020a05635852cb00b00142dfc2a441mr4203742rwz.8.1695224212579; Wed, 20 Sep 2023 08:36:52 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j24-20020a633c18000000b00565009a97f0sm1133706pga.17.2023.09.20.08.36.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 08:36:52 -0700 (PDT) Date: Wed, 20 Sep 2023 08:36:51 -0700 From: Kees Cook To: Justin Stitt Cc: Justin Sanders , Jens Axboe , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org, Xu Panda , Yang Yang Subject: Re: [PATCH v2] aoe: replace strncpy with strscpy Message-ID: <202309200836.372F9757@keescook> References: <20230919-strncpy-drivers-block-aoe-aoenet-c-v2-1-3d5d158410e9@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230919-strncpy-drivers-block-aoe-aoenet-c-v2-1-3d5d158410e9@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-hardening@vger.kernel.org On Tue, Sep 19, 2023 at 05:27:45AM +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 Looks right. Thanks! Reviewed-by: Kees Cook -- Kees Cook