Re: [PATCH v2] ntp: remove accidental integer wrap-around

2024-05-24 Thread Justin Stitt
Thomas, I appreciate you reviewing my patches. On Fri, May 24, 2024 at 5:09 AM Thomas Gleixner wrote: > > On Fri, May 17 2024 at 20:22, Justin Stitt wrote: > > time_maxerror is unconditionally incremented and the result is checked > > against NTP_PHASE_LIMIT, but the in

Re: [PATCH v3] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-17 Thread Justin Stitt
Hi, On Thu, May 16, 2024 at 6:13 PM Matthew Wilcox wrote: > > On Fri, May 17, 2024 at 12:29:06AM +, Justin Stitt wrote: > > When running syzkaller with the newly reintroduced signed integer > > overflow sanitizer we encounter this report: > > why do you keep saying i

[PATCH v2] ntp: remove accidental integer wrap-around

2024-05-17 Thread Justin Stitt
Signed-off-by: Justin Stitt --- Changes in v2: - update commit log (thanks Thomas) - check for sane user input during validation (thanks Thomas) - Link to v1: https://lore.kernel.org/r/20240507-b4-sio-ntp-usec-v1-1-15003fc9c...@google.com --- Historically, the signed integer overflow sanitizer did

[PATCH v2] ntp: safeguard against time_constant overflow case

2024-05-16 Thread Justin Stitt
/352 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - Adjust commit log (thanks Thomas) - massively simplify bounds checking for time_constant - Link to v1: https://lore.kernel.org/r/20240506-b4-sio-ntp-c-v1-1-a01281aa0...@google.com --- Historically, the signed

[PATCH v3] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-16 Thread Justin Stitt
: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/358 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v3: - use check_add_overflow() instead of min() to keep old -EINVAL behavior (thanks Jan) - shorten UBSAN splat

Re: [PATCH] ntp: remove accidental integer wrap-around

2024-05-16 Thread Justin Stitt
On Thu, May 16, 2024 at 4:40 PM Justin Stitt wrote: > Isn't this usually supplied from the user and can be some pretty > random stuff? Are you suggesting we update > timekeeping_validate_timex() to include a check to limit the maxerror > field to (NTP_PHASE_LIMIT-(MAXFREQ / N

Re: [PATCH] ntp: remove accidental integer wrap-around

2024-05-16 Thread Justin Stitt
Hi, On Tue, May 14, 2024 at 3:38 AM Thomas Gleixner wrote: > > On Tue, May 07 2024 at 04:34, Justin Stitt wrote: > > Using syzkaller alongside the newly reintroduced signed integer overflow > > sanitizer spits out this report: > > > > [ 138.

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-16 Thread Justin Stitt
Hi, On Thu, May 16, 2024 at 7:09 AM Peter Zijlstra wrote: > > On Thu, May 16, 2024 at 06:30:32AM -0700, Kees Cook wrote: > > > > I am a broken record. :) This is _not_ about undefined behavior. > > And yet you introduced CONFIG_UBSAN_SIGNED_WRAP... *UB*san, get it? We should think of UBSAN as

Re: [RFC] Mitigating unexpected arithmetic overflow

2024-05-15 Thread Justin Stitt
Hi Peter, On Wed, May 15, 2024 at 12:36 AM Peter Zijlstra wrote: > > On Wed, May 08, 2024 at 04:47:25PM -0700, Linus Torvalds wrote: > > For example, the most common case of overflow we've ever had has very > > much been array indexing. Now, sometimes that has actually been actual > > undefined

Re: [PATCH v2] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-13 Thread Justin Stitt
On Mon, May 13, 2024 at 01:01:57PM -0700, Kees Cook wrote: > On Thu, May 09, 2024 at 11:42:07PM +0000, Justin Stitt wrote: > > fs/read_write.c | 18 +++--- > > fs/remap_range.c | 12 ++-- > > 2 files changed, 17 insertions(+), 13 deletions(-) >

[PATCH v2] fs: remove accidental overflow during wraparound check

2024-05-13 Thread Justin Stitt
(long long); then we can use that sum for the following check. Link: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/356 Cc: linux-hardening@vger.kernel.org Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- Changes in v2: - drop the sum < 0

Re: [PATCH] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-10 Thread Justin Stitt
On Fri, May 10, 2024 at 8:15 AM Jan Kara wrote: > > On Thu 09-05-24 21:34:58, Justin Stitt wrote: > > --- > > fs/read_write.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/read_write.c b/fs/read_write.c > > index d4c0

Re: [PATCH] libfs: fix accidental overflow in offset calculation

2024-05-09 Thread Justin Stitt
Hi, On Fri, May 10, 2024 at 02:04:51AM +0100, Al Viro wrote: > On Fri, May 10, 2024 at 01:49:06AM +0100, Al Viro wrote: > > On Fri, May 10, 2024 at 12:35:51AM +0000, Justin Stitt wrote: > > > @@ -147,7 +147,9 @@ loff_t dcache_dir_lseek(struct file *file, loff_t > &

[PATCH] libfs: fix accidental overflow in offset calculation

2024-05-09 Thread Justin Stitt
/issues/359 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Historically, the signed integer overflow sanitizer did not work in the kernel due to its interaction with `-fwrapv` but this has since been changed [1] in the newest version of Clang. It was re-enabled in the kernel

[PATCH v2] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-09 Thread Justin Stitt
return -EINVAL; /* Ensure the infile range is within the infile. */ --- base-commit: 0106679839f7c69632b3b9833c3268c316c0a9fc change-id: 20240509-b4-sio-read_write-04a17d40620e Best regards, -- Justin Stitt

Re: [PATCH] fs: remove accidental overflow during wraparound check

2024-05-09 Thread Justin Stitt
On Thu, May 9, 2024 at 8:53 AM Jan Kara wrote: > > @@ -319,8 +320,12 @@ int vfs_fallocate(struct file *file, int mode, loff_t > > offset, loff_t len) > > if (!S_ISREG(inode->i_mode) && !S_ISBLK(inode->i_mode)) > > return -ENODEV; > > > > - /* Check for wrap through zero

[PATCH] fs: fix unintentional arithmetic wraparound in offset calculation

2024-05-09 Thread Justin Stitt
... Link: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/358 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Here's the syzkaller reproducer: | # {Threaded:false Repeat:false RepeatTimes:0 Procs:1 Slowdown:1 S

Re: [PATCH net-next v2 2/2] gve: Use ethtool_sprintf/puts() to fill stats strings

2024-05-08 Thread Justin Stitt
Simon Horman This patch looks good and follows similar replacements [1] I've made in the past. Acked-by: Justin Stitt > --- > drivers/net/ethernet/google/gve/gve_ethtool.c | 42 > +++ > 1 file changed, 17 insertions(+), 25 deletions(-) > > diff --git a/dr

[PATCH v2] scsi: sr: fix unintentional arithmetic wraparound

2024-05-08 Thread Justin Stitt
fff. There are some "magic" numbers here but I did not want to change more than what was necessary. Link: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/357 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - cha

[PATCH] scsi: sr: fix unintentional arithmetic wraparound

2024-05-07 Thread Justin Stitt
ps://github.com/KSPP/linux/issues/357 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Here's the syzkaller reproducer: r0 = openat$cdrom(0xff9c, &(0x7f000140), 0x800, 0x0) ioctl$CDROM_SELECT_SPEED(r0, 0x5322, 0x7ee9f7c1) ... which was used against Kees' tr

[PATCH] fs: remove accidental overflow during wraparound check

2024-05-07 Thread Justin Stitt
(long long); then we can use that sum for the following check. Link: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/356 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- I wonder, though, why isn't loff_t an unsigned type? We ha

[PATCH] cdrom: rearrange last_media_change check to avoid unintentional overflow

2024-05-06 Thread Justin Stitt
oject/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/354 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- drivers/cdrom/cdrom.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index a5e07270e0d4..20

[PATCH] ntp: remove accidental integer wrap-around

2024-05-06 Thread Justin Stitt
at against NTP_PHASE_LIMIT to properly limit the max size of time_maxerror without overflowing during the check itself. Link: https://github.com/llvm/llvm-project/pull/82432 [1] Closes: https://github.com/KSPP/linux/issues/354 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- include/lin

Re: [PATCH] printk: cleanup deprecated uses of strncpy/strcpy

2024-05-01 Thread Justin Stitt
On Wed, May 1, 2024 at 2:39 PM Christophe JAILLET wrote: > Hi, > > Nit: The { } around each branch can now also be removed. There was one line before and there's one line now. I'll remove the brackets but I will briefly wait to see if any other concerns come in. Thanks > > CJ >

Re: [PATCH] sctp: annotate struct sctp_assoc_ids with __counted_by()

2024-05-01 Thread Justin Stitt
t_for_each_entry(asoc, &(sp->ep->asocs), asocs) { | ids->gaids_assoc_id[num++] = asoc->assoc_id; | } So this looks good to me. Reviewed-by: Justin Stitt > }; > > /* > -- > 2.25.1 > Thanks Justin

[PATCH] printk: cleanup deprecated uses of strncpy/strcpy

2024-04-29 Thread Justin Stitt
[3] Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- --- include/linux/printk.h | 2 +- kernel/printk/printk.c | 20 +--- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/include/linux/printk.h b/include/linux/printk.h index 955e31860095..b3a29c27abe9 100

[PATCH] PM: hibernate: replace deprecated strncpy with strscpy

2024-04-29 Thread Justin Stitt
ngs [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 --- Note: build-tested only. Found with: $ rg "strncpy\(" --- kernel/power/hiberna

[PATCH v6] checkpatch: add check for snprintf to scnprintf

2024-04-29 Thread Justin Stitt
let's do that." To help prevent new instances of snprintf() from popping up, let's add a check to checkpatch.pl. Suggested-by: Finn Thain Signed-off-by: Justin Stitt --- Changes in v6: - move capture group to only include symbol name (not spaces or paren) - Link to v5: https://lore.kernel.o

Re: [PATCH v2] ubsan: Avoid i386 UBSAN handler crashes with Clang

2024-04-26 Thread Justin Stitt
Ryabinin > Cc: Nathan Chancellor > Cc: Nick Desaulniers > Cc: Bill Wendling > Cc: Justin Stitt > Cc: l...@lists.linux.dev > Cc: kasan-...@googlegroups.com > Cc: linux-hardening@vger.kernel.org > v2: >- use email address in Reported-by >- link to upstream ll

[PATCH v4] net: dsa: lan9303: use ethtool_puts() for lan9303_get_strings()

2024-04-24 Thread Justin Stitt
://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Cc: Kees Cook Suggested-by: Alexander Lobakin Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- Changes in v4

Re: [PATCH 0/2] configs/hardening: Some fixes for UBSAN

2024-04-22 Thread Justin Stitt
On Mon, Apr 15, 2024 at 11:15:05AM -0700, Kees Cook wrote: > On Thu, Apr 11, 2024 at 11:11:05AM -0700, Nathan Chancellor wrote: > > [0.189542] Internal error: UBSAN: unrecognized failure code: > > f2005515 [#1] PREEMPT SMP > > Oops! Yes, I didn't update the (arm64) trap handler to

[PATCH v5] checkpatch: add check for snprintf to scnprintf

2024-04-22 Thread Justin Stitt
let's do that." To help prevent new instances of snprintf() from popping up, let's add a check to checkpatch.pl. Suggested-by: Finn Thain Signed-off-by: Justin Stitt --- Changes in v5: - use capture groups to let the user know which variation they used - Link to v4: https://lore.kernel.org/r/2024

[PATCH] kallsyms: replace deprecated strncpy with strscpy

2024-04-12 Thread Justin Stitt
Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- --- kernel/module/kallsyms.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/module/kallsyms.c b/kernel/module/kallsyms.c index ef73ae7c8909..62fb57bb9f16 100644 --- a/kernel/module/kallsyms.c +++ b/ker

Re: [PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-11 Thread Justin Stitt
On Thu, Apr 11, 2024 at 1:56 PM Joe Perches wrote: > It could. > > # {v}snprintf uses that should likely be {v}scnprintf > if ($line =~ /\b((v?)snprintf)\s*\(/) { > WARN("SNPRINTF", > "Prefer ${2}scnprintf over $1 - see: >

Re: [PATCH] xfs: replace deprecated strncpy with strscpy_pad

2024-04-10 Thread Justin Stitt
On Tue, Apr 9, 2024 at 9:22 AM Kees Cook wrote: > > > > - /* 1 larger than sb_fname, so this ensures a trailing NUL char */ > > - memset(label, 0, sizeof(label)); > > spin_lock(>m_sb_lock); > > - strncpy(label, sbp->sb_fname, XFSLABEL_MAX); > > + strscpy_pad(label,

[PATCH v2] xfs: replace deprecated strncpy with memtostr_pad

2024-04-10 Thread Justin Stitt
ing@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - use memtostr_pad (thanks Kees) - Link to v1: https://lore.kernel.org/r/20240405-strncpy-xfs-split1-v1-1-3e3df465a...@google.com --- Note: This patch relies on the memtostr{_pad} implementation from Kees' patch: https://lore.kernel.

[PATCH v2] xfs: xattr: replace strncpy and check for truncation

2024-04-10 Thread Justin Stitt
/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - use "%.*s" format specifier - use != instead of < to check for truncation (Christoph H.) - Link to v1: https://lore.kernel.org/r/20240405-strncpy-xattr-split2-v1-1-90ab18232...@google.c

Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Justin Stitt
On Tue, Apr 9, 2024 at 5:23 PM Justin Stitt wrote: > > Hi, > > On Tue, Apr 9, 2024 at 6:32 AM Christoph Hellwig wrote: > > > > On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > > > - memcpy(offset, prefix, prefix_len); > > > -

Re: [PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-09 Thread Justin Stitt
Hi, On Tue, Apr 9, 2024 at 6:32 AM Christoph Hellwig wrote: > > On Fri, Apr 05, 2024 at 07:45:08PM +, Justin Stitt wrote: > > - memcpy(offset, prefix, prefix_len); > > - offset += prefix_len; > > - strncpy(offset, (char *)name, namelen);

Re: [PATCH v3 3/3] net: mana: Avoid open coded arithmetic

2024-04-08 Thread Justin Stitt
function. > > This way, the code is more readable and safer. > > This code was detected with the help of Coccinelle, and audited and > modified manually. > > Link: > https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-argu

Re: [PATCH v3 1/3] net: mana: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-08 Thread Justin Stitt
On Mon, Apr 8, 2024 at 2:35 PM Justin Stitt wrote: > > Hi, > > On Sat, Apr 06, 2024 at 04:23:35PM +0200, Erick Archer wrote: > > The "struct mana_cfg_rx_steer_req_v2" uses a dynamically sized set of > > trailing elements. Specifically, it uses a "mana_han

Re: [PATCH v3 2/3] RDMA/mana_ib: Prefer struct_size over open coded arithmetic

2024-04-08 Thread Justin Stitt
; > Link: > https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments > [1] > Link: https://github.com/KSPP/linux/issues/160 [2] > Signed-off-by: Erick Archer Reviewed-by: Justin Stitt > --- > drivers/infiniband/hw/mana/q

Re: [PATCH v3 1/3] net: mana: Add flex array to struct mana_cfg_rx_steer_req_v2

2024-04-08 Thread Justin Stitt
n-coded-arithmetic-in-allocator-arguments > [2] > Signed-off-by: Erick Archer I think this could have all been one patch, I found myself jumping around the three patches here piecing together context. Reviewed-by: Justin Stitt > --- > include/net/mana/mana.h | 1 + > 1 fil

[PATCH v3] net: dsa: lan9303: use ethtool_puts() for lan9303_get_strings()

2024-04-08 Thread Justin Stitt
://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Cc: Kees Cook Signed-off-by: Justin Stitt Suggested-by: Alexander Lobakin --- Changes in v3: - use ethtool_puts over

[PATCH v4] checkpatch: add check for snprintf to scnprintf

2024-04-08 Thread Justin Stitt
let's do that." To help prevent new instances of snprintf() from popping up, let's add a check to checkpatch.pl. Suggested-by: Finn Thain Signed-off-by: Justin Stitt --- Changes in v4: - also check for vsnprintf variant (thanks Bill) - Link to v3: https://lore.kernel.org/r/20240315-snprintf-ch

[PATCH] xfs: replace deprecated strncpy with strscpy_pad

2024-04-05 Thread Justin Stitt
el.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 --- Split f

[PATCH] xfs: xattr: replace strncpy and check for truncation

2024-04-05 Thread Justin Stitt
/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Split from https://lore.kernel.org/all/20240401-strncpy-fs-xfs-xfs_ioctl-c-v1-1-02b9feb19...@google.com/ with feedback from Christoph H. --- fs/xfs/xfs_xattr.c | 16 +++- 1 file changed, 11 insertions(+), 5

Re: [PATCH] Squashfs: replace deprecated strncpy with strscpy

2024-04-03 Thread Justin Stitt
On Wed, Apr 3, 2024 at 12:32 PM Phillip Lougher wrote: > A better way to remove the strncpy() is to remove the unnecessary string > copy, which I have done in this patch here: Great! Cleaning up this code while removing strncpy() is a two for one.

[PATCH] bpf: replace deprecated strncpy with strscpy

2024-04-02 Thread Justin Stitt
.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 --- Note: build-tested only. Found with: $ rg "strncpy\(&qu

[PATCH] init: replace deprecated strncpy with strscpy_pad

2024-04-02 Thread Justin Stitt
/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- init/do_mounts.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/init/do_mounts.c b/init/do_mounts.c index 3c

[PATCH] trace: events: cleanup deprecated strncpy uses

2024-04-01 Thread Justin Stitt
.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 --- Note: build-tested only

[PATCH] xfs: cleanup deprecated uses of strncpy

2024-04-01 Thread Justin Stitt
ink: 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 --- Note: build-tested only. Found with: $ rg "strncpy\(" --- fs/xfs/xfs_ioctl.c | 4 +--- fs

[PATCH] udf: replace deprecated strncpy/strcpy with strscpy

2024-04-01 Thread Justin Stitt
ww.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 --- Note: build-t

[PATCH v2] hfsplus: refactor copy_name to not use strncpy

2024-04-01 Thread Justin Stitt
.8/strscpy.9.en.html Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - include NUL-byte in length (thanks Kees) - reword commit message slightly - Link to v1: https://lore.kernel.org/r/20240321-strncpy-fs-hfsplus-xatt

[PATCH] Squashfs: replace deprecated strncpy with strscpy

2024-03-28 Thread Justin Stitt
/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://github.com/KSPP/linux/issues/90 [2] Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html [3] Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found

[PATCH] smb: client: replace deprecated strncpy with strscpy

2024-03-28 Thread Justin Stitt
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 --- fs/smb/client/cifssmb.c | 6 ++ fs/smb/client/smb2ops.c | 2 +- fs/smb/client/smb2transport.c | 2 +- 3 files changed, 4 insertions(+), 6 delet

[PATCH] reiserfs: replace deprecated strncpy with scnprintf

2024-03-28 Thread Justin Stitt
[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 --- I realize this file has been marked as "obsolete" as told by checkpatch: | WARNING: f

[PATCH] pstore/blk: replace deprecated strncpy with strscpy

2024-03-28 Thread Justin Stitt
.9.en.html [2] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- fs/pstore/blk.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/pstore/blk.c

[PATCH] orangefs: cleanup uses of strncpy

2024-03-22 Thread Justin Stitt
hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- fs/orangefs/dcache.c | 4 +--- fs/orangefs/namei.c | 26 -- fs/orangefs/super.c | 17 ++--- 3 files changed, 15 insertions(+),

[PATCH] hfsplus: refactor copy_name to not use strncpy

2024-03-21 Thread Justin Stitt
ink: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- --- fs/hfsplus/xattr.c | 19 +-- 1 file changed, 5 insertions(+), 14 deletions(-) diff --git a

[PATCH v2] binfmt: replace deprecated strncpy

2024-03-21 Thread Justin Stitt
mirror that in binfmt_elf_fdpic.c Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1] Link: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - use get_task_comm

Re: [PATCH] binfmt: replace deprecated strncpy with strscpy_pad

2024-03-21 Thread Justin Stitt
Hi, On Thu, Mar 21, 2024 at 9:23 AM Eric W. Biederman wrote: > > I am perplexed. Why not use get_task_comm fill_psinfo like binfmt_elf > does? > > It seems very silly to copy half the function without locking and then > not copy it's locking as well. > > Given that the more highly tested

[PATCH] ext4: replace deprecated strncpy with alternatives

2024-03-20 Thread Justin Stitt
KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- fs/ext4/file.c | 3 +-- fs/ext4/ioctl.c | 3 +-- fs/ext4/super.c | 7 +++ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a

[PATCH] fs: ecryptfs: replace deprecated strncpy with strscpy

2024-03-20 Thread Justin Stitt
ed.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 --- Note: build-tested only. Found with: $ rg "str

[PATCH] binfmt: replace deprecated strncpy with strscpy_pad

2024-03-20 Thread Justin Stitt
ted.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 --- Note: build-tested only. Found with: $ rg &qu

[PATCH] virt: acrn: replace deprecated strncpy with strscpy

2024-03-20 Thread Justin Stitt
ps://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

[PATCH v3] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-19 Thread Justin Stitt
: https://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- Changes in v3: - Prefer strtomem_pad (thanks Bjorn) - Reword commit message (thanks Bjorn) - Carry over Kees' RB as this new version is functionally the same and mat

Re: [PATCH v2] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-19 Thread Justin Stitt
Hi, On Mon, Mar 18, 2024 at 8:37 PM Bjorn Andersson wrote: > > On Mon, Mar 18, 2024 at 10:49:23PM +, Justin Stitt wrote: > > strncpy() is deprecated for use on NUL-terminated destination strings > > [1] and as such we should prefer more robust and less ambiguous str

Re: [PATCH] tty: n_gsm: replace deprecated strncpy with strscpy

2024-03-19 Thread Justin Stitt
Hi, On Tue, Mar 19, 2024 at 2:11 AM Maarten Brock wrote: > > Hi Justin, > > > --- > > Note: build-tested only. > > Really? Without warnings? > > > --- a/drivers/tty/n_gsm.c > > +++ b/drivers/tty/n_gsm.c > > @@ -4010,7 +4010,7 @@ static int gsm_create_network(struct gsm_dlci *dlci, > > struct

[PATCH] usb: gadget: mv_u3d: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
/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 --- Note: build-tested only. Found with: $ rg "strncpy\(" --- drivers/usb/gadget/udc/mv_u3d_core.c | 4 ++-- 1 file changed, 2 insertions

[PATCH] usb: gadget: u_ether: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- drivers/usb/gadget/function/u_ether.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/u_ether.c b/drivers/usb/gadget/function/u_ether.c index 3c

[PATCH] tty: n_gsm: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
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 --- Note: build-tested only. Found with: $ rg "strncpy\(" --- dri

[PATCH v2] soc: qcom: cmd-db: replace deprecated strncpy with strtomem

2024-03-18 Thread Justin Stitt
-by: Justin Stitt --- Changes in v2: - use strtomem instead of memcpy (thanks Kees) - Link to v1: https://lore.kernel.org/r/20240314-strncpy-drivers-soc-qcom-cmd-db-c-v1-1-70f5d5e70...@google.com --- Note: build-tested only. Found with: $ rg "strncpy\(" --- drivers/soc/qcom/cmd-db.c | 9 ++

Re: [PATCH] soc: qcom: cmd-db: replace deprecated strncpy with memcpy

2024-03-18 Thread Justin Stitt
On Mon, Mar 18, 2024 at 2:52 PM Kees Cook wrote: > > On Thu, Mar 14, 2024 at 10:29:37PM +, Justin Stitt wrote: > > strncpy() is deprecated for use on NUL-terminated destination strings > > [1] and as such we should prefer more robust and less ambiguous string > > in

[PATCH] thermal: intel: int340x_thermal: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
ithub.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- drivers/thermal/intel/int340x_thermal/acpi_thermal_rel.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/dr

[PATCH] scsi: target: core: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
ps://github.com/KSPP/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Note: build-tested only. Found with: $ rg "strncpy\(" --- drivers/target/target_core_transport.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drive

[PATCH] scsi: target: replace deprecated strncpy with strscpy

2024-03-18 Thread Justin Stitt
/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 --- Note: build-tested only. Found with: $ rg

[PATCH v3] checkpatch: add check for snprintf to scnprintf

2024-03-15 Thread Justin Stitt
let's do that." To help prevent new instances of snprintf() from popping up, let's add a check to checkpatch.pl. Suggested-by: Finn Thain Signed-off-by: Justin Stitt --- Changes in v3: - fix indentation - add reference link (https://github.com/KSPP/linux/issues/105) (thanks Joe) - Link

[PATCH] soc: qcom: cmd-db: replace deprecated strncpy with memcpy

2024-03-14 Thread Justin Stitt
/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 --- Note: build-tested only

Re: [PATCH v2 0/7] scsi: replace deprecated strncpy

2024-03-05 Thread Justin Stitt
On Wed, Feb 28, 2024 at 4:18 PM Kees Cook wrote: > > On Wed, Feb 28, 2024 at 10:59:00PM +, Justin Stitt wrote: > > This series contains multiple replacements of strncpy throughout the > > scsi subsystem. > > > > strncpy() is deprecated for use on NUL-termina

[PATCH v3 7/7] scsi: wd33c93: replace deprecated strncpy with strscpy

2024-03-05 Thread Justin Stitt
this code making it easier to read. Even considering the path where @str is falsey, the manual NUL-byte assignment is useless as setup_buffer is declared with static storage duration in the top-level scope which should NUL-initialize the whole buffer. Reviewed-by: Kees Cook Signed-off-by: Justin

[PATCH v3 6/7] scsi: smartpqi: replace deprecated strncpy with strscpy

2024-03-05 Thread Justin Stitt
appropriately with great care taken to manually NUL-terminate the destination buffer. Nonetheless, let's make the swap over to strscpy() for robustness' (and readability's) sake. Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++--- 1 file changed,

[PATCH v3 5/7] scsi: devinfo: replace strncpy and manual pad

2024-03-05 Thread Justin Stitt
of the code is more clear (I probably didn't even need to add a comment -- that's how clear it is). Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- drivers/scsi/scsi_devinfo.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b

[PATCH v3 3/7] scsi: qedf: replace deprecated strncpy with strscpy

2024-03-05 Thread Justin Stitt
tem but it is trivial and related to this patch). We can see the drv_version.name size here: | struct qed_mcp_drv_version { | u32 version; | u8 name[MCP_DRV_VER_STR_SIZE - 4]; | }; Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- drivers/net/ethernet/qlo

[PATCH v3 4/7] scsi: qla4xxx: replace deprecated strncpy with strscpy

2024-03-05 Thread Justin Stitt
uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN]; ... | }; | strscpy(chap_rec->password, chap_table->secret, | QL4_CHAP_MAX_SECRET_LEN); Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- drivers/scsi/qla4xxx/ql4_mbx.c | 17 -

[PATCH v3 2/7] scsi: mpt3sas: replace deprecated strncpy with strscpy

2024-03-05 Thread Justin Stitt
. For all cases, use the more idiomatic strscpy() usage of: strscpy(dest, src, sizeof(dest)) Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_transport.c | 18 +- 2 files changed, 10 insertions(+), 10

[PATCH v3 1/7] scsi: mpi3mr: replace deprecated strncpy with assignments

2024-03-05 Thread Justin Stitt
://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 Reviewed-by: Kees Cook Signed-off-by: Justin Stitt --- changes from v1->v2: * use const char* assignments rather than strscpy (thanks Finn+Kees) --- driv

[PATCH v3 0/7] scsi: replace deprecated strncpy

2024-03-05 Thread Justin Stitt
/20240223-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v1-0-9cd3882f0...@google.com --- Justin Stitt (7): scsi: mpi3mr: replace deprecated strncpy with assignments scsi: mpt3sas: replace deprecated strncpy with strscpy scsi: qedf: replace deprecated strncpy with strscpy scsi

[PATCH v2 6/7] scsi: smartpqi: replace deprecated strncpy with strscpy

2024-02-28 Thread Justin Stitt
appropriately with great care taken to manually NUL-terminate the destination buffer. Nonetheless, let's make the swap over to strscpy() for robustness' (and readability's) sake. Signed-off-by: Justin Stitt --- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 delet

[PATCH v2 7/7] scsi: wd33c93: replace deprecated strncpy with strscpy

2024-02-28 Thread Justin Stitt
this code making it easier to read. Even considering the path where @str is falsey, the manual NUL-byte assignment is useless as setup_buffer is declared with static storage duration in the top-level scope which should NUL-initialize the whole buffer. Signed-off-by: Justin Stitt --- drivers/scsi

[PATCH v2 5/7] scsi: devinfo: replace strncpy and manual pad

2024-02-28 Thread Justin Stitt
of the code is more clear (I probably didn't even need to add a comment -- that's how clear it is). Signed-off-by: Justin Stitt --- drivers/scsi/scsi_devinfo.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi

[PATCH v2 4/7] scsi: qla4xxx: replace deprecated strncpy with strscpy

2024-02-28 Thread Justin Stitt
uint8_t password[ISCSI_CHAP_AUTH_SECRET_MAX_LEN]; ... | }; | strscpy(chap_rec->password, chap_table->secret, | QL4_CHAP_MAX_SECRET_LEN); Signed-off-by: Justin Stitt --- drivers/scsi/qla4xxx/ql4_mbx.c | 17 - drivers/scsi/

[PATCH v2 3/7] scsi: qedf: replace deprecated strncpy with strscpy

2024-02-28 Thread Justin Stitt
tem but it is trivial and related to this patch). We can see the drv_version.name size here: | struct qed_mcp_drv_version { | u32 version; | u8 name[MCP_DRV_VER_STR_SIZE - 4]; | }; Signed-off-by: Justin Stitt --- drivers/net/ethernet/qlogic/qed/qed_main.c

[PATCH v2 2/7] scsi: mpt3sas: replace deprecated strncpy with strscpy

2024-02-28 Thread Justin Stitt
. For all cases, use the more idiomatic strscpy() usage of: strscpy(dest, src, sizeof(dest)) Signed-off-by: Justin Stitt --- drivers/scsi/mpt3sas/mpt3sas_base.c | 2 +- drivers/scsi/mpt3sas/mpt3sas_transport.c | 18 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff

[PATCH v2 1/7] scsi: mpi3mr: replace deprecated strncpy with assignments

2024-02-28 Thread Justin Stitt
://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 --- changes from v1->v2: * use const char* assignments rather than strscpy (thanks Finn+Kees) --- drivers/scsi/mpi3mr/mpi3mr_f

[PATCH v2 0/7] scsi: replace deprecated strncpy

2024-02-28 Thread Justin Stitt
patch. --- Changes in v2: - for (1/7): change strscpy to simple const char* assignments - Link to v1: https://lore.kernel.org/r/20240223-strncpy-drivers-scsi-mpi3mr-mpi3mr_fw-c-v1-0-9cd3882f0...@google.com --- Justin Stitt (7): scsi: mpi3mr: replace deprecated strncpy with assignments

[PATCH v2] scsi: lpfc: replace deprecated strncpy with strscpy

2024-02-26 Thread Justin Stitt
/linux/issues/90 Cc: linux-hardening@vger.kernel.org Signed-off-by: Justin Stitt --- Changes in v2: - keep strnlen (thanks Kees) - Link to v1: https://lore.kernel.org/all/20240222-strncpy-drivers-scsi-lpfc-lpfc_ct-c-v1-1-20c685bd1...@google.com/ --- drivers/scsi/lpfc/lpfc_ct.c | 4 ++-- 1

[PATCH 7/7] scsi: wd33c93: replace deprecated strncpy with strscpy

2024-02-23 Thread Justin Stitt
this code making it easier to read. Even considering the path where @str is falsey, the manual NUL-byte assignment is useless as setup_buffer is declared with static storage duration in the top-level scope which should NUL-initialize the whole buffer. Signed-off-by: Justin Stitt --- drivers/scsi

[PATCH 6/7] scsi: smartpqi: replace deprecated strncpy with strscpy

2024-02-23 Thread Justin Stitt
appropriately with great care taken to manually NUL-terminate the destination buffer. Nonetheless, let's make the swap over to strscpy() for robustness' (and readability's) sake. Signed-off-by: Justin Stitt --- drivers/scsi/smartpqi/smartpqi_init.c | 5 ++--- 1 file changed, 2 insertions(+), 3 delet

[PATCH 5/7] scsi: devinfo: replace strncpy and manual pad

2024-02-23 Thread Justin Stitt
of the code is more clear (I probably didn't even need to add a comment -- that's how clear it is). Signed-off-by: Justin Stitt --- drivers/scsi/scsi_devinfo.c | 18 ++ 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi

  1   2   3   4   >