From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from out30-112.freemail.mail.aliyun.com (out30-112.freemail.mail.aliyun.com [115.124.30.112]) (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 C871B42044; Mon, 20 May 2024 11:24:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=115.124.30.112 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716204255; cv=none; b=greCa1sb+xv72iCpJ/akfoPgLzaDg9c7HIUimHzBbUIv2Lzluvpy20ejUz5iACi0axYAPHyAlSTIBg/5FDhQeHg0DVDT5HLns46odRRFkBST4Q+zQX8OYP3XvPIh2T62mlZVcIMvcycil1yhyc4yO49mOlIxndyCPX9j/UF0IJY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716204255; c=relaxed/simple; bh=e5msGpPJDfpNozD6dX0TXGDkIn5t6CljDiGOFY3+f8E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=I7tEErEllBZlwaOHiDrH8ALqwn8RUQMuhdYygIRDzo+QeSMlHmC/MgCRAxcO3vlftc4EW/R3q4zEl2xD3dvU9LTJvaykmYE4gihTij+EdeVlcCc5NfF1LQWqyG+DK1K4iNYXScsfKNxsHNWKyI0dtE1yDpwPeyZoGBJwAT25a2o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; spf=pass smtp.mailfrom=linux.alibaba.com; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b=ZRWlrIKp; arc=none smtp.client-ip=115.124.30.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.alibaba.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.b="ZRWlrIKp" DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1716204249; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=e5msGpPJDfpNozD6dX0TXGDkIn5t6CljDiGOFY3+f8E=; b=ZRWlrIKplW1YPjLd05G9+f+tm8g6XYzuhfjvg3YpjE61faO8TNVdmVePsn751grmQA222UszBEuvIMM9CiMIBjplNb8Zbp8YOOeHs+ujwbX0F704RA4gJjnuPqUGTLGoqCnOUlkmp3oGg/X98WSQoQMIhvRaAODS67uSQDnnLPY= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R271e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033037067109;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=14;SR=0;TI=SMTPD_---0W6s..ub_1716204246; Received: from 30.97.48.204(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0W6s..ub_1716204246) by smtp.aliyun-inc.com; Mon, 20 May 2024 19:24:08 +0800 Message-ID: Date: Mon, 20 May 2024 19:24:06 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 08/12] cachefiles: never get a new anonymous fd if ondemand_id is valid To: Baokun Li , Jingbo Xu , netfs@lists.linux.dev, dhowells@redhat.com, jlayton@kernel.org Cc: zhujia.zj@bytedance.com, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, yangerkun@huawei.com, houtao1@huawei.com, yukuai3@huawei.com, wozizhi@huawei.com, Baokun Li References: <20240515084601.3240503-1-libaokun@huaweicloud.com> <20240515084601.3240503-9-libaokun@huaweicloud.com> <5b1b2719-2123-9218-97b4-ccda8b5cb3b4@huaweicloud.com> From: Gao Xiang In-Reply-To: <5b1b2719-2123-9218-97b4-ccda8b5cb3b4@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit On 2024/5/20 19:14, Baokun Li wrote: > On 2024/5/20 17:24, Jingbo Xu wrote: >> >> On 5/20/24 5:07 PM, Baokun Li wrote: >>> On 2024/5/20 16:43, Jingbo Xu wrote: >>>> On 5/15/24 4:45 PM, libaokun@huaweicloud.com wrote: >>>>> From: Baokun Li >>>>> > SNIP >>>>> >>>>> To avoid this, allocate a new anonymous fd only if no anonymous fd has >>>>> been allocated (ondemand_id == 0) or if the previously allocated >>>>> anonymous >>>>> fd has been closed (ondemand_id == -1). Moreover, returns an error if >>>>> ondemand_id is valid, letting the daemon know that the current userland >>>>> restore logic is abnormal and needs to be checked. >>>>> >>>>> Fixes: c8383054506c ("cachefiles: notify the user daemon when looking >>>>> up cookie") >>>>> Signed-off-by: Baokun Li >>>> The LOCs of this fix is quite under control.  But still it seems that >>>> the worst consequence is that the (potential) malicious daemon gets >>>> hung.  No more effect to the system or other processes.  Or does a >>>> non-malicious daemon have any chance having the same issue? >>> If we enable hung_task_panic, it may cause panic to crash the server. >> Then this issue has nothing to do with this patch?  As long as a >> malicious daemon doesn't close the anonymous fd after umounting, then I >> guess a following attempt of mounting cookie with the same name will >> also wait and hung there? >> > Yes, a daemon that only reads requests but doesn't process them will > cause hung,but the daemon will obey the basic constraints when we > test it. If we'd really like to enhanace this ("hung_task_panic"), I think you'd better to switch wait_for_completion() to wait_for_completion_killable() at least IMHO anyway. Thanks, Gao Xiang