All of lore.kernel.org
 help / color / mirror / Atom feed
From: David Laight <david.laight.linux@gmail.com>
To: Michal Wilczynski <m.wilczynski@samsung.com>
Cc: Dave Hansen <dave.hansen@linux.intel.com>,
	linux-mips@vger.kernel.org,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Bill Wendling <morbo@google.com>,
	"H. Peter Anvin" <hpa@zytor.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sungguk <sungguk.na@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-s390@vger.kernel.org,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Sergey Senozhatsky <senozhatsky@chromium.org>,
	Helge Deller <deller@gmx.de>,
	x86@kernel.org, Russell King <linux@armlinux.org.uk>,
	Ingo Molnar <mingo@redhat.com>,
	Yann Collet <yann.collet.73@gmail.com>,
	Gao Xiang <xiang@kernel.org>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	llvm@lists.linux.dev, Vasily Gorbik <gor@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	linux-crypto@vger.kernel.org,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Terrell <terrelln@meta.com>, Borislav Petkov <bp@alien8.de>,
	Jaegeuk Kim <jaegeuk@kernel.org>,
	linux-arm-kernel@lists.infradead.org,
	Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	linux-parisc@vger.kernel.org,
	Nick Desaulniers <ndesaulniers@google.com>,
	linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	Minchan Kim <minchan@kernel.org>,
	Thomas Gleixner <tglx@kernel.org>,
	Justin Stitt <justinstitt@google.com>,
	Phillip Lougher <phillip@squashfs.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-erofs@lists.ozlabs.org
Subject: Re: [f2fs-dev] [PATCH RFC 1/9] lib/lz4: import upstream LZ4 sources verbatim
Date: Sun, 4 Oct 2026 09:33:57 +0100	[thread overview]
Message-ID: <20261004093357.33a124b4@pumpkin> (raw)
In-Reply-To: <fac0f401-bbd3-444b-a755-53cc393673de@samsung.com>

On Sun, 4 Oct 2026 01:50:39 +0200
Michal Wilczynski <m.wilczynski@samsung.com> wrote:

> On 9/28/26 07:19, Sergey Senozhatsky wrote:
> > On (26/09/25 13:27), Michal Wilczynski wrote:
> > [..]  
> >> +int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration)
> >> +{
> >> +    LZ4_stream_t_internal* const ctx = & LZ4_initStream(state, sizeof(LZ4_stream_t)) -> internal_donotuse;
> >> +    assert(ctx != NULL);  
> > 
> > Probably in some other places as well:
> > 
> > LZ4_initStream() can return NULL, but the code immediately derefs
> > the pointer.  The assert() check seems to be misplaced, unless I'm
> > missing something.
> > 
> > I suppose those need to be decoupled.  First LZ4_initStream() call and
> > NULL check, then stream->internal_donotuse.  
> 
> Good catch, this assert() is a noop in the kernel (as any build without
> LZ4_DEBUG), so a NULL, undersized or misaligned wrkmem oopses in
> LZ4_compress_fast(), and LZ4_compress_destSize() and LZ4_resetStreamHC()
> carry on with an uninitialised state.

The assert() is also just a waste of code.
Debugging the NULL pointer dereference is just as easy.

David 
 
> 
> No in-tree caller hits it (all use kmalloc/vmalloc), and I listed the
> alignment requirement as a behaviour change in the cover letter. Still,
> the vendored files need to stay verbatim.
> 
> So in v2 our own entry points can check alignment with a WARN_ON_ONCE()
> and bail out early. It might be something that we can fix upstream as
> well.
> 
> 
> >   
> 
> Best regards,



_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel

WARNING: multiple messages have this Message-ID (diff)
From: David Laight <david.laight.linux@gmail.com>
To: Michal Wilczynski <m.wilczynski@samsung.com>
Cc: Sergey Senozhatsky <senozhatsky@chromium.org>,
	Nathan Chancellor <nathan@kernel.org>,
	Nick Desaulniers <ndesaulniers@google.com>,
	Bill Wendling <morbo@google.com>,
	Justin Stitt <justinstitt@google.com>,
	Russell King <linux@armlinux.org.uk>,
	Thomas Bogendoerfer <tsbogend@alpha.franken.de>,
	"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>,
	Helge Deller <deller@gmx.de>, Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Christian Borntraeger <borntraeger@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Thomas Gleixner <tglx@kernel.org>, Ingo Molnar <mingo@redhat.com>,
	Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	x86@kernel.org, "H. Peter Anvin" <hpa@zytor.com>,
	Minchan Kim <minchan@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org, llvm@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org,
	linux-parisc@vger.kernel.org, linux-s390@vger.kernel.org,
	linux-block@vger.kernel.org,
	Yann Collet <yann.collet.73@gmail.com>,
	Nick Terrell <terrelln@meta.com>, Gao Xiang <xiang@kernel.org>,
	Chao Yu <chao@kernel.org>, Jaegeuk Kim <jaegeuk@kernel.org>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	Phillip Lougher <phillip@squashfs.org.uk>,
	Sungguk <sungguk.na@samsung.com>,
	Jaehoon Chung <jh80.chung@samsung.com>,
	Marek Szyprowski <m.szyprowski@samsung.com>,
	linux-erofs@lists.ozlabs.org,
	linux-f2fs-devel@lists.sourceforge.net,
	linux-crypto@vger.kernel.org
Subject: Re: [PATCH RFC 1/9] lib/lz4: import upstream LZ4 sources verbatim
Date: Sun, 4 Oct 2026 09:33:57 +0100	[thread overview]
Message-ID: <20261004093357.33a124b4@pumpkin> (raw)
In-Reply-To: <fac0f401-bbd3-444b-a755-53cc393673de@samsung.com>

On Sun, 4 Oct 2026 01:50:39 +0200
Michal Wilczynski <m.wilczynski@samsung.com> wrote:

> On 9/28/26 07:19, Sergey Senozhatsky wrote:
> > On (26/09/25 13:27), Michal Wilczynski wrote:
> > [..]  
> >> +int LZ4_compress_fast_extState(void* state, const char* source, char* dest, int inputSize, int maxOutputSize, int acceleration)
> >> +{
> >> +    LZ4_stream_t_internal* const ctx = & LZ4_initStream(state, sizeof(LZ4_stream_t)) -> internal_donotuse;
> >> +    assert(ctx != NULL);  
> > 
> > Probably in some other places as well:
> > 
> > LZ4_initStream() can return NULL, but the code immediately derefs
> > the pointer.  The assert() check seems to be misplaced, unless I'm
> > missing something.
> > 
> > I suppose those need to be decoupled.  First LZ4_initStream() call and
> > NULL check, then stream->internal_donotuse.  
> 
> Good catch, this assert() is a noop in the kernel (as any build without
> LZ4_DEBUG), so a NULL, undersized or misaligned wrkmem oopses in
> LZ4_compress_fast(), and LZ4_compress_destSize() and LZ4_resetStreamHC()
> carry on with an uninitialised state.

The assert() is also just a waste of code.
Debugging the NULL pointer dereference is just as easy.

David 
 
> 
> No in-tree caller hits it (all use kmalloc/vmalloc), and I listed the
> alignment requirement as a behaviour change in the cover letter. Still,
> the vendored files need to stay verbatim.
> 
> So in v2 our own entry points can check alignment with a WARN_ON_ONCE()
> and bail out early. It might be something that we can fix upstream as
> well.
> 
> 
> >   
> 
> Best regards,



  reply	other threads:[~2026-10-04  8:34 UTC|newest]

Thread overview: 60+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260925113450eucas1p2fcf838f00f35e1bce0ca04a694cd0cd2@eucas1p2.samsung.com>
2026-09-25 11:27 ` [f2fs-dev] [PATCH RFC 0/9] lib/lz4: stop forking upstream LZ4, vendor it instead Michal Wilczynski
2026-09-25 11:27   ` Michal Wilczynski
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 1/9] lib/lz4: import upstream LZ4 sources verbatim Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:38     ` sashiko-bot
2026-09-28  4:12     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  4:12       ` Sergey Senozhatsky
2026-10-03 23:34       ` [f2fs-dev] " Michal Wilczynski
2026-10-03 23:34         ` Michal Wilczynski
2026-09-28  5:19     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  5:19       ` Sergey Senozhatsky
2026-10-03 23:50       ` [f2fs-dev] " Michal Wilczynski
2026-10-03 23:50         ` Michal Wilczynski
2026-10-04  8:33         ` David Laight [this message]
2026-10-04  8:33           ` David Laight
2026-09-30  6:07     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-30  6:07       ` Sergey Senozhatsky
2026-10-03 23:52       ` [f2fs-dev] " Michal Wilczynski
2026-10-03 23:52         ` Michal Wilczynski
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 2/9] lib/lz4: backport upstream's -Wmissing-prototypes fix Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:42     ` sashiko-bot
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 3/9] lib/lz4: add the build environment for the vendored sources Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:47     ` sashiko-bot
2026-09-28  5:48     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  5:48       ` Sergey Senozhatsky
2026-10-04  0:05       ` [f2fs-dev] " Michal Wilczynski
2026-10-04  0:05         ` Michal Wilczynski
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 4/9] arch: boot: put the LZ4 freestanding headers on the decompressor path Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:43     ` sashiko-bot
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 5/9] lib/lz4: switch the compressor to the vendored sources Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:43     ` sashiko-bot
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 6/9] lib/lz4: switch the HC " Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:43     ` sashiko-bot
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 7/9] lib/lz4: switch the decompressor " Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:42     ` sashiko-bot
2026-09-28  4:16     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  4:16       ` Sergey Senozhatsky
2026-10-03 23:38       ` [f2fs-dev] " Michal Wilczynski
2026-10-03 23:38         ` Michal Wilczynski
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 8/9] lib/lz4: fold lz4_kernel_api.h into <linux/lz4.h> Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 11:43     ` sashiko-bot
2026-09-25 11:27   ` [f2fs-dev] [PATCH RFC 9/9] MAINTAINERS: add an entry for the LZ4 compression library Michal Wilczynski
2026-09-25 11:27     ` Michal Wilczynski
2026-09-25 21:39     ` [f2fs-dev] " Eric Biggers via Linux-f2fs-devel
2026-09-25 21:39       ` Eric Biggers
2026-10-03 22:45       ` [f2fs-dev] " Michal Wilczynski
2026-10-03 22:45         ` Michal Wilczynski
2026-09-25 22:07   ` [f2fs-dev] [PATCH RFC 0/9] lib/lz4: stop forking upstream LZ4, vendor it instead Eric Biggers via Linux-f2fs-devel
2026-09-25 22:07     ` Eric Biggers
2026-09-28  4:25   ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  4:25     ` Sergey Senozhatsky
2026-09-28  8:27     ` [f2fs-dev] " Sergey Senozhatsky
2026-09-28  8:27       ` Sergey Senozhatsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261004093357.33a124b4@pumpkin \
    --to=david.laight.linux@gmail.com \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=agordeev@linux.ibm.com \
    --cc=akpm@linux-foundation.org \
    --cc=axboe@kernel.dk \
    --cc=borntraeger@linux.ibm.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=deller@gmx.de \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=hpa@zytor.com \
    --cc=jaegeuk@kernel.org \
    --cc=justinstitt@google.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-erofs@lists.ozlabs.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mips@vger.kernel.org \
    --cc=linux-parisc@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=llvm@lists.linux.dev \
    --cc=m.szyprowski@samsung.com \
    --cc=m.wilczynski@samsung.com \
    --cc=minchan@kernel.org \
    --cc=mingo@redhat.com \
    --cc=morbo@google.com \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    --cc=phillip@squashfs.org.uk \
    --cc=senozhatsky@chromium.org \
    --cc=sungguk.na@samsung.com \
    --cc=svens@linux.ibm.com \
    --cc=terrelln@meta.com \
    --cc=tglx@kernel.org \
    --cc=tsbogend@alpha.franken.de \
    --cc=x86@kernel.org \
    --cc=xiang@kernel.org \
    --cc=yann.collet.73@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.