From nobody Tue Dec 2 01:07:15 2025 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A963227EC80 for ; Sun, 23 Nov 2025 23:53:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763942008; cv=none; b=aLDptyNbn/eeTYTcrfZfZ/H13L/Ftng73zeIzV7xMzDzLIzupdcT/h91naDGmgPHCqmS5sD+gl2PcRYIfMy6QTIkgIBJfHNHuMkAwpyeSwWtbRIxs7KIThzIV7QPXcNymdzvzLD3RgwYGMll7B3PPjwax6qBBPx4GsEBxtaOXB4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763942008; c=relaxed/simple; bh=bp1hje8TsOLQ2RFJb36RPr1l308CepLcaPVTTLyjjAA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=CAj3eMP8xgkqpFwTPjo55UI0xf9XKkOC0SNBnCnu0GLWA1TKTFY+XQbZ0XsofuwQKpbsH47s50nIyAuH7X1tE9cOs5NxwqetFKr480Uh5abyUa4ve1N9ovBBeV7E897BWsmCnEu6Mh5UHdySpogxSG+1kpSyIi3r5keTMyY6L70= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fhb6L+FU; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fhb6L+FU" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1763942004; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=+zR+wyD2tkHaCbGXbBhk+jHS6Ln/+v/na1j9uB/3YwU=; b=fhb6L+FU7B9pi+r9RGQeppcuBQShE3lF6odLctqoy02XbixpiujyzKdNEyE0c/W0zpv8C+ ecK78/B2UnJ8buGYyrw2V7LOcWG7+gTGvlhZKjTiLc1297avug9gak5S19ruaO+BDDtVdV w2Lq1Epu19ZjaA3/dZBlMYgsmC6N8dQ= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-363-FcYCN9XGNvuULIhxShcVqg-1; Sun, 23 Nov 2025 18:53:21 -0500 X-MC-Unique: FcYCN9XGNvuULIhxShcVqg-1 X-Mimecast-MFC-AGG-ID: FcYCN9XGNvuULIhxShcVqg_1763941999 Received: from mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.93]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B566A1956050; Sun, 23 Nov 2025 23:53:19 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.14]) by mx-prod-int-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 4459D1800451; Sun, 23 Nov 2025 23:53:17 +0000 (UTC) From: David Howells To: Steve French Cc: David Howells , Paulo Alcantara , Shyam Prasad N , Stefan Metzmacher , linux-cifs@vger.kernel.org, netfs@lists.linux.dev, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, Tom Talpey Subject: [PATCH v3 08/12] cifs: Clean up some places where an extra kvec[] was required for rfc1002 Date: Sun, 23 Nov 2025 23:52:35 +0000 Message-ID: <20251123235242.3361706-9-dhowells@redhat.com> In-Reply-To: <20251123235242.3361706-1-dhowells@redhat.com> References: <20251123235242.3361706-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.93 Content-Type: text/plain; charset="utf-8" Clean up some places where previously an extra element in the kvec array was being used to hold an rfc1002 header for SMB1 (a previous patch removed this and generated it on the fly as for SMB2/3). Signed-off-by: David Howells cc: Steve French cc: Paulo Alcantara cc: Shyam Prasad N cc: Tom Talpey cc: linux-cifs@vger.kernel.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org --- fs/smb/client/cifsencrypt.c | 52 ++++++++--------------------------- fs/smb/client/cifsproto.h | 5 ---- fs/smb/client/cifstransport.c | 20 ++------------ fs/smb/client/smb1ops.c | 12 +++++--- fs/smb/client/transport.c | 25 +++++++++-------- 5 files changed, 35 insertions(+), 79 deletions(-) diff --git a/fs/smb/client/cifsencrypt.c b/fs/smb/client/cifsencrypt.c index 1e0ac87c6686..a9a57904c6b1 100644 --- a/fs/smb/client/cifsencrypt.c +++ b/fs/smb/client/cifsencrypt.c @@ -86,26 +86,21 @@ static int cifs_sig_iter(const struct iov_iter *iter, s= ize_t maxsize, int __cifs_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *s= erver, char *signature, struct cifs_calc_sig_ctx *ctx) { - int i; + struct iov_iter iter; ssize_t rc; - struct kvec *iov =3D rqst->rq_iov; - int n_vec =3D rqst->rq_nvec; + size_t size =3D 0; =20 - for (i =3D 0; i < n_vec; i++) { - if (iov[i].iov_len =3D=3D 0) - continue; - if (iov[i].iov_base =3D=3D NULL) { - cifs_dbg(VFS, "null iovec entry\n"); - return -EIO; - } + for (int i =3D 0; i < rqst->rq_nvec; i++) + size +=3D rqst->rq_iov[i].iov_len; =20 - rc =3D cifs_sig_update(ctx, iov[i].iov_base, iov[i].iov_len); - if (rc) { - cifs_dbg(VFS, "%s: Could not update with payload\n", - __func__); - return rc; - } - } + iov_iter_kvec(&iter, ITER_SOURCE, rqst->rq_iov, rqst->rq_nvec, size); + + if (iov_iter_count(&iter) <=3D 4) + return -EIO; + + rc =3D cifs_sig_iter(&iter, iov_iter_count(&iter), ctx); + if (rc < 0) + return rc; =20 rc =3D cifs_sig_iter(&rqst->rq_iter, iov_iter_count(&rqst->rq_iter), ctx); if (rc < 0) @@ -186,29 +181,6 @@ int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_S= erver_Info *server, return rc; } =20 -int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *se= rver, - __u32 *pexpected_response_sequence) -{ - struct smb_rqst rqst =3D { .rq_iov =3D iov, - .rq_nvec =3D n_vec }; - - return cifs_sign_rqst(&rqst, server, pexpected_response_sequence); -} - -/* must be called with server->srv_mutex held */ -int cifs_sign_smb(struct smb_hdr *cifs_pdu, unsigned int pdu_len, - struct TCP_Server_Info *server, - __u32 *pexpected_response_sequence_number) -{ - struct kvec iov[1] =3D { - [0].iov_base =3D (char *)cifs_pdu, - [0].iov_len =3D pdu_len, - }; - - return cifs_sign_smbv(iov, ARRAY_SIZE(iov), server, - pexpected_response_sequence_number); -} - int cifs_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, __u32 expected_sequence_number) diff --git a/fs/smb/client/cifsproto.h b/fs/smb/client/cifsproto.h index 4062be626d8e..8d9afd0df590 100644 --- a/fs/smb/client/cifsproto.h +++ b/fs/smb/client/cifsproto.h @@ -67,11 +67,6 @@ int __cifs_calc_signature(struct smb_rqst *rqst, struct = TCP_Server_Info *server, char *signature, struct cifs_calc_sig_ctx *ctx); int cifs_sign_rqst(struct smb_rqst *rqst, struct TCP_Server_Info *server, __u32 *pexpected_response_sequence_number); -int cifs_sign_smbv(struct kvec *iov, int n_vec, struct TCP_Server_Info *se= rver, - __u32 *pexpected_response_sequence); -int cifs_sign_smb(struct smb_hdr *cifs_pdu, unsigned int pdu_len, - struct TCP_Server_Info *server, - __u32 *pexpected_response_sequence_number); int cifs_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server, __u32 expected_sequence_number); diff --git a/fs/smb/client/cifstransport.c b/fs/smb/client/cifstransport.c index 1a0b80fc97d4..6fa60de786e9 100644 --- a/fs/smb/client/cifstransport.c +++ b/fs/smb/client/cifstransport.c @@ -71,22 +71,6 @@ alloc_mid(const struct smb_hdr *smb_buffer, struct TCP_S= erver_Info *server) return smb; } =20 -int -smb_send(struct TCP_Server_Info *server, struct smb_hdr *smb_buffer, - unsigned int smb_buf_length) -{ - struct kvec iov[1] =3D { - [0].iov_base =3D smb_buffer, - [0].iov_len =3D smb_buf_length, - }; - struct smb_rqst rqst =3D { - .rq_iov =3D iov, - .rq_nvec =3D ARRAY_SIZE(iov), - }; - - return __smb_send_rqst(server, 1, &rqst); -} - static int allocate_mid(struct cifs_ses *ses, struct smb_hdr *in_buf, struct smb_message **ppmidQ) { @@ -370,7 +354,7 @@ int SendReceiveBlockingLock(const unsigned int xid, str= uct cifs_tcon *tcon, return rc; } =20 - rc =3D cifs_sign_smb(in_buf, in_len, server, &smb->sequence_number); + rc =3D cifs_sign_rqst(&rqst, server, &smb->sequence_number); if (rc) { delete_mid(smb); cifs_server_unlock(server); @@ -378,7 +362,7 @@ int SendReceiveBlockingLock(const unsigned int xid, str= uct cifs_tcon *tcon, } =20 smb->mid_state =3D MID_REQUEST_SUBMITTED; - rc =3D smb_send(server, in_buf, in_len); + rc =3D __smb_send_rqst(server, 1, &rqst); cifs_save_when_sent(smb); =20 if (rc < 0) diff --git a/fs/smb/client/smb1ops.c b/fs/smb/client/smb1ops.c index 91205685057c..6b0d0b511b9f 100644 --- a/fs/smb/client/smb1ops.c +++ b/fs/smb/client/smb1ops.c @@ -34,17 +34,21 @@ static int send_nt_cancel(struct TCP_Server_Info *server, struct smb_rqst *rqst, struct smb_message *smb) { - int rc =3D 0; struct smb_hdr *in_buf =3D (struct smb_hdr *)rqst->rq_iov[0].iov_base; - unsigned int in_len =3D rqst->rq_iov[0].iov_len; + struct kvec iov[1]; + struct smb_rqst crqst =3D { .rq_iov =3D iov, .rq_nvec =3D 1 }; + int rc =3D 0; =20 /* +2 for BCC field */ in_buf->Command =3D SMB_COM_NT_CANCEL; in_buf->WordCount =3D 0; put_bcc(0, in_buf); =20 + iov[0].iov_base =3D in_buf; + iov[0].iov_len =3D sizeof(struct smb_hdr) + 2; + cifs_server_lock(server); - rc =3D cifs_sign_smb(in_buf, in_len, server, &smb->sequence_number); + rc =3D cifs_sign_rqst(&crqst, server, &smb->sequence_number); if (rc) { cifs_server_unlock(server); return rc; @@ -56,7 +60,7 @@ send_nt_cancel(struct TCP_Server_Info *server, struct smb= _rqst *rqst, * after signing here. */ --server->sequence_number; - rc =3D smb_send(server, in_buf, in_len); + rc =3D __smb_send_rqst(server, 1, &crqst); if (rc < 0) server->sequence_number--; =20 diff --git a/fs/smb/client/transport.c b/fs/smb/client/transport.c index 2e338e186809..c023c9873c88 100644 --- a/fs/smb/client/transport.c +++ b/fs/smb/client/transport.c @@ -1043,22 +1043,23 @@ compound_send_recv(const unsigned int xid, struct c= ifs_ses *ses, goto out; } =20 - buf =3D (char *)smb[i]->resp_buf; - resp_iov[i].iov_base =3D buf; - resp_iov[i].iov_len =3D smb[i]->resp_buf_size; - - if (smb[i]->large_buf) - resp_buf_type[i] =3D CIFS_LARGE_BUFFER; - else - resp_buf_type[i] =3D CIFS_SMALL_BUFFER; - rc =3D server->ops->check_receive(smb[i], server, flags & CIFS_LOG_ERROR); =20 - /* mark it so buf will not be freed by delete_mid */ - if ((flags & CIFS_NO_RSP_BUF) =3D=3D 0) - smb[i]->resp_buf =3D NULL; + if (resp_iov) { + buf =3D (char *)smb[i]->resp_buf; + resp_iov[i].iov_base =3D buf; + resp_iov[i].iov_len =3D smb[i]->resp_buf_size; =20 + if (smb[i]->large_buf) + resp_buf_type[i] =3D CIFS_LARGE_BUFFER; + else + resp_buf_type[i] =3D CIFS_SMALL_BUFFER; + + /* mark it so buf will not be freed by delete_mid */ + if ((flags & CIFS_NO_RSP_BUF) =3D=3D 0) + smb[i]->resp_buf =3D NULL; + } } =20 /*