From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 56727C433F5 for ; Mon, 14 Mar 2022 23:37:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343715AbiCNXhM (ORCPT ); Mon, 14 Mar 2022 19:37:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343707AbiCNXhK (ORCPT ); Mon, 14 Mar 2022 19:37:10 -0400 X-Greylist: delayed 1253 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Mon, 14 Mar 2022 16:35:59 PDT Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [142.44.231.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 919C813F63; Mon, 14 Mar 2022 16:35:59 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nTtph-00BJxN-UC; Mon, 14 Mar 2022 23:10:34 +0000 Date: Mon, 14 Mar 2022 23:10:33 +0000 From: Al Viro To: Hao Luo Cc: Alexei Starovoitov , Andrii Nakryiko , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Shakeel Butt , Joe Burton , Tejun Heo , joshdon@google.com, sdf@google.com, bpf@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH bpf-next v1 1/9] bpf: Add mkdir, rmdir, unlink syscalls for prog_bpf_syscall Message-ID: References: <20220225234339.2386398-1-haoluo@google.com> <20220225234339.2386398-2-haoluo@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Al Viro Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 14, 2022 at 10:07:31AM -0700, Hao Luo wrote: > Hello Al, > > In which contexts can those be called? > > > > In a sleepable context. The plan is to introduce a certain tracepoints > as sleepable, a program that attaches to sleepable tracepoints is > allowed to call these functions. In particular, the first sleepable > tracepoint introduced in this patchset is one at the end of > cgroup_mkdir(). Do you have any advices? Yes - don't do it, unless you really want a lot of user-triggerable deadlocks. Pathname resolution is not locking-agnostic. In particular, you can't do it if you are under any ->i_rwsem, whether it's shared or exclusive. That includes cgroup_mkdir() callchains. And if the pathname passed to these functions will have you walk through the parent directory, you would get screwed (e.g. if the next component happens to be inexistent, triggering a lookup, which takes ->i_rwsem shared).