Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp465054pxb; Sat, 6 Mar 2021 05:41:36 -0800 (PST) X-Google-Smtp-Source: ABdhPJybHOGXQpxk4YyYhaLsOU6rjiRPlTkDmyZJUEDEle7WL2/oyBLJg9HhE+Rmp5zO6Ihqzsx/ X-Received: by 2002:a17:906:600f:: with SMTP id o15mr7115263ejj.76.1615038096080; Sat, 06 Mar 2021 05:41:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615038096; cv=none; d=google.com; s=arc-20160816; b=fjCfTkudoN7zK7qt7fd00LTELukboy3a0RfDAZJMs4bCKMZ5HnSNicckv35Wg96iYt 8TAolrj3ud2FjMkuDIPuGFTJd8YHpdV/9+sG9fv3gjIA64qI2H0FP7WCKaxklaH9rQyJ LUSVBCX+1ZUMZ9slcODXTf/rPuzfbh0dCCbJIWZVur8LT7e69uUYEjqqAleO4IIzBcyU OavFCjKFZUGlcZsiMmF8DQ/87iwLjwMGxKauExt0IWbkE7rqJbyvwcGh9haztXEQdng1 458bxM9DobuGgaDuAiRM1lp6Csch/DQaZiO/WKdz4Mv4tyD6w9evYFC9Bl/VAX4sQls7 SUOg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=SgyHs4bA8jPvG61Iiukljso/K2PZ/5NW+EVGXjv/wjc=; b=tXB5aSPci0wgwtIjiBbJKJEuY3sD/15DJCdxxmBc//b8ovuxLKJEp/sy8c5pL/HnRn pk1LMSaJH7RAB+FhvgBeDPNY3gSeY6752FcQKNMSEYNjBsEeRqfEOT4gQl/eO53kmwEu Flq/wk8das6urCiZ2wHmny+b5Kg7Pwy6qGdg9m4HEZDjwSQwrAogCMNFZf7Bum3ook8s RODrZEDpcCZyvU+m3SEs8nTioa2o+vakUZr+a+9gTnqZUjDwZLEcpnQqpZAo/JbO67+A PnnlURYojizjfFA+UNvdCyqE1Je+6J/7VCVqNBL13IHPm+s8nFr6V3uuSDtNcP8MHYjX jakA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id r11si3194904eja.563.2021.03.06.05.41.12; Sat, 06 Mar 2021 05:41:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230477AbhCFNib (ORCPT + 99 others); Sat, 6 Mar 2021 08:38:31 -0500 Received: from www262.sakura.ne.jp ([202.181.97.72]:52105 "EHLO www262.sakura.ne.jp" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230421AbhCFNiJ (ORCPT ); Sat, 6 Mar 2021 08:38:09 -0500 Received: from fsav403.sakura.ne.jp (fsav403.sakura.ne.jp [133.242.250.102]) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTP id 126DboK9026971; Sat, 6 Mar 2021 22:37:50 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Received: from www262.sakura.ne.jp (202.181.97.72) by fsav403.sakura.ne.jp (F-Secure/fsigk_smtp/550/fsav403.sakura.ne.jp); Sat, 06 Mar 2021 22:37:50 +0900 (JST) X-Virus-Status: clean(F-Secure/fsigk_smtp/550/fsav403.sakura.ne.jp) Received: from [192.168.1.9] (M106072142033.v4.enabler.ne.jp [106.72.142.33]) (authenticated bits=0) by www262.sakura.ne.jp (8.15.2/8.15.2) with ESMTPSA id 126Dboiq026964 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NO); Sat, 6 Mar 2021 22:37:50 +0900 (JST) (envelope-from penguin-kernel@i-love.sakura.ne.jp) Subject: Re: [PATCH] security: tomoyo: fix error return code of tomoyo_update_domain() To: Jia-Ju Bai Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, jmorris@namei.org, serge@hallyn.com References: <20210306130346.16296-1-baijiaju1990@gmail.com> From: Tetsuo Handa Message-ID: <79dd201e-ea6e-8de5-6250-25c23453448d@i-love.sakura.ne.jp> Date: Sat, 6 Mar 2021 22:37:49 +0900 User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.8.0 MIME-Version: 1.0 In-Reply-To: <20210306130346.16296-1-baijiaju1990@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021/03/06 22:03, Jia-Ju Bai wrote: > When mutex_lock_interruptible() fails, the error return code of > tomoyo_update_domain() is not properly assigned. > To fix this bug, error is assigned with the return value of > mutex_lock_interruptible(), and then error is checked. Thanks for a patch, but this patch is wrong. Since the variable "error" is initialized as int error = is_delete ? -ENOENT : -ENOMEM; at the beginning of this function, unconditionally overwriting this variable with the return code of mutex_lock_interruptible() breaks if (error && !is_delete) { } block of this function. And the caller does not check if the return code is -EINTR instead of -ENOENT or -ENOMEM.