From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 608E822D4DC for ; Sun, 29 Mar 2026 07:20:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774768803; cv=none; b=P0i11ZQNdAFZRkBZJR9ko/FOFCzpfYtok5efGeVgWYL3NfiSMbR8888e+ZzwyPpFyMszY/yXmZAyve2TLOoBpcdtu8+nPxttWL2i+7ClFmeCECZ8GHlo/NywQX7WiKdfz0/wnYCgPBGfKCGAXsGgMplla3QJJGTCnjYqRGVEXs0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774768803; c=relaxed/simple; bh=lx8u+5uedAt64ee9QWPJIudikFE2RX1ASjVV1teZKwI=; h=Subject:To:Cc:From:Date:Message-ID:MIME-Version:Content-Type; b=CFjA6+ywHtpm+cg4r2Lc/yktNzCohgDDtOAkiGFIqYmAYYUIV/izJyoVG1uTvruSqPqtsihoc3sNtq+ZhIl2QFxpsMvNJgBbnHiA+NGU7nFo9LN1ii62VgMXJMhS/uvyx3qksq0LZk+fd0wKdIghUVjdVrM46PX/FCqurhrS05c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=TUw/AeyT; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="TUw/AeyT" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 54714C116C6; Sun, 29 Mar 2026 07:20:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1774768803; bh=lx8u+5uedAt64ee9QWPJIudikFE2RX1ASjVV1teZKwI=; h=Subject:To:Cc:From:Date:From; b=TUw/AeyTDYn/yFa7ifmSLveX3W+SdVohYHM3/4OwIV4L24k69eOASlR/DU6MOPpwE sXABQJrOm4bkJ/fp/2bEwBo4wCDQbguZzhqYtItlArXHDGF1ErzEQMIFE6Zk+1836p GEON8fg2Hv1bHxesiyKtz5ys8WCneqwLHbKW46bs= Subject: FAILED: patch "[PATCH] ksmbd: replace hardcoded hdr2_len with offsetof() in" failed to apply to 5.15-stable tree To: linkinjeon@kernel.org,stfrench@microsoft.com Cc: From: Date: Sun, 29 Mar 2026 09:19:59 +0200 Message-ID: <2026032959-lapping-dude-6fa0@gregkh> Precedence: bulk X-Mailing-List: stable@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=ANSI_X3.4-1968 Content-Transfer-Encoding: 8bit The patch below does not apply to the 5.15-stable tree. If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to . To reproduce the conflict and resubmit, you may use the following commands: git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.15.y git checkout FETCH_HEAD git cherry-pick -x 0e55f63dd08f09651d39e1b709a91705a8a0ddcb # git commit -s git send-email --to '' --in-reply-to '2026032959-lapping-dude-6fa0@gregkh' --subject-prefix 'PATCH 5.15.y' HEAD^.. Possible dependencies: thanks, greg k-h ------------------ original commit in Linus's tree ------------------ >From 0e55f63dd08f09651d39e1b709a91705a8a0ddcb Mon Sep 17 00:00:00 2001 From: Namjae Jeon Date: Fri, 13 Mar 2026 14:45:58 +0900 Subject: [PATCH] ksmbd: replace hardcoded hdr2_len with offsetof() in smb2_calc_max_out_buf_len() After this commit (e2b76ab8b5c9 "ksmbd: add support for read compound"), response buffer management was changed to use dynamic iov array. In the new design, smb2_calc_max_out_buf_len() expects the second argument (hdr2_len) to be the offset of ->Buffer field in the response structure, not a hardcoded magic number. Fix the remaining call sites to use the correct offsetof() value. Cc: stable@vger.kernel.org Fixes: e2b76ab8b5c9 ("ksmbd: add support for read compound") Signed-off-by: Namjae Jeon Signed-off-by: Steve French diff --git a/fs/smb/server/smb2pdu.c b/fs/smb/server/smb2pdu.c index 24f8d58493d0..f5f1bf5f642e 100644 --- a/fs/smb/server/smb2pdu.c +++ b/fs/smb/server/smb2pdu.c @@ -4452,8 +4452,9 @@ int smb2_query_dir(struct ksmbd_work *work) d_info.wptr = (char *)rsp->Buffer; d_info.rptr = (char *)rsp->Buffer; d_info.out_buf_len = - smb2_calc_max_out_buf_len(work, 8, - le32_to_cpu(req->OutputBufferLength)); + smb2_calc_max_out_buf_len(work, + offsetof(struct smb2_query_directory_rsp, Buffer), + le32_to_cpu(req->OutputBufferLength)); if (d_info.out_buf_len < 0) { rc = -EINVAL; goto err_out; @@ -4720,8 +4721,9 @@ static int smb2_get_ea(struct ksmbd_work *work, struct ksmbd_file *fp, } buf_free_len = - smb2_calc_max_out_buf_len(work, 8, - le32_to_cpu(req->OutputBufferLength)); + smb2_calc_max_out_buf_len(work, + offsetof(struct smb2_query_info_rsp, Buffer), + le32_to_cpu(req->OutputBufferLength)); if (buf_free_len < 0) return -EINVAL; @@ -5047,8 +5049,9 @@ static int get_file_stream_info(struct ksmbd_work *work, file_info = (struct smb2_file_stream_info *)rsp->Buffer; buf_free_len = - smb2_calc_max_out_buf_len(work, 8, - le32_to_cpu(req->OutputBufferLength)); + smb2_calc_max_out_buf_len(work, + offsetof(struct smb2_query_info_rsp, Buffer), + le32_to_cpu(req->OutputBufferLength)); if (buf_free_len < 0) goto out; @@ -8206,8 +8209,9 @@ int smb2_ioctl(struct ksmbd_work *work) buffer = (char *)req + le32_to_cpu(req->InputOffset); cnt_code = le32_to_cpu(req->CtlCode); - ret = smb2_calc_max_out_buf_len(work, 48, - le32_to_cpu(req->MaxOutputResponse)); + ret = smb2_calc_max_out_buf_len(work, + offsetof(struct smb2_ioctl_rsp, Buffer), + le32_to_cpu(req->MaxOutputResponse)); if (ret < 0) { rsp->hdr.Status = STATUS_INVALID_PARAMETER; goto out;