From patchwork Fri Nov 18 11:41:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denis Arefev X-Patchwork-Id: 22286 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp143745wrr; Fri, 18 Nov 2022 03:47:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5DiuUgPBNSG+DOTpkpf3eoZVeC+YrvSRB446W2KgiBuD642To6k9kysrSYJpiBwTI7OYCu X-Received: by 2002:a17:906:706:b0:7ac:2e16:eb05 with SMTP id y6-20020a170906070600b007ac2e16eb05mr5949481ejb.26.1668772055996; Fri, 18 Nov 2022 03:47:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668772055; cv=none; d=google.com; s=arc-20160816; b=cI1vLVs9m2RrfyuiFSMTIWgKp8Ml9hZ4WxfMr+vYnBbwegW1Bq4T961Iu8pIkxelqK StJxhxQFYzD8bz77BxiAtpVBIliQYy4RBgvgYwLBsrtaDlY4XGjLDEvT8X2E2pLeOnpi 31IJTxNSq49rhvvkxvZImTHAw6s0XETY+3vPqFloa0rml6TwFT/qquFoLr5lz6XonFMk vbU1PV5NEnLY74Fyyw4z+DefWCq09Gy3sYpuNLo2Jr1+iqW5I0NneEkkXFgUtkzO0tOG p7dDSpFl3lSDXEy4Q9UJTs7VwDQu3j8qS1P6uXy/mpkgjnIZnN8NNJYHpXFzzechoXx3 PxAQ== 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 :message-id:date:subject:cc:to:dkim-signature:from; bh=SSD/8D3oxjxNO6XFSWDffwRmka85Uk/caIyP96y7PQk=; b=V8yLy3QI7+0KGYYeK4MPUp/c3zx5WiO52Xd+hzwtLOAvF3jp8BxKVzqGEGerV6zHFs 30nBiNOBteQH0/SGrLXgGH5h27sLhpkW4nYPpQB8JPBNRu8/Q8mxJdLCzFd7HIjb7gHc omEiHP57jJe8B08Cdkjvf8mrTg60eMekIwiQI7hfpcBZ7060PB78ZpFpqAeZrf1adMim 3PJObFaf7//Arv8MCVL8B7dFdtNv9XPsUDROimajNwpBST3szEZkO+z+/yWaMRrIx0xp 2BNdfilBLyzsqedzNdfcfad2CQeIqDA2nPjrBrvHu2MXr60XOwqP6uXNp1mmjNSjq5AD 90LA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b="cl/J/kRe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z6-20020a056402274600b004488842d88esi3286395edd.13.2022.11.18.03.47.09; Fri, 18 Nov 2022 03:47:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@swemel.ru header.s=mail header.b="cl/J/kRe"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=swemel.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241423AbiKRLll (ORCPT + 99 others); Fri, 18 Nov 2022 06:41:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43338 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241100AbiKRLlk (ORCPT ); Fri, 18 Nov 2022 06:41:40 -0500 Received: from mx.swemel.ru (mx.swemel.ru [95.143.211.150]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA5E717430; Fri, 18 Nov 2022 03:41:39 -0800 (PST) From: Denis Arefev DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=swemel.ru; s=mail; t=1668771697; 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; bh=SSD/8D3oxjxNO6XFSWDffwRmka85Uk/caIyP96y7PQk=; b=cl/J/kReOmnmtGqxIEY9x/uDHsYTje/wJhEd5YDc6K8CwBGEj6LD9pzQZbOjoQCGEsGRWi f7IiCj8XHMiEEILyZt+68o7mpukiEW3cdmLUUyrAGKQ+J0spkkstvwBxUXB1ayhgGbXcWd wJKEmJcdgQMEgL1iCzw6hT+PZh41Gd4= To: Alexander Viro Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, trufanov@swemel.ru, vfh@swemel.ru Subject: [PATCH v2] namespace: Added pointer check in copy_mnt_ns() Date: Fri, 18 Nov 2022 14:41:37 +0300 Message-Id: <20221118114137.128088-1-arefev@swemel.ru> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749834327191504413?= X-GMAIL-MSGID: =?utf-8?q?1749834327191504413?= Return value of a function 'next_mnt' is dereferenced at namespace.c:3377 without checking for null, but it is usually checked for this function Found by Linux Verification Center (linuxtesting.org) with SVACE. Signed-off-by: Denis Arefev --- fs/namespace.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fs/namespace.c b/fs/namespace.c index cebaa3e81794..06472a110257 100644 --- a/fs/namespace.c +++ b/fs/namespace.c @@ -3348,9 +3348,9 @@ struct mnt_namespace *copy_mnt_ns(unsigned long flags, struct mnt_namespace *ns, } p = next_mnt(p, old); q = next_mnt(q, new); - if (!q) + if (!q || !p) break; - while (p->mnt.mnt_root != q->mnt.mnt_root) + while (p && (p->mnt.mnt_root != q->mnt.mnt_root)) p = next_mnt(p, old); } namespace_unlock();