{"id":2222820,"url":"http://patchwork.ozlabs.org/api/1.2/patches/2222820/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260413190713.283939-3-ematsumiya@suse.de/","project":{"id":12,"url":"http://patchwork.ozlabs.org/api/1.2/projects/12/?format=json","name":"Linux CIFS Client","link_name":"linux-cifs-client","list_id":"linux-cifs.vger.kernel.org","list_email":"linux-cifs@vger.kernel.org","web_url":"","scm_url":"","webscm_url":"","list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20260413190713.283939-3-ematsumiya@suse.de>","list_archive_url":null,"date":"2026-04-13T19:07:08","name":"[3/8] smb: client: compress: fix counting in LZ77 match finding","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"792b20f8bbbfde36d532be844c60d2bfbf303a75","submitter":{"id":78375,"url":"http://patchwork.ozlabs.org/api/1.2/people/78375/?format=json","name":"Enzo Matsumiya","email":"ematsumiya@suse.de"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/linux-cifs-client/patch/20260413190713.283939-3-ematsumiya@suse.de/mbox/","series":[{"id":499741,"url":"http://patchwork.ozlabs.org/api/1.2/series/499741/?format=json","web_url":"http://patchwork.ozlabs.org/project/linux-cifs-client/list/?series=499741","date":"2026-04-13T19:07:09","name":"[1/8] smb: client: compress: fix buffer overrun in lz77_compress()","version":1,"mbox":"http://patchwork.ozlabs.org/series/499741/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2222820/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2222820/checks/","tags":{},"related":[],"headers":{"Return-Path":"\n <linux-cifs+bounces-10777-incoming=patchwork.ozlabs.org@vger.kernel.org>","X-Original-To":["incoming@patchwork.ozlabs.org","linux-cifs@vger.kernel.org"],"Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=suse.de header.i=@suse.de header.a=rsa-sha256\n header.s=susede2_rsa header.b=xT+rrlcj;\n\tdkim=pass header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=98VuPZTr;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.a=rsa-sha256 header.s=susede2_rsa header.b=xT+rrlcj;\n\tdkim=neutral header.d=suse.de header.i=@suse.de header.a=ed25519-sha256\n header.s=susede2_ed25519 header.b=98VuPZTr;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=172.234.253.10; helo=sea.lore.kernel.org;\n envelope-from=linux-cifs+bounces-10777-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)","smtp.subspace.kernel.org;\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.b=\"xT+rrlcj\";\n\tdkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de\n header.b=\"98VuPZTr\";\n\tdkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.b=\"xT+rrlcj\";\n\tdkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de\n header.b=\"98VuPZTr\"","smtp.subspace.kernel.org;\n arc=none smtp.client-ip=195.135.223.130","smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=suse.de","smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=suse.de","smtp-out1.suse.de;\n\tnone"],"Received":["from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fvcVC583xz1xtJ\n\tfor <incoming@patchwork.ozlabs.org>; Tue, 14 Apr 2026 05:12:19 +1000 (AEST)","from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby sea.lore.kernel.org (Postfix) with ESMTP id C7FE73045024\n\tfor <incoming@patchwork.ozlabs.org>; Mon, 13 Apr 2026 19:07:44 +0000 (UTC)","from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 1D34C38F647;\n\tMon, 13 Apr 2026 19:07:44 +0000 (UTC)","from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))\n\t(No client certificate requested)\n\tby smtp.subspace.kernel.org (Postfix) with ESMTPS id C070C327C08\n\tfor <linux-cifs@vger.kernel.org>; Mon, 13 Apr 2026 19:07:42 +0000 (UTC)","from imap1.dmz-prg2.suse.org (unknown [10.150.64.97])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby smtp-out1.suse.de (Postfix) with ESMTPS id 146886A8B7;\n\tMon, 13 Apr 2026 19:07:41 +0000 (UTC)","from imap1.dmz-prg2.suse.org (localhost [127.0.0.1])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest\n SHA256)\n\t(No client certificate requested)\n\tby imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 93C8F4B038;\n\tMon, 13 Apr 2026 19:07:40 +0000 (UTC)","from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167])\n\tby imap1.dmz-prg2.suse.org with ESMTPSA\n\tid jwPOFvw+3WknEAAAD6G6ig\n\t(envelope-from <ematsumiya@suse.de>); Mon, 13 Apr 2026 19:07:40 +0000"],"ARC-Seal":"i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1776107264; cv=none;\n b=oAQNOCaDOFhFzpYVmaz6riDlIqK5Y/iybY4HhobM6eDfH/m/pNs9fiF8FBl1B+XI+Syja/5PdEo4n6Nrqkl0wyOfk+bhBL12HqhhoWGvOmd97PTqSS0NMq0t/aY55HBbjaWxyCgJzoow0936EmMMYdwOg4ZWZOVy1eEEiO4Q6yA=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1776107264; c=relaxed/simple;\n\tbh=3Xowdv2BvhLZ717GW43TwB1ow9mGeQa7xbjYK/8rGW8=;\n\th=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:\n\t MIME-Version;\n b=DClguklqqCxRyiq8M+NzvXWjnu1l7QcrW2Vrd8ZurgjkExqOxS8pR/luDwJtT0ZyEYQGLUpqqJe8yoQd1GaGcpAl3qMquCyDXZG9bI7eoSi9Br99ePGEkdQZ0Jbzwa6GTXoLrjMtJiLDx3HZxtZccbzYuGi1bhyU25pMAq5S5Co=","ARC-Authentication-Results":"i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=none dis=none) header.from=suse.de;\n spf=pass smtp.mailfrom=suse.de;\n dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.b=xT+rrlcj;\n dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de\n header.b=98VuPZTr;\n dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de\n header.b=xT+rrlcj;\n dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de\n header.b=98VuPZTr; arc=none smtp.client-ip=195.135.223.130","DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n\tt=1776107261;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n\t mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=zMF5k9xlh64JtzVfTCCTVu0y6xLgrEG2XWvMV8dxisc=;\n\tb=xT+rrlcjKT8OyBHNrvL8rbKS9xW8Zkda9be+Jlb7VgZQmeoYptlExF06WNh7wQVoL7PsLM\n\t9gunUGnszmmOya5TjS+us6lUAvwCMzUtdJ5B5cEqJ857OYKhwZDC6Gpl+XIzPhXikzYfm9\n\tFj67uuPa41y7eZ0Y0uMN8b5HtyRauEk=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n\ts=susede2_ed25519; t=1776107261;\n\th=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n\t mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=zMF5k9xlh64JtzVfTCCTVu0y6xLgrEG2XWvMV8dxisc=;\n\tb=98VuPZTr8ryuBPNbsSW//adWi4rErbiqydCk0SjGa2+vrj6Uefq+FE9ImNDAl/or6Cu5hi\n\tlmIiEmd8jeCpnGBg==","v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de;\n s=susede2_rsa;\n\tt=1776107261;\n h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n\t mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=zMF5k9xlh64JtzVfTCCTVu0y6xLgrEG2XWvMV8dxisc=;\n\tb=xT+rrlcjKT8OyBHNrvL8rbKS9xW8Zkda9be+Jlb7VgZQmeoYptlExF06WNh7wQVoL7PsLM\n\t9gunUGnszmmOya5TjS+us6lUAvwCMzUtdJ5B5cEqJ857OYKhwZDC6Gpl+XIzPhXikzYfm9\n\tFj67uuPa41y7eZ0Y0uMN8b5HtyRauEk=","v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de;\n\ts=susede2_ed25519; t=1776107261;\n\th=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc:\n\t mime-version:mime-version:\n\t content-transfer-encoding:content-transfer-encoding:\n\t in-reply-to:in-reply-to:references:references;\n\tbh=zMF5k9xlh64JtzVfTCCTVu0y6xLgrEG2XWvMV8dxisc=;\n\tb=98VuPZTr8ryuBPNbsSW//adWi4rErbiqydCk0SjGa2+vrj6Uefq+FE9ImNDAl/or6Cu5hi\n\tlmIiEmd8jeCpnGBg=="],"From":"Enzo Matsumiya <ematsumiya@suse.de>","To":"linux-cifs@vger.kernel.org","Cc":"smfrench@gmail.com,\n\tpc@manguebit.com,\n\tronniesahlberg@gmail.com,\n\tsprasad@microsoft.com,\n\ttom@talpey.com,\n\tbharathsm@microsoft.com,\n\thenrique.carvalho@suse.com","Subject":"[PATCH 3/8] smb: client: compress: fix counting in LZ77 match finding","Date":"Mon, 13 Apr 2026 16:07:08 -0300","Message-ID":"<20260413190713.283939-3-ematsumiya@suse.de>","X-Mailer":"git-send-email 2.53.0","In-Reply-To":"<20260413190713.283939-1-ematsumiya@suse.de>","References":"<20260413190713.283939-1-ematsumiya@suse.de>","Precedence":"bulk","X-Mailing-List":"linux-cifs@vger.kernel.org","List-Id":"<linux-cifs.vger.kernel.org>","List-Subscribe":"<mailto:linux-cifs+subscribe@vger.kernel.org>","List-Unsubscribe":"<mailto:linux-cifs+unsubscribe@vger.kernel.org>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-Spam-Score":"-2.80","X-Spam-Level":"","X-Spamd-Result":"default: False [-2.80 / 50.00];\n\tBAYES_HAM(-3.00)[100.00%];\n\tNEURAL_HAM_LONG(-1.00)[-1.000];\n\tMID_CONTAINS_FROM(1.00)[];\n\tR_MISSING_CHARSET(0.50)[];\n\tNEURAL_HAM_SHORT(-0.20)[-0.999];\n\tMIME_GOOD(-0.10)[text/plain];\n\tTO_MATCH_ENVRCPT_ALL(0.00)[];\n\tFUZZY_RATELIMITED(0.00)[rspamd.com];\n\tFROM_HAS_DN(0.00)[];\n\tRCVD_VIA_SMTP_AUTH(0.00)[];\n\tFREEMAIL_CC(0.00)[gmail.com,manguebit.com,microsoft.com,talpey.com,suse.com];\n\tARC_NA(0.00)[];\n\tTO_DN_NONE(0.00)[];\n\tRCVD_TLS_ALL(0.00)[];\n\tFROM_EQ_ENVFROM(0.00)[];\n\tRCVD_COUNT_TWO(0.00)[2];\n\tRCPT_COUNT_SEVEN(0.00)[8];\n\tDBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:email];\n\tMIME_TRACE(0.00)[0:+];\n\tDKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519];\n\tFREEMAIL_ENVRCPT(0.00)[gmail.com]","X-Spam-Flag":"NO"},"content":"- lz77_match_len() increments @cur before checking for equality,\n  leading to off-by-one match len in some cases.\n\n  Fix by moving pointers increment to inside the loop.\n  Also rename @wnd arg to @match (more accurate name).\n- both lz77_match_len() and lz77_compress() checked for\n  \"buf + step < end\" when the correct is \"<=\" for such cases.\n\nSigned-off-by: Enzo Matsumiya <ematsumiya@suse.de>\n---\n fs/smb/client/compress/lz77.c | 17 ++++++++++-------\n 1 file changed, 10 insertions(+), 7 deletions(-)","diff":"diff --git a/fs/smb/client/compress/lz77.c b/fs/smb/client/compress/lz77.c\nindex c1e7fada6e61..61cdf1c14612 100644\n--- a/fs/smb/client/compress/lz77.c\n+++ b/fs/smb/client/compress/lz77.c\n@@ -48,17 +48,17 @@ static __always_inline void lz77_write32(u32 *ptr, u32 v)\n \tput_unaligned_le32(v, ptr);\n }\n \n-static __always_inline u32 lz77_match_len(const void *wnd, const void *cur, const void *end)\n+static __always_inline u32 lz77_match_len(const void *match, const void *cur, const void *end)\n {\n \tconst void *start = cur;\n \tu64 diff;\n \n \t/* Safe for a do/while because otherwise we wouldn't reach here from the main loop. */\n \tdo {\n-\t\tdiff = lz77_read64(cur) ^ lz77_read64(wnd);\n+\t\tdiff = lz77_read64(cur) ^ lz77_read64(match);\n \t\tif (!diff) {\n \t\t\tcur += LZ77_STEP_SIZE;\n-\t\t\twnd += LZ77_STEP_SIZE;\n+\t\t\tmatch += LZ77_STEP_SIZE;\n \n \t\t\tcontinue;\n \t\t}\n@@ -67,10 +67,13 @@ static __always_inline u32 lz77_match_len(const void *wnd, const void *cur, cons\n \t\tcur += count_trailing_zeros(diff) >> 3;\n \n \t\treturn (cur - start);\n-\t} while (likely(cur + LZ77_STEP_SIZE < end));\n+\t} while (likely(cur + LZ77_STEP_SIZE <= end));\n \n-\twhile (cur < end && lz77_read8(cur++) == lz77_read8(wnd++))\n-\t\t;\n+\t/* Fallback to byte-by-byte comparison for last <8 bytes. */\n+\twhile (cur < end && lz77_read8(cur) == lz77_read8(match)) {\n+\t\tcur++;\n+\t\tmatch++;\n+\t}\n \n \treturn (cur - start);\n }\n@@ -195,7 +198,7 @@ noinline int lz77_compress(const void *src, u32 slen, void *dst, u32 *dlen)\n \t\t\tflag_pos = dstp;\n \t\t\tdstp += 4;\n \t\t}\n-\t} while (likely(srcp + LZ77_STEP_SIZE < end));\n+\t} while (likely(srcp + LZ77_STEP_SIZE <= end));\n \n \twhile (srcp < end) {\n \t\tu32 c = umin(end - srcp, 32 - flag_count);\n","prefixes":["3/8"]}