From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ot1-f71.google.com (mail-ot1-f71.google.com [209.85.210.71]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D1D136A350 for ; Mon, 17 Aug 2026 20:33:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.71 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786998791; cv=none; b=snJURgYClEOshHTtrMH7b15/6nG7yQWl4/n+Xa9CE6wMbwMI+mWKn8snb41pceNbaX7uPC4JJvLCc17errkpRik/aK5taPBaq/jkp6KBOhRrJtwIjhrv9EKl8J5kFVnw84ZtrYJer+dMmrIH/TfYCI8EBQA4ihG9iv7OvGNWTV8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786998791; c=relaxed/simple; bh=62mvJf3WvOZtRlyN48SZrZg1DyDipbX+PZ/49rl1Hjo=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=cPEi7HxCw8KwJaGK0De2BX5L9lzmi/pPS7gYLbuRszhPj+SLDffb3DiwfI2H5KogPRJB4nrY1502LbKfJ3szc1KvV8i2kof3e8pldmr1ql3s2OApQyeBky9wZu35MJCg18nSxBL31G449/hXmQeli/cAiHmcXfkVycyrF0IeZdM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=evc9YGzm; arc=none smtp.client-ip=209.85.210.71 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--justinstitt.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="evc9YGzm" Received: by mail-ot1-f71.google.com with SMTP id 46e09a7af769-7eb89852728so2888273a34.3 for ; Mon, 17 Aug 2026 13:33:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1786998789; x=1787603589; darn=vger.kernel.org; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:from:to:cc:subject:date:message-id:reply-to :content-type; bh=lAVl+NhQY8DNi7sjHIPAU1qvka7Rp9cjT1Z4/qhVby4=; b=evc9YGzmiYUpe/ZFzeCe9WqVznc8D0U56PTj5HKKAuNSpf9gXZLBBWPiRH4YglDcjH 1z9zR9GEONZQZMx3AiDWjjBRRhWpgqiL1n5jFfjDuhsIvykwtnhUTCrna1XNHruCefVc JQsIPAVhvOMTis/J2KzUKhko2YL83pGV0rQzBlQ78iZUsPajV2W+CgMrmCXgjRlx7wPR aEkQ2QGwKC4isUiFuZEUz7x6ZqcazWnrlbOSqMvIsatIFXzbHhrnUMdaGMtKBxXJwFi6 A60g7yqGDznxoGIdc7hs3TSQ//q8g3GK+IpkFzVkWyKX+apP5gCC6ot/xrM994sntD39 KQPA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786998789; x=1787603589; h=content-type:cc:to:from:subject:message-id:references:mime-version :in-reply-to:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=lAVl+NhQY8DNi7sjHIPAU1qvka7Rp9cjT1Z4/qhVby4=; b=QEe7YhJdP4qFQYpCQowj3d39or7q+ezm6Lo8eu2aHXrThY4J4u+bQQfQRLJe31LlWb zIWOg+YKKfEoStoFAwa4wf4Em9OuaFspmpuYTFmvmRnqJwpOi8McQ1hYWZMBQzztaEUl gpEU8CcMcs694TMToyl4pdAcLnxRT17+hl5EZCfCz20zBhfC643nkvPJPaRd6I5iH9Dc mqcqdo4T79ukiWVj3zZ0qq+b2GCwvob60DHrmKXugli0ldbJ7Wb/VVr+LGNEvqMxD2kS IfMcamclRkpFmqZJPNQLdEpXn7yNcz6P/CbwKRWAYXZLssSP4jfGTGLaLqv5GbbT+Ttz c/kA== X-Forwarded-Encrypted: i=1; AHgh+RqZvQtTVJvbfxxIywuJ2nLmRkR5Rn25HbtY1/QxIVVXH0KocRqJujreXmmlhlazAayEJ4bvOaOFRk7FPbc=@vger.kernel.org X-Gm-Message-State: AOJu0YyIhVyOH8Ip5pNIZeS+n2ZtGzHQNShwR22dyDcxUss2xDkv5Oyk uJGNpA1LLfLEGKiYRJSrDXhqxb+20WL0vk8mQz37tb8ouBEhOYg44VXlYWkmaRW8zM+7JnSMCMs pVt4sQPFFKbn8+jlsFNAK4DWsMg== X-Received: from ilbda7.prod.google.com ([2002:a05:6e02:3cc7:b0:508:27c6:a6d7]) (user=justinstitt job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6820:178b:b0:6ae:4475:bc48 with SMTP id 006d021491bc7-6b0d6245b8bmr24430765eaf.22.1786998788813; Mon, 17 Aug 2026 13:33:08 -0700 (PDT) Date: Mon, 17 Aug 2026 13:33:08 -0700 In-Reply-To: <27956255dde39f58d73a7b51cb53cbe3d7804f54.1786411026.git.mariianikitash@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <27956255dde39f58d73a7b51cb53cbe3d7804f54.1786411026.git.mariianikitash@google.com> Message-ID: Subject: Re: [PATCH] NFS: nfsroot: replace strlcat() with snprintf() From: Justin Stitt To: Mariia Nikitash Cc: trondmy@kernel.org, anna@kernel.org, keescook@google.com, linux-hardening@vger.kernel.org, linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org, nikitash.mariiaw@gmail.com Content-Type: text/plain; charset="us-ascii" Hi, On Fri, Aug 14, 2026 at 12:28:45AM -0700, Mariia Nikitash wrote: > In preparation for removing the deprecated strlcat() API[1], replace its > uses in root_nfs_cat() with snprintf(). > > Build the separator and source string in a single call using the > remaining space in the destination buffer. snprintf() returns the length > it would have written excluding the terminating NUL, so comparing the > return value against the remaining buffer space preserves the existing > truncation check. > > Link: https://github.com/KSPP/linux/issues/370 [1] > Signed-off-by: Mariia Nikitash Reviewed-by: Justin Stitt > --- > fs/nfs/nfsroot.c | 8 ++++---- > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/fs/nfs/nfsroot.c b/fs/nfs/nfsroot.c > index 432612d22437..e951fe731679 100644 > --- a/fs/nfs/nfsroot.c > +++ b/fs/nfs/nfsroot.c > @@ -173,12 +173,12 @@ static int __init root_nfs_cat(char *dest, const char *src, > const size_t destlen) > { > size_t len = strlen(dest); > + size_t remaining = destlen - len; > + const char *sep = ""; > > if (len && dest[len - 1] != ',') > - if (strlcat(dest, ",", destlen) >= destlen) > - return -1; > - > - if (strlcat(dest, src, destlen) >= destlen) > + sep = ","; > + if (snprintf(dest + len, remaining, "%s%s", sep, src) >= remaining) > return -1; > return 0; > } > -- > 2.55.0.679.g6767b8d81c-goog > > Thanks Justin