From patchwork Mon Feb 19 14:39:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 203132 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1326726dyc; Mon, 19 Feb 2024 06:42:05 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVJ04XWvKXN+mINBxWQlDeJ2nbZnw9sUnOHPnpyQPs/ZhvdRVAs8eoG67KKe4MMyjQ/iLGhFj6mOzXFagaMx7p6uraMdw== X-Google-Smtp-Source: AGHT+IEqItV1BIepbOCo9nKSFukplGyuGeyTLmWdMK2Kd0d8TUXxELg27peueMJemL5YVPm4p9rf X-Received: by 2002:a17:90b:164e:b0:299:6b93:9d94 with SMTP id il14-20020a17090b164e00b002996b939d94mr2564191pjb.25.1708353725281; Mon, 19 Feb 2024 06:42:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708353725; cv=pass; d=google.com; s=arc-20160816; b=ZrqZjTb3Ph6kZYp/Twyz2xDLJF5qU4qH5HUmqHxkvR6kni38cYVrPAZLXr1E6Z227R JpDW3bZv6wm/29K8UW19YYVkeZFaZIzK5UCdOLND5k6hcxEpUB5WoI+tGZfZ53wD51h+ 3dsj5zTWMVDFkU1XCD6TsJMi5NN+DwU4batDAyFQzh3x6kuq1TQkoPetBkazp10Td2++ ppAK6o5GJZQU6qnpJmZGWBNl/R3Q84PzLU9kqUc1mkCwwsG82i2ibPhpXr9K1nM6EJXJ hIl6NF8IlEQ8tbKeGys8kb/LHq2RJEd5xiKHhhj6MuvFCQskF0YharbbEP8wykD9/Upy J7TQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=61Y1ryM8fe/JjxMt1H4crmRFgXy4y3uGTZZvyqUo4+c=; fh=Dvz1EOh7uOnJt5G9mXlPZHb3QMg5AAHTfNSqCpvI5zU=; b=CURDZbzYuo3WmT14WFqcVs39ukARkh4Z37vBt2y7+DaoeK/BTpZByIk1VUNF3XSHlM YPFsGPun2tIh85Sb06kjjePvfES6oYu4exD/09wBJmiSFWo9yLobjbX5rkgTBL2N8ogt 2aHLacquwY4yrI3We5qCG3wcPckceqePJn3XFz7RYdPV0CpNq7nqA6ipUOJnwQt0RA5f cTbgYM8zw1g16yvjcijpS1+msfh1liRs+IPMgy8dMHdsuuc+NLFEj6kXXjqt76SsrIRS hNXi1ZIeRMv/ZoDGGgO8IAHGyCoIz0YLeht+J+6FM6w5yTBzadmd4yA0j9UuTm/jOw2d N0ag==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1MHCbff; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71493-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id cl20-20020a17090af69400b002963d0fe262si4596729pjb.77.2024.02.19.06.42.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 06:42:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=Q1MHCbff; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71493-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71493-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2CE2DB22F87 for ; Mon, 19 Feb 2024 14:40:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D0F20383A1; Mon, 19 Feb 2024 14:39:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Q1MHCbff" 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 06E2B2EB10 for ; Mon, 19 Feb 2024 14:39:17 +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=1708353559; cv=none; b=VX0DhGetCECdfcqfzoNzCbQdjfv7KsnIsa7zCjySMJphqDLgDjSF7zmM1Jkcb6/ydduTA2YdhgHZ85qHxBvscG7deQ/xtypNUkxs+cszfNk2eM1psGvxKB6yZ2FkHFHG8S0WrC/ZGKR0AkmdqLYDLl6OYPj/WzDhj8Ccq4dSm0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708353559; c=relaxed/simple; bh=FQW538CkhbCyOjNCq4Mt7YkUrwTilVq9pXAfhbPQhsU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KoJaT/R5Wx57P4LuVeGVx72sJifttFQmbGkiqF0IyUnmHNXQHlHwJEOSvfot7JuJCGN95AepmTLvT3Fv4poSNJ7N1wrGz0FKY1hWRm9BQPBLGs3lebs0WHWDLBnZ2lMIGOUkOFGByM4cSDjyRHSZhgAOZaDnDCnGzgbVPQmTiCk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=Q1MHCbff; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708353556; 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=61Y1ryM8fe/JjxMt1H4crmRFgXy4y3uGTZZvyqUo4+c=; b=Q1MHCbffLzlGFRnbuFillkeu/3UTiwhU0Be8ffLcRFizn0vyAXGp0VeyhubsbVyzkWBMB4 zUP+ZNVKt1uMkPu2d12dIJDGYzC04VLJYAS0Z+Aad3Nx03BCv14NUYSuB9m4Wk89sCiMvg 0EBs65fv106TTBEoE7ZCeD6VR5lU0/A= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-207-4PV-VDJjOEmvnI60OKUorA-1; Mon, 19 Feb 2024 09:39:11 -0500 X-MC-Unique: 4PV-VDJjOEmvnI60OKUorA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 09E933C0ED57; Mon, 19 Feb 2024 14:39:11 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id 030D71C060B2; Mon, 19 Feb 2024 14:39:09 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Markus Suvanto , Marc Dionne , Daniil Dulov , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] afs: Fix ignored callbacks over ipv4 Date: Mon, 19 Feb 2024 14:39:02 +0000 Message-ID: <20240219143906.138346-2-dhowells@redhat.com> In-Reply-To: <20240219143906.138346-1-dhowells@redhat.com> References: <20240219143906.138346-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791338715891453236 X-GMAIL-MSGID: 1791338715891453236 From: Marc Dionne When searching for a matching peer, all addresses need to be searched, not just the ipv6 ones in the fs_addresses6 list. Given that the lists no longer contain addresses, there is little reason to splitting things between separate lists, so unify them into a single list. 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 Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008035.html Signed-off-by: Marc Dionne Signed-off-by: David Howells Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008037.html # v1 Link: https://lists.infradead.org/pipermail/linux-afs/2024-February/008066.html # v2 --- fs/afs/internal.h | 6 ++---- fs/afs/main.c | 3 +-- fs/afs/server.c | 14 +++++--------- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/fs/afs/internal.h b/fs/afs/internal.h index 9c03fcf7ffaa..6ce5a612937c 100644 --- a/fs/afs/internal.h +++ b/fs/afs/internal.h @@ -321,8 +321,7 @@ struct afs_net { struct list_head fs_probe_slow; /* List of afs_server to probe at 5m intervals */ struct hlist_head fs_proc; /* procfs servers list */ - struct hlist_head fs_addresses4; /* afs_server (by lowest IPv4 addr) */ - struct hlist_head fs_addresses6; /* afs_server (by lowest IPv6 addr) */ + struct hlist_head fs_addresses; /* afs_server (by lowest IPv6 addr) */ seqlock_t fs_addr_lock; /* For fs_addresses[46] */ struct work_struct fs_manager; @@ -561,8 +560,7 @@ struct afs_server { struct afs_server __rcu *uuid_next; /* Next server with same UUID */ struct afs_server *uuid_prev; /* Previous server with same UUID */ struct list_head probe_link; /* Link in net->fs_probe_list */ - struct hlist_node addr4_link; /* Link in net->fs_addresses4 */ - struct hlist_node addr6_link; /* Link in net->fs_addresses6 */ + struct hlist_node addr_link; /* Link in net->fs_addresses6 */ struct hlist_node proc_link; /* Link in net->fs_proc */ struct list_head volumes; /* RCU list of afs_server_entry objects */ struct afs_server *gc_next; /* Next server in manager's list */ diff --git a/fs/afs/main.c b/fs/afs/main.c index 1b3bd21c168a..a14f6013e316 100644 --- a/fs/afs/main.c +++ b/fs/afs/main.c @@ -90,8 +90,7 @@ static int __net_init afs_net_init(struct net *net_ns) INIT_LIST_HEAD(&net->fs_probe_slow); INIT_HLIST_HEAD(&net->fs_proc); - INIT_HLIST_HEAD(&net->fs_addresses4); - INIT_HLIST_HEAD(&net->fs_addresses6); + INIT_HLIST_HEAD(&net->fs_addresses); seqlock_init(&net->fs_addr_lock); INIT_WORK(&net->fs_manager, afs_manage_servers); diff --git a/fs/afs/server.c b/fs/afs/server.c index e169121f603e..038f9d0ae3af 100644 --- a/fs/afs/server.c +++ b/fs/afs/server.c @@ -38,7 +38,7 @@ 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) { + hlist_for_each_entry_rcu(server, &net->fs_addresses, addr_link) { estate = rcu_dereference(server->endpoint_state); alist = estate->addresses; for (i = 0; i < alist->nr_addrs; i++) @@ -177,10 +177,8 @@ static struct afs_server *afs_install_server(struct afs_cell *cell, * bit, but anything we might want to do gets messy and memory * intensive. */ - if (alist->nr_ipv4 > 0) - hlist_add_head_rcu(&server->addr4_link, &net->fs_addresses4); - if (alist->nr_addrs > alist->nr_ipv4) - hlist_add_head_rcu(&server->addr6_link, &net->fs_addresses6); + if (alist->nr_addrs > 0) + hlist_add_head_rcu(&server->addr_link, &net->fs_addresses); write_sequnlock(&net->fs_addr_lock); @@ -511,10 +509,8 @@ static void afs_gc_servers(struct afs_net *net, struct afs_server *gc_list) list_del(&server->probe_link); hlist_del_rcu(&server->proc_link); - if (!hlist_unhashed(&server->addr4_link)) - hlist_del_rcu(&server->addr4_link); - if (!hlist_unhashed(&server->addr6_link)) - hlist_del_rcu(&server->addr6_link); + if (!hlist_unhashed(&server->addr_link)) + hlist_del_rcu(&server->addr_link); } write_sequnlock(&net->fs_lock); From patchwork Mon Feb 19 14:39:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 203131 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1326686dyc; Mon, 19 Feb 2024 06:42:00 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwOvUGds/pQC1nGJd9jXtvrZr1Xb+ylpuPRDTF0f7VBoJo+cQXI2aZrAngcccKVhkm2yF0LnGEac4j02yiINKoxVIjbw== X-Google-Smtp-Source: AGHT+IFEjO15xPEdMFgTGucypuhov7R8Zt+v98jhcPxQZuD9QDozDsykj8i3XTBgUwJwlhEFUP3q X-Received: by 2002:a05:6a21:3949:b0:19e:c304:cfae with SMTP id ac9-20020a056a21394900b0019ec304cfaemr13035361pzc.51.1708353720511; Mon, 19 Feb 2024 06:42:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708353720; cv=pass; d=google.com; s=arc-20160816; b=imD213uaNNcgyqx1KUH0d1H43HT2AK8MCOd4JalqwyYjQn1EzrS/R0ENvSFcM/tbcB ajWxAGdvNnF2PyYT/vFQGmGtuEfbxeGn03BQoRbAG1JSkEGV8EMnQw3a8g4bSaZbBK/R wWBmFpZHscG11nULoK4nmbhIJR5bJYi2DMzIao8xR+1REjIneUwxXRdnWDTjipyUPFZl yLtRMIee4NYmoAqQmBzhcvDthcvJneK/ZASe8pejXhETBv6OVE1/OD7HRdfn9z+B2235 Pkeirjjty9qcB7W9ESWyByVtwPGiO0+kgY3Vxahch1YS/kTHvVPcAMRgxwJeI8AFowHU 8yug== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2z5xVfPbtvAXi+poyaZjlxvFkPKDSd6KB5QNpLYkM5w=; fh=Dvz1EOh7uOnJt5G9mXlPZHb3QMg5AAHTfNSqCpvI5zU=; b=xEceul9eQPm9uVGeWLdwON7h7Ca9wst/uv8+u9VqgwwxNNjOWRKYteXnI+245geAQr LZXz0KPH2uBkzgfJibsZpU3goPWmOEUiwWhqAUSzsPv2ehlTWKgJfBdjnsX2lYa/mouJ Dt/9DBm8fvslZQ9eSzNqlQAiCPtBT424lo+rhuvOH1H3EVNZntFoBI1pzbNBjmql4D5p +vwowSHdIpuG/3EX3VRrTl8W+hbMr0tB+WaxOvVeJKfUOHzdzQXYuAWIgJQK0n1bzAng gRqASK0lpHffgyqW1TuIFg091X6+mEZM7ru2SDkBm3luyCT/FwQQzwmPozpRutVuFDKJ z1SA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FjOUuEko; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71494-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b20-20020a056a000a9400b006e0a2fe05fesi4655366pfl.125.2024.02.19.06.42.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 06:42:00 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=FjOUuEko; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-kernel+bounces-71494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71494-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 456C4B22EF8 for ; Mon, 19 Feb 2024 14:40:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8B86538394; Mon, 19 Feb 2024 14:39:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="FjOUuEko" 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 06DAF2E419 for ; Mon, 19 Feb 2024 14:39:17 +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=1708353559; cv=none; b=kTKr6UE7fAm26ZoMvSMgniACbYnVOElaiWQjgUbIuN9WKacjY6Wtz/4gGb/oBpoInLqfpRu2rwYbBLXKH4jku6oJo069Q+BJk2lg88H+fmbEd9FeDMVf/C1aJaT0EGen2EPU5AKyk3mv1j2hlZj1eDlx6d8oghwHgqqU9IgdKt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708353559; c=relaxed/simple; bh=q6i/qIM7No4B8p1Gsv1EcuGge0SWmBXroEjze9FrxRw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jXd40fYEi4dJo8RHwrz2u+d00s1V07XhEhO2ic3jsx5lQUa4vwYGy8cAnmOHOJU8lmuJdceSqk6/NBFQF8vom/3EMfVxQ+mUplsrTLoY/i0y3S18FqtHK2G2iaUV6M2FCVKEnf8OibiCyDUO2RzVpy6ta1U2+7KRDskocCPCjrI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none 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=FjOUuEko; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1708353557; 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=2z5xVfPbtvAXi+poyaZjlxvFkPKDSd6KB5QNpLYkM5w=; b=FjOUuEkoWuQyQkUNMdVgtIuZSAKNrbmuYhJNSo6TtT0aAmHFxGAgtniA8cMOB+IhRUzAF3 QsxS4YA8YGXDpMWDlS/B5w6T9AvaldxwTZM+/FRvY0RN5mkOJSQYleZguAp2q0hDj66sl9 jRYwAJ64e3OVNWNBZ/YJqsTczWEMrDM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-661-0a4mPoAgNBuqh-rfWblxlw-1; Mon, 19 Feb 2024 09:39:13 -0500 X-MC-Unique: 0a4mPoAgNBuqh-rfWblxlw-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A837C881B6C; Mon, 19 Feb 2024 14:39:12 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.15]) by smtp.corp.redhat.com (Postfix) with ESMTP id A03AA200B2D7; Mon, 19 Feb 2024 14:39:11 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Markus Suvanto , Marc Dionne , Daniil Dulov , linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] afs: Increase buffer size in afs_update_volume_status() Date: Mon, 19 Feb 2024 14:39:03 +0000 Message-ID: <20240219143906.138346-3-dhowells@redhat.com> In-Reply-To: <20240219143906.138346-1-dhowells@redhat.com> References: <20240219143906.138346-1-dhowells@redhat.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791338711169927767 X-GMAIL-MSGID: 1791338711169927767 From: Daniil Dulov The max length of volume->vid value is 20 characters. So increase idbuf[] size up to 24 to avoid overflow. Found by Linux Verification Center (linuxtesting.org) with SVACE. [DH: Actually, it's 20 + NUL, so increase it to 24 and use snprintf()] Fixes: d2ddc776a458 ("afs: Overhaul volume and server record caching and fileserver rotation") Signed-off-by: Daniil Dulov Signed-off-by: David Howells Link: https://lore.kernel.org/r/20240211150442.3416-1-d.dulov@aladdin.ru/ # v1 Link: https://lore.kernel.org/r/20240212083347.10742-1-d.dulov@aladdin.ru/ # v2 --- fs/afs/volume.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/afs/volume.c b/fs/afs/volume.c index 020ecd45e476..af3a3f57c1b3 100644 --- a/fs/afs/volume.c +++ b/fs/afs/volume.c @@ -353,7 +353,7 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) { struct afs_server_list *new, *old, *discard; struct afs_vldb_entry *vldb; - char idbuf[16]; + char idbuf[24]; int ret, idsz; _enter(""); @@ -361,7 +361,7 @@ static int afs_update_volume_status(struct afs_volume *volume, struct key *key) /* We look up an ID by passing it as a decimal string in the * operation's name parameter. */ - idsz = sprintf(idbuf, "%llu", volume->vid); + idsz = snprintf(idbuf, sizeof(idbuf), "%llu", volume->vid); vldb = afs_vl_lookup_vldb(volume->cell, key, idbuf, idsz); if (IS_ERR(vldb)) {