[PATCH 1/3] afs: Also search ipv4 address list in afs_find_server

Jeffrey E Altman jaltman at auristor.com
Fri Feb 16 12:41:52 PST 2024


On 2/16/2024 2:37 PM, Marc Dionne wrote:
> When searching for a matching peer, look in fs_addresses4 list rather
> than the fs_addresses6 list if the peer address is v4.
>
> When processing an incoming callback from an ipv4 address, this would
> lead to a failure to set call->server, resulting in the callback being
> ignored and the client seeing stale contents.
>
> Fixes: 72904d7b9bfb ("rxrpc, afs: Allow afs to pin rxrpc_peer objects")
> Reported-by: Markus Suvanto <markus.suvanto at gmail.com>
> Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008035.html
> Signed-off-by: Marc Dionne <marc.dionne at auristor.com>
> ---
>   fs/afs/server.c | 22 ++++++++++++++++------
>   1 file changed, 16 insertions(+), 6 deletions(-)
>
> diff --git a/fs/afs/server.c b/fs/afs/server.c
> index e169121f603e..ff79d1761a84 100644
> --- a/fs/afs/server.c
> +++ b/fs/afs/server.c
> @@ -38,12 +38,22 @@ struct afs_server *afs_find_server(struct afs_net *net, const struct rxrpc_peer
>   		seq++; /* 2 on the 1st/lockless path, otherwise odd */
>   		read_seqbegin_or_lock(&net->fs_addr_lock, &seq);
>   
> -		hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
> -			estate = rcu_dereference(server->endpoint_state);
> -			alist = estate->addresses;
> -			for (i = 0; i < alist->nr_addrs; i++)
> -				if (alist->addrs[i].peer == peer)
> -					goto found;
> +		if (peer->src->transport.family == AF_INET6) {
> +			hlist_for_each_entry_rcu(server, &net->fs_addresses6, addr6_link) {
> +				estate = rcu_dereference(server->endpoint_state);
> +				alist = estate->addresses;
> +				for (i = 0; i < alist->nr_addrs; i++)
> +					if (alist->addrs[i].peer == peer)
> +						goto found;
> +			}
> +		} else {
> +			hlist_for_each_entry_rcu(server, &net->fs_addresses4, addr4_link) {
> +				estate = rcu_dereference(server->endpoint_state);
> +				alist = estate->addresses;
> +				for (i = 0; i < alist->nr_addrs; i++)
> +					if (alist->addrs[i].peer == peer)
> +						goto found;
> +			}
>   		}
>   
>   		server = NULL;

Reviewed-by: Jeffrey E Altman <jaltman at auristor.com>

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 4039 bytes
Desc: S/MIME Cryptographic Signature
URL: <http://lists.infradead.org/pipermail/linux-afs/attachments/20240216/6e16a1d8/attachment.p7s>


More information about the linux-afs mailing list