Received: by 2002:ab2:69cc:0:b0:1f4:be93:e15a with SMTP id n12csp1189248lqp; Sun, 14 Apr 2024 19:57:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXt7aLmgVAk5P+VW52ZhSo3gNIsezXPZZH3yRlep8nudtxzqVSnQ+j4wzXJYMheqOl3pMfB/spO5wuVFxg99gKOr2qJzhFWdmnBL78WAA== X-Google-Smtp-Source: AGHT+IH2m0/MwI9FCmTkoT93jKCZx/IT0GPDnhw0LSh47jVRM6+wlRupNInHdHFD979mm0tTIDlS X-Received: by 2002:a05:6a21:8881:b0:1a7:9ce4:bd1d with SMTP id tb1-20020a056a21888100b001a79ce4bd1dmr13088701pzc.34.1713149822658; Sun, 14 Apr 2024 19:57:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1713149822; cv=pass; d=google.com; s=arc-20160816; b=Efs7BBL0mtmvAq/DRzChlw9sBu/ySTyZax6DQ+C5MYy4mP2hCS0fWlWsXhEPMdn3bk 66Gd6okndCKAn3gU3b11MgWpysOCDQ6GmZkRCqawN31N35VdOKTmIMpiv9SwP+ttu9YO dCBbILqbfETwrBeVaP9GDMJQe1Dm8horhXgZx/TuGvDpSPWO9zhX+6n9Nq0XIXjBUJ7O 62JoOlytV8Nt4REVA2o6EUsUhKIqF4xRD+mbe+ebrlaU3H50zbWg3V1FNp0GFaq1rp7m tAi8uy6drm0P/Kfb6AdGTjISN9I7Z8Kza/gYLkV+GWrs1Wut3lG0U85nhBbbMRkS2ffc +7Fg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=bbouK2i2QXvMiu/IXpjaD7CYpfqtLXdPv9/Xv/iKvVg=; fh=NFp4f2umOPL/LEcYJBwpgMCcHAzHnB2yU/m8gzRd8p8=; b=EE4NymRxIAEjofj7+LkaorzzJGNyxn1uD++x8O9VziQU1p7Nebo0kNmQOeXSWCMHIj m18xea8xAB7dpH4CIxWxFBOcOD5dgCMJWDaqMARKIWmTIgu6LLl+9UyufqUo/BQVsorg w9r0cjK6yZ+/xAVwItHrdlgg2dL89qk8l7EuGSv53Jomh6Ds2KH0OgmsOY9Vit6ru5jE Hk5GKZFMYIavkqxRVi0WglD1hMxHpssVx50u2uwPzjg0qb3CyYSUpUOo0x2OqNA8fI4X Xs+wtstJh6DXr090Gl/gshqrujiiZS8kYGhHRdPqYPToJlEMsjmDTgemEzT8dsh4qXq2 cpSw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=29HYk93m; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u11-20020a63f64b000000b005e84b852238si7098855pgj.504.2024.04.14.19.57.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 14 Apr 2024 19:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-144405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20210309 header.b=29HYk93m; arc=pass (i=1 dkim=pass dkdomain=infradead.org); spf=pass (google.com: domain of linux-kernel+bounces-144405-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-144405-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id C9FB9282480 for ; Sun, 14 Apr 2024 20:59:07 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0CF6B136E38; Sun, 14 Apr 2024 20:58:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b="29HYk93m" Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 F06BF41C68; Sun, 14 Apr 2024 20:58:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.137.202.133 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713128338; cv=none; b=gNxJfFB1B4x1Ul+08ALAD18L6r9YUruBMrl73ZFwtgcfrr/AVgN95pyqH7C3KUOXcmrl7dMS4v3nTVZdzfyzuM5cvvdvnB3oeoAOIJMGsK3x5czMo6E2zkYJ2yuYQEJhmceAaFq9yqPCtn0sBdZoBCgKBcstBH6ozz8C0AOQoyY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713128338; c=relaxed/simple; bh=AiuoHRyfN8BIP74DeS4SwjEEoZsmO1qeZ+hZGF4ctHc=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=d1F2wYEarLcdRSbXJzwcE0/QIfzkAp9/jL64ilQZyKU5zLJfvbgJGIdXfCu1DLdEyWx0TKqgeAuU9536WKnQeCR40iqhZwShPJUyiZo0gACqA8qTjaYZkb+N57YtECfSIkt+NG/7YZlNXeBI/dblr0bbXeJDdDKX4CnDcOIW6tg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org; spf=none smtp.mailfrom=infradead.org; dkim=pass (2048-bit key) header.d=infradead.org header.i=@infradead.org header.b=29HYk93m; arc=none smtp.client-ip=198.137.202.133 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20210309; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=bbouK2i2QXvMiu/IXpjaD7CYpfqtLXdPv9/Xv/iKvVg=; b=29HYk93mBv9SUvTswYCrQyrCKd t6Lbb5P7anOATU4YvCzS+EiY1Z7EwrwprK5OH3QwOdhhxbpP9EbZgcbsHJF9sQfbxSFrrW5WYHlAI pN1reMoXbl6ThJM5poYbINbmP4+D9Bj2wqLa6OLFRMRrsUBZnfele5qVhlhVcZgtBk8RWaW26o/H/ 2SXhwsHFGl0qBAN6qqfR2fR9iW1FAIRun5L1PvwRi1buJw3Q03ZfdirjUa/uVrqFFCAfyi1yAVVMh XBSfvItoHm1Wf2Al5RpikTrYJKI4A6e1463HdYjZLWF6rkBJaVwcfUiEL/97Ui6UWxNalnldA5cqB VZzm4jzw==; Received: from mcgrof by bombadil.infradead.org with local (Exim 4.97.1 #2 (Red Hat Linux)) id 1rw6wC-00000006OKI-00w4; Sun, 14 Apr 2024 20:58:56 +0000 Date: Sun, 14 Apr 2024 13:58:55 -0700 From: Luis Chamberlain To: Alexey Dobriyan Cc: akpm@linux-foundation.org, linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz Subject: Re: [PATCH] module: ban '.', '..' as module names, ban '/' in module names Message-ID: References: Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Sender: Luis Chamberlain On Sun, Apr 14, 2024 at 10:05:05PM +0300, Alexey Dobriyan wrote: > --- a/include/linux/fs.h > +++ b/include/linux/fs.h > @@ -3616,4 +3616,12 @@ extern int vfs_fadvise(struct file *file, loff_t offset, loff_t len, > extern int generic_fadvise(struct file *file, loff_t offset, loff_t len, > int advice); > > +/* > + * Use this if data from userspace end up as directory/filename on > + * some virtual filesystem. > + */ > +static inline bool string_is_vfs_ready(const char *s) > +{ > + return strcmp(s, ".") != 0 && strcmp(s, "..") != 0 && !strchr(s, '/'); > +} > #endif /* _LINUX_FS_H */ > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2893,6 +2893,11 @@ static int load_module(struct load_info *info, const char __user *uargs, > > audit_log_kern_module(mod->name); > > + if (!string_is_vfs_ready(mod->name)) { > + err = -EINVAL; > + goto free_module; > + } > + Sensible change however to put string_is_vfs_ready() in include/linux/fs.h is a stretch if there really are no other users. Luis