Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4255073rdb; Mon, 11 Dec 2023 13:33:23 -0800 (PST) X-Google-Smtp-Source: AGHT+IFgqbepFAy6+rQIXy3FVqi9txI92V5buCoLks3c1ofz6LeUxI3yo5azgy3EqzfG920P8i4A X-Received: by 2002:a05:6a21:a589:b0:18f:d827:bcf9 with SMTP id gd9-20020a056a21a58900b0018fd827bcf9mr7502870pzc.80.1702330402975; Mon, 11 Dec 2023 13:33:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702330402; cv=none; d=google.com; s=arc-20160816; b=pDhklvhEiofAxqEJoHDe6dsShB+fWHNB+Zq86hRRZ0SbLVd6BMPXJwRggNIZOcjwx5 wCFFeN5uW8zRy9dowiP9d/FCdai9+pgBk3VJag/2ANVlLQ2krGhXTyIT+VWf5mrWMHz/ L9VvTmOjRWIOpU35I2hXRyGg6SiDpcnmiqxIxAjhfQ/cCJDyvMQvbBtdBph8idW1Gves VKAp2rEqGTrPl6xj69AE5+2IjlK6X0yVG7tEYaq+G1rz9IBJEXRucWc43bAJr9m5jLRA R+Wj4eBAnNwESXbJ1iJdrQWYuX+WWgKt/4ayxPYcQ6IgfextnoHuF8dFRn7kKoS7DIjB de2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/T6yVZIIW8gaOaFWvjKuKFf94e1s7X/v7fENW4wrGt4=; fh=amlZE/0bmUZb0iruJSnjcNGDWpcpLgWng4o3VdOIeS8=; b=QZ2uxDie0j5Ik/4EBUFsAMbuNTTSA9TSF6rd3/viUtDPtsIkcsLWo28zaYFjm32WJy 5Y7BFMw7PL4e8kl3kRr2/hN+1151z0fqrmB0gJKxMSxeD/LzlhbHAKJ1e4mktDjDx8LM DuR9VlJ7FQiFYDuqFK+HdLh1dw0Y3Wr3ijQ+anMBuyrtsXrzS7D81VjKs3hxkKzj7ZpU cWPwoR8tJ6EsVOtjArD8JwgYV1vl1CysCUfvpQW2Ro3/SlUs966wOthEwJnNdh3lMFgz dP9rySAhR9n5QXghT+hSuSHIEu/8+KMB9Relttax31V55ykKTwEsWmGCWZa4BwOiUkjN E9rQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hitp1wNO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id p24-20020aa78618000000b006ce544ed22csi6554451pfn.128.2023.12.11.13.33.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Dec 2023 13:33:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=hitp1wNO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 51B58805EB27; Mon, 11 Dec 2023 13:33:20 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345232AbjLKVcn (ORCPT + 99 others); Mon, 11 Dec 2023 16:32:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39968 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345233AbjLKVcl (ORCPT ); Mon, 11 Dec 2023 16:32:41 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15BE9D1 for ; Mon, 11 Dec 2023 13:32:48 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1702330367; 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=/T6yVZIIW8gaOaFWvjKuKFf94e1s7X/v7fENW4wrGt4=; b=hitp1wNOYZ6wTs7Z0ZnNn1B4ARK+04y7dMXOwEaZxFdy8uWqzjly83gcTk/M9ObWVAsZ6t rY0vFGnxt5eSUPt0wkVz4riugDBTIuGQEC6aVQ42cOhJI8CBsUcZO/8VQi52Ss5iyVM73j ux5hFiADNwlcZVJnGzGiNlEH7OKczGs= 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-498-6Zu9lM7qOvmBrHvBp8NfIA-1; Mon, 11 Dec 2023 16:32:40 -0500 X-MC-Unique: 6Zu9lM7qOvmBrHvBp8NfIA-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 3F2D4881C84; Mon, 11 Dec 2023 21:32:40 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.2]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3B0B62026D66; Mon, 11 Dec 2023 21:32:39 +0000 (UTC) From: David Howells To: Markus Suvanto , Marc Dionne Cc: David Howells , linux-afs@lists.infradead.org, keyrings@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] afs: Fix dynamic root lookup DNS check Date: Mon, 11 Dec 2023 21:32:32 +0000 Message-ID: <20231211213233.2793525-3-dhowells@redhat.com> In-Reply-To: <20231211213233.2793525-1-dhowells@redhat.com> References: <20231211213233.2793525-1-dhowells@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 11 Dec 2023 13:33:20 -0800 (PST) In the afs dynamic root directory, the ->lookup() function does a DNS check on the cell being asked for and if the DNS upcall reports an error it will report an error back to userspace (typically ENOENT). However, if a failed DNS upcall returns a new-style result, it will return a valid result, with the status field set appropriately to indicate the type of failure - and in that case, dns_query() doesn't return an error and we let stat() complete with no error - which can cause confusion in userspace as subsequent calls that trigger d_automount then fail with ENOENT. Fix this by checking the status result from a valid dns_query() and returning an error if it indicates a failure. Fixes: bbb4c4323a4d ("dns: Allow the dns resolver to retrieve a server set") Reported-by: Markus Suvanto Closes: https://bugzilla.kernel.org/show_bug.cgi?id=216637 Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- Notes: Changes ======= ver #2) - Fix signed-unsigned comparison when checking return val. fs/afs/dynroot.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c index 34474a061654..1f656005018e 100644 --- a/fs/afs/dynroot.c +++ b/fs/afs/dynroot.c @@ -114,6 +114,7 @@ static int afs_probe_cell_name(struct dentry *dentry) struct afs_net *net = afs_d2net(dentry); const char *name = dentry->d_name.name; size_t len = dentry->d_name.len; + char *result = NULL; int ret; /* Names prefixed with a dot are R/W mounts. */ @@ -131,9 +132,22 @@ static int afs_probe_cell_name(struct dentry *dentry) } ret = dns_query(net->net, "afsdb", name, len, "srv=1", - NULL, NULL, false); - if (ret == -ENODATA || ret == -ENOKEY) + &result, NULL, false); + if (ret == -ENODATA || ret == -ENOKEY || ret == 0) ret = -ENOENT; + if (ret > 0 && ret >= sizeof(struct dns_server_list_v1_header)) { + struct dns_server_list_v1_header *v1 = (void *)result; + + if (v1->hdr.zero == 0 && + v1->hdr.content == DNS_PAYLOAD_IS_SERVER_LIST && + v1->hdr.version == 1 && + (v1->status != DNS_LOOKUP_GOOD && + v1->status != DNS_LOOKUP_GOOD_WITH_BAD)) + return -ENOENT; + + } + + kfree(result); return ret; }