From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr2-f34.google.com (mail-wr2-f34.google.com [74.125.225.98]) (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 C66983B14C7 for ; Sun, 4 Oct 2026 08:34:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.225.98 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791102843; cv=none; b=ARhlJPhhZ69/W7Ntiw5CCMePPLYA5bNJOe+WVID0aV47oTxg5Dko0l9167HCb0DPIHjN9WNNM8qWCKAG+vXmMjyqeEGWXOvqWDnE+jdlNplfQI/c0kwd2p3YADidlA0JcIFRSwNqShqZQ3cAKUw5DNXOQr0j/4xujMovvcwB6FE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791102843; c=relaxed/simple; bh=1sBv2SI3wnHyVQDHUJVigmIehBQG6EXZHnsM+TL5srs=; h=Date:From:To:Cc:Subject:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=NWh6tNneDyHbudRjKwkdpJsfOpPTjQHtS3F5d0lLnP+Go9Q237ct3k1s2uQTVVhDKk91neWAc+pssNjrFezcxoM8gkxYvyu4lvBUiTinD+s48vSYJnnitsVphsZapPNkhTtAFSCCW9BY373WahZlQ3ZOL1Eu4KL51TvvvObleNE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=NdkAUfd2; arc=none smtp.client-ip=74.125.225.98 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NdkAUfd2" Received: by mail-wr2-f34.google.com with SMTP id ffacd0b85a97d-48b01c41135so478576f8f.0 for ; Sun, 04 Oct 2026 01:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1791102840; x=1791707640; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:from:to:cc:subject :date:message-id:reply-to:content-type; bh=0HFDC0D77tUqEmXehAlYyAx2E0DK1wOzX1zKg1ym3bo=; b=NdkAUfd2+KZTf3s9hEpqKwliTej8peJLCSWDISLUjLwt09egN/aiRz2XZCkpPnIhNC aK2B8KkXrAsfSf5UqEl+SqvFza5LHgVUqAccsIdsuUTmlR+g8Uea5bMpAzd2qbdFBiCg t8fADBhEweXTv2ZNQgB7eZ1zF3dsFM6vncUf/ADRkOjyLLHTRGIDP4eOp+lBBA8JuXeu nBJoxu6110IVlbTfAnaegRILWMJ2WNttnECN9/fl0pH8w6q6eG9C43JEnC4p9zNrOs3x cGQa4jIxiwUPFj88RAfsTL3tjVtRaEeC2g1Rjy8xyoFrbRQsWvwMztVhAx2Ih1bK6nsb 4faQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791102840; x=1791707640; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=0HFDC0D77tUqEmXehAlYyAx2E0DK1wOzX1zKg1ym3bo=; b=mDr42I4Hf5uTnPrdF0ievcxnan4gty/ePbb0AqgPCyXj3x+VRuWD4kxqTJKvOfS9XN fjwmx2uMDe1tHqRCX8d/qAM13ctA/BrD3Tak5sYitxitCifcIICwUFvoFwBnHCp3ho8j rF2hCdaBFgfD8207e5S0XPb41OpIyKOAXEdAm6VqgZuSKRf1MPxYa/AetO3FS4JFzBut 2eLxsORtsTO5ZrNLi/1QGglTiFEzCpCBddygkqRzzkUw4TLhifpiGB7ugcfx8migHJZd mrKQeoCnOjPGUSZxPfHMeZxno+yNpgaDobPOiHu73hpuNyNRUtonKdlmarOICz0sYO3T dEFQ== X-Forwarded-Encrypted: i=1; AKwUvBx8VWDMffi/c/9kRwUNeXVxYZSj/2XXYfAHD4lrVe9VYH5ZKahQL5XVg7cx2mq1rQioRCrdsnBgYZ96wAE=@vger.kernel.org X-Gm-Message-State: AFq9FYKSlmd0Lgw+d+C0K1RMigg3Ak5q8VchPkb2n11zF50dmbX8kzPb pXs5XQnZVjUG5v8RUj5AyjhqV3SWI4ued9ntqrnLHHwx2m69tv4mAXbK X-Gm-Gg: AYBFou1oehW5zsaYQDmqmBpaW5b3glOGveMrbn8WCC4WhViAB7MF4ODvJMe9Fcqqmru 74ZjsZjvbGl04X2/RQwVE77RA58rgWEnY2RXnkxHqSl8qfxorvx/XCJ/qehprxAzWejdpbYh1Ey Yl83z3aiJXy/S5W7SrGuJL2jlgxKK7b9PUDujUSISnXzLcvCq16Cc8fJIWy6Wq97JY78N2UAZwk IUkA2kreXdrRlybZlFHb56bA19cqv/8Y7gZY9+FCRxtFNhJn3+C2ms6gbqqREInC2ocnJ9HBT35 yG7LbXnvWEAKuRN36C0LQ0CW5hfYS8VzMdDDKpKdtNmyAWflTTCTobATyjrCJc1mGH6zD8XdejI YT69ake5pnGd9k67zBg0EINkkU01KFvC229aQWqlxjWkVoV4YBS5mwIdOm9MuaOCOS7yQ48FkOX LXaERQq4tH+peupwjjYEACwZm6yd8u1RHcpWzUajH+/eitsSRKJ+wx5ZZ8O1ErdDl9YlJXY0Omr jFjKdj6BaD+dgWxCrflA82rTh2137L/BQaJrWHZF+Emew== X-Received: by 2002:a5d:5d0f:0:b0:488:83f7:633a with SMTP id ffacd0b85a97d-48b12736b49mr11750202f8f.28.1791102839800; Sun, 04 Oct 2026 01:33:59 -0700 (PDT) Received: from pumpkin (82-69-66-36.dsl.in-addr.zen.co.uk. [82.69.66.36]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-48b380f04f8sm17350793f8f.9.2026.10.04.01.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2026 01:33:59 -0700 (PDT) Date: Sun, 4 Oct 2026 09:33:57 +0100 From: David Laight To: Michal Wilczynski Cc: Sergey Senozhatsky , Nathan Chancellor , Nick Desaulniers , Bill Wendling , Justin Stitt , Russell King , Thomas Bogendoerfer , "James E.J. Bottomley" , Helge Deller , Heiko Carstens , Vasily Gorbik , Alexander Gordeev , Christian Borntraeger , Sven Schnelle , Thomas Gleixner , Ingo Molnar , Borislav Petkov , Dave Hansen , x86@kernel.org, "H. Peter Anvin" , Minchan Kim , Jens Axboe , Andrew Morton , 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 , Nick Terrell , Gao Xiang , Chao Yu , Jaegeuk Kim , Herbert Xu , Phillip Lougher , Sungguk , Jaehoon Chung , Marek Szyprowski , 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 Message-ID: <20261004093357.33a124b4@pumpkin> In-Reply-To: References: <20260925-lz4-vendor-upstream-v1-0-1c7ffbe21c4b@samsung.com> <20260925-lz4-vendor-upstream-v1-1-1c7ffbe21c4b@samsung.com> X-Mailer: Claws Mail 4.1.1 (GTK 3.24.38; arm-unknown-linux-gnueabihf) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit On Sun, 4 Oct 2026 01:50:39 +0200 Michal Wilczynski 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,