From patchwork Tue Dec 12 21:17:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 13489994 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="L4UAFUOZ" Received: from mail-il1-x12d.google.com (mail-il1-x12d.google.com [IPv6:2607:f8b0:4864:20::12d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81ED6D0 for ; Tue, 12 Dec 2023 13:17:44 -0800 (PST) Received: by mail-il1-x12d.google.com with SMTP id e9e14a558f8ab-35f71436397so786915ab.3 for ; Tue, 12 Dec 2023 13:17:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1702415864; x=1703020664; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+Zc6KTpAZSdY8QpoD6ndRxHT3SVEvXG+4LeuNbqJOvg=; b=L4UAFUOZAH3mEUJ0dYkraext6N+7dmrPBKQ07Zrkvg0EipGpro+00z8Kf/u6eTav0e ce0D3+DrURn7ueMVVDjugihrDkYrnlD+QKI9UKTbV2XHjM6LOsa7wtRs4TNUKXRf/Ei+ Ofe/ZfWwt4z57P1hMbbpm/rviheqp6NahsHM4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702415864; x=1703020664; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+Zc6KTpAZSdY8QpoD6ndRxHT3SVEvXG+4LeuNbqJOvg=; b=P2W6AjHvWuljACXi3S6aUAcUPwTcoq9h1+5UhJEcMoulxHX0OJTVQnRa1KMRW8v5K8 wxX0iiPfw9BzPb5EyzNI6VWsHFnOEbkJszSPFYV6BqJb0s5I6OeOl5mSYDsTLmvxPMXA 5a5Zx6o/pt55lHvjcSKDT5G+HlWfMZ9PE8LG+Cyd3vmzWWj9zH8h12kMY953ZBAilH+F AZiEpIUhF2bjLsAwjXlMpZsj+BWHFeo+GlDuHqZ/zDU5LtDLyVVfke2RfU69jwdbSNge LXJPDWg6/YtSSix8s1p7pSJ4qoqTyKai9nIATg8jnWBsQtUXMIn66LDjeD/0tI40ql8k PuSA== X-Gm-Message-State: AOJu0Yxq/JL+avPCex8h38z/IBBp1HAU3uhWNi+r1yiLC6lOs6OKxu/P buQa5wIcwBG5vmceQDqskXYX/A== X-Google-Smtp-Source: AGHT+IEvDlyQAlbj5kZpcUy0l69R3KnPJJrpfmKzdIY3kCQw6u1d63ztJ2FRYEW2wthGdpMi+t5zWQ== X-Received: by 2002:a05:6e02:1526:b0:35d:59a2:2bb with SMTP id i6-20020a056e02152600b0035d59a202bbmr10427390ilu.91.1702415863911; Tue, 12 Dec 2023 13:17:43 -0800 (PST) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id i4-20020a63cd04000000b005c1ce3c960bsm8681954pgg.50.2023.12.12.13.17.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 13:17:41 -0800 (PST) From: Kees Cook To: Greg Kroah-Hartman Cc: Kees Cook , Tejun Heo , Azeem Shaikh , Zefan Li , Johannes Weiner , Waiman Long , Christophe JAILLET , linux-kernel@vger.kernel.org, cgroups@vger.kernel.org, bpf@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 0/3] kernfs: Convert from strlcpy() to strscpy() Date: Tue, 12 Dec 2023 13:17:37 -0800 Message-Id: <20231212211606.make.155-kees@kernel.org> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-hardening@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1166; i=keescook@chromium.org; h=from:subject:message-id; bh=25MytgNAUZhUM008DbLRMGuucWR15FZ+JfVwwxo9GpI=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBleM3zNEJ6ozMonZeoBQXI8on6XfsVYmsQsgluk o1wQ+Ga48OJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZXjN8wAKCRCJcvTf3G3A JsNPEACp/RHtIqnnV4mPRZIPFgXSZFVF1HvucA+ryrSi+/fpmEwvxufPyzuDwgNvNgXbvTi2AHk SyV/uJMDv/6gbhfFVhyvE60Wb0MqH5vRCJJkLHJjqd5QmFaLOZwMgbdsX0BkMhwE3sgnXH0+x/0 rBmVvY+oMp2+nxQqmUeUCHg9v7ohxjEDc7cJUXQw1ohErQHEFgL/I3+etO2/t/XqLDC4b7/iZAW uCV5mIOpBOml+3+QYCaRLL5sIvpTOB8uzkgoELY+dOPfkH9qz0qTf6rW3lq/Hl8O756SsZdAf9s piPFzMgt6R6FoK+gsbWiO9pnRYVYVhXp6ZWdpx3zI4ftuMvbuqrfrrqRhAwt5igfahudw4qarQg npD/uktNC5EBbJc1DBbpHxukXKawE2ANI7oarahhLNx5r5hhSeW24mhApPa/Y4wz/Oo4to/4SqR C9JNMxmVvt3cIVjg1bq+4Z+qCQVzVEa5pJsYt1OvmtJXUonqsX8/8D2GSOFwReXk64SVsPoLIEl 8V5SbrwZWj9Yswt1XA+josJR+CoAiZYQPNx2CbO5yc3xQNJNkg1bnVzy81o0+xQVtI/ZFtTit3n Ra2HxpF7JkjcUUDSwLJMq72OZMpGQ/NaMYcgjfrL+eD8X/C2kAShjRuuqk+UCSbcgiIA/+7ZknX KxURH9O 1QW+s3Sw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Hi, One of the last users of strlcpy() is kernfs, which has some complex calling hierarchies that needed to be carefully examined. This series refactors the strlcpy() calls into strscpy() calls, and bubbles up all changes in return value checking for callers. Future work in kernfs and sysfs will see the replacement of open-coded string handling with the seq_buf API, but we need to do one thing at a time. Thanks! -kees v3: don't need to account for scnprintf() returning negative (christophe.jaillet) v2: https://lore.kernel.org/all/20231130200937.it.424-kees@kernel.org/ v1: https://lore.kernel.org/linux-hardening/20231116191718.work.246-kees@kernel.org/ Kees Cook (3): kernfs: Convert kernfs_walk_ns() from strlcpy() to strscpy() kernfs: Convert kernfs_name_locked() from strlcpy() to strscpy() kernfs: Convert kernfs_path_from_node_locked() from strlcpy() to strscpy() fs/kernfs/dir.c | 50 +++++++++++++++++++-------------------- kernel/cgroup/cgroup-v1.c | 2 +- kernel/cgroup/cgroup.c | 4 ++-- kernel/cgroup/cpuset.c | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-)