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 E79F2C433F5 for ; Tue, 15 Mar 2022 19:05:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1350372AbiCOTHG (ORCPT ); Tue, 15 Mar 2022 15:07:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57478 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1351337AbiCOTG4 (ORCPT ); Tue, 15 Mar 2022 15:06:56 -0400 Received: from zeniv-ca.linux.org.uk (zeniv-ca.linux.org.uk [142.44.231.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 930D4E2E; Tue, 15 Mar 2022 12:04:59 -0700 (PDT) Received: from viro by zeniv-ca.linux.org.uk with local (Exim 4.94.2 #2 (Red Hat Linux)) id 1nUCP3-00BlnI-Ls; Tue, 15 Mar 2022 19:00:17 +0000 Date: Tue, 15 Mar 2022 19:00:17 +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 Tue, Mar 15, 2022 at 10:27:39AM -0700, Hao Luo wrote: > Option 1: We can put restrictions on the pathname passed into this > helper. We can explicitly require the parameter dirfd to be in bpffs > (we can verify). In addition, we check pathname to be not containing > any dot or dotdot, so the resolved path will end up inside bpffs, > therefore won't take ->i_rwsem that is in the callchain of > cgroup_mkdir(). Won't be enough - mount --bind the parent under itself and there you go... Sure, you could prohibit mountpoint crossing, etc., but at that point I'd question the usefulness of pathname resolution in the first place.