Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp181271rdb; Thu, 21 Dec 2023 06:24:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IFSSWNmPPv52X8qDtU6lYkIwOkOVGRXWN5cs4mtc9sh/dQYBD9Kjyji5PTW2W/NQPDUrqj6 X-Received: by 2002:a05:6512:158e:b0:50e:4e72:3bd8 with SMTP id bp14-20020a056512158e00b0050e4e723bd8mr1257374lfb.199.1703168653779; Thu, 21 Dec 2023 06:24:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703168653; cv=none; d=google.com; s=arc-20160816; b=f6k6Hi2F5qzvfpUg8tXk0+7MqcO8fDgr3+WabMUk6vUgYwJ3COP3G0Udfd/KWzGoy8 p4b49y4jgtVtCYuMqzaJWlreqE/SCwEgHyaqI8LyLTrhncZ1G8UwXk2YX0kY6mTr4eTp Dgd1JhFggf4a8Mf0Cjow7DWt0ekN96IaAqKVSYgRQ7vH9xozN7EK04st3mgblYSPtzQ9 kxUv1jKQPqlSWKcgYvA0WHWQXuBvJy0znU8NIxFD+q1v1EQchBMsDU1RIFy4YT0oYgDI 4XxPg62YVkg2lUm8FWkBl2NDfOIl2ImXcT3g0J2z4CYm4HdI97ncZoQJsRAbyQa+Ojpv 5jlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:content-transfer-encoding:content-id:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:subject:cc:to :from:organization:dkim-signature; bh=TW/reE9xPc0IHxJZcKvgnG2qRH9ttpPMFz80v6EmDTg=; fh=S2R8GVI1IIO8qKyDfVy6H2tIX7eiH+KhKS6XKmPiX/0=; b=UGqaG+NGHXyCSY3LOPUmWe3tGNVZZTZbAn82+CLJdlcOgeTOFJnHSZDz6zlLRa9R8q cQg1Me8AXN/p3zp5X/Zd1K+DoExYViVZVvmuENuy7frVnydwutq3rSwODuiBpkMUOodM 9SO14I7/xq0U4swkrmBQh0pqYWVdM/nUAiiCZTEIvfUEKod0Tq0h8u5Ytcr7YpEzSn/q /gSp7msNmXsllNw3l9sJFGXGFeeYylqS8M5vTa5ZTSKjca4N5XjR5IIc2HUCvbzTFwu/ /6VfZraH3V6Lj36F1fGuO4fXu9L0/NcEOOq5BHpnIX8khWgGJXFHjMsoiONUnJKDOfgV h2+g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JHPABv/z"; spf=pass (google.com: domain of linux-kernel+bounces-8565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8565-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k6-20020a170906680600b00a2331cfc960si849452ejr.653.2023.12.21.06.24.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Dec 2023 06:24:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-8565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="JHPABv/z"; spf=pass (google.com: domain of linux-kernel+bounces-8565-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-8565-linux.lists.archive=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 8265D1F22094 for ; Thu, 21 Dec 2023 14:24:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5C78736084; Thu, 21 Dec 2023 14:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="JHPABv/z" X-Original-To: linux-kernel@vger.kernel.org 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 817006D6F2 for ; Thu, 21 Dec 2023 14:24:02 +0000 (UTC) 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=1703168641; 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: content-transfer-encoding:content-transfer-encoding; bh=TW/reE9xPc0IHxJZcKvgnG2qRH9ttpPMFz80v6EmDTg=; b=JHPABv/zyo5lbHovFzdXwhDDSaejD76wKkk/mZKGhGBWaURdnEuHUnoXgTcy0u7nqdLMwY My7yfWO89uQakwshfuy8PkxgOi3FcFJjY+at+ZyqDhQYioHdaQhy1bLEOpUx65F/5+6nBt ODPhnVrbdoqLS0yAYF5w7DPyJGdg7Sw= 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-374-zQG30YRBP3awbjWww4paEA-1; Thu, 21 Dec 2023 09:23:55 -0500 X-MC-Unique: zQG30YRBP3awbjWww4paEA-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (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 00113101A555; Thu, 21 Dec 2023 14:23:55 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.39.195.169]) by smtp.corp.redhat.com (Postfix) with ESMTP id 48543492BC6; Thu, 21 Dec 2023 14:23:53 +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 To: Anastasia Belova , Marc Dionne cc: dhowells@redhat.com, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org Subject: [PATCH] afs: Fix overwriting of result of DNS query Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1700861.1703168632.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Thu, 21 Dec 2023 14:23:52 +0000 Message-ID: <1700862.1703168632@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 In afs_update_cell(), ret is the result of the DNS lookup and the errors are to be handled by a switch - however, the value gets clobbered in between by setting it to -ENOMEM in case afs_alloc_vlserver_list() fails. Fix this by moving the setting of -ENOMEM into the error handling for OOM failure. Further, only do it if we don't have an alternative error to return. Found by Linux Verification Center (linuxtesting.org) with SVACE. Based o= n a patch from Anastasia Belova[1]. Fixes: d5c32c89b208 ("afs: Fix cell DNS lookup") Signed-off-by: David Howells cc: Anastasia Belova cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: lvc-project@linuxtesting.org Link: https://lore.kernel.org/r/20231221085849.1463-1-abelova@astralinux.r= u/ [1] --- fs/afs/cell.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/afs/cell.c b/fs/afs/cell.c index 988c2ac7cece..926cb1188eba 100644 --- a/fs/afs/cell.c +++ b/fs/afs/cell.c @@ -409,10 +409,12 @@ static int afs_update_cell(struct afs_cell *cell) if (ret =3D=3D -ENOMEM) goto out_wake; = - ret =3D -ENOMEM; vllist =3D afs_alloc_vlserver_list(0); - if (!vllist) + if (!vllist) { + if (ret >=3D 0) + ret =3D -ENOMEM; goto out_wake; + } = switch (ret) { case -ENODATA: