Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 F04C32D23B6 for ; Tue, 24 Jun 2025 14:22:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750774979; cv=none; b=QO+nJg23vXgj7RJHe14/385m84UUc3y7jq4d1vuPcG4LuKOLKvcP+OUObsj2xsYr6nNhgYKmbvBsmOL3LPqyaKKQOVfoAen5Tgw4YhJrZHLZagMd/4ii6s1pyDk8/cAGZHP4txVmVFhb5dAUBse2kXgSp2bJUB906qRyQ5Kfo9c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1750774979; c=relaxed/simple; bh=DyGsBcB6vv3h1JsbgAkV+Dgc9KpOte+BK0rILkrHnu4=; h=From:In-Reply-To:References:To:Cc:Subject:MIME-Version: Content-Type:Date:Message-ID; b=F1fxnfpL4nxe0aU3f9jN8UdN1yuvfNfovd6PAbE07hFSXwEgwFPa3R7jDm4iw9pCUsF5vV/4xyzT4RSnHgvd8ZHhP9KrRnil4mU6unyqKv2YJN4WfwNj1zybm7WL/qVvoRpZQpMzYkGcqim/91bljvErtJ99qcZLxIKzew9F+Es= 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=H5dK+WWx; arc=none smtp.client-ip=170.10.133.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="H5dK+WWx" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1750774976; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Su4dK6eziUeWtnT2n4zYWHb6UwxoSMzl876+vyWG0NY=; b=H5dK+WWxDxwoXtmqPy3WVDQHipC2b9BedlBrdH86NRM2nsPCrIMr0JqRtbVpAG1kxuRX39 iQm4MokNzV4LPc8Wem5PVAIo5a+vrg4uX820nPfwp67YkZa94WL3BEkvQ1UtMEv7lKpIyR w/iDqmfgk0W6koNMO5uOfbAhKQNt2aE= Received: from mx-prod-mc-04.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-316-fMlWeTagONaZYJyOFC7J2Q-1; Tue, 24 Jun 2025 10:22:55 -0400 X-MC-Unique: fMlWeTagONaZYJyOFC7J2Q-1 X-Mimecast-MFC-AGG-ID: fMlWeTagONaZYJyOFC7J2Q_1750774974 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 60C8719560B3; Tue, 24 Jun 2025 14:22:54 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.81]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 94E4530001A1; Tue, 24 Jun 2025 14:22:52 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells In-Reply-To: References: <1107690.1750683895@warthog.procyon.org.uk> To: Stefan Metzmacher Cc: dhowells@redhat.com, "linux-cifs@vger.kernel.org" , netfs@lists.linux.dev, linux-fsdevel , Steve French Subject: Re: [PATCH] cifs: Collapse smbd_recv_*() into smbd_recv() and just use copy_to_iter() Precedence: bulk X-Mailing-List: netfs@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1156126.1750774971.1@warthog.procyon.org.uk> Date: Tue, 24 Jun 2025 15:22:51 +0100 Message-ID: <1156127.1750774971@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 Stefan Metzmacher wrote: > > read_rfc1002_done: > > + /* SMBDirect will read it all or nothing */ > > + msg->msg_iter.count = 0; > > And this iov_iter_truncate(0); Actually, it should probably have been iov_iter_advance(). > While I'm wondering why we had this at all. > > It seems all callers of cifs_read_iter_from_socket() > don't care and the code path via sock_recvmsg() doesn't > truncate it just calls copy_to_iter() via this chain: > ->inet_recvmsg->tcp_recvmsg->skb_copy_datagram_msg->skb_copy_datagram_iter > ->simple_copy_to_iter->copy_to_iter() > > I think the old code should have called > iov_iter_advance(rc) instead of msg->msg_iter.count = 0. > > But the new code doesn't need it as copy_to_iter() > calls iterate_and_advance(). Yeah, it should. I seem to remember that there were situations in which it didn't, but it's possible I managed to get rid of them. > > - default: > > - /* It's a bug in upper layer to get there */ > > - cifs_dbg(VFS, "Invalid msg type %d\n", > > - iov_iter_type(&msg->msg_iter)); > > - rc = -EINVAL; > > - } > > I guess this is actually a real fix as I just saw > CIFS: VFS: Invalid msg type 4 > in logs while running the cifs/001 test. > And 4 is ITER_FOLIOQ. Ah... Were you using "-o seal"? The encrypted data is held in a buffer formed from a folioq with a series of folios in it. David