From patchwork Fri Jun 17 05:08:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ian Kent X-Patchwork-Id: 12885096 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 C9703C433EF for ; Fri, 17 Jun 2022 05:15:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379891AbiFQFPG (ORCPT ); Fri, 17 Jun 2022 01:15:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46956 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232386AbiFQFPF (ORCPT ); Fri, 17 Jun 2022 01:15:05 -0400 X-Greylist: delayed 360 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 16 Jun 2022 22:15:03 PDT Received: from smtp03.aussiebb.com.au (2403-5800-3-25--1003.ip6.aussiebb.net [IPv6:2403:5800:3:25::1003]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8A4A563BE6; Thu, 16 Jun 2022 22:15:03 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by smtp03.aussiebb.com.au (Postfix) with ESMTP id A81321A0089; Fri, 17 Jun 2022 15:09:00 +1000 (AEST) X-Virus-Scanned: Debian amavisd-new at smtp03.aussiebb.com.au Received: from smtp03.aussiebb.com.au ([127.0.0.1]) by localhost (smtp03.aussiebb.com.au [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Kkiu0vSoVOHC; Fri, 17 Jun 2022 15:09:00 +1000 (AEST) Received: by smtp03.aussiebb.com.au (Postfix, from userid 119) id 94D6B1A0085; Fri, 17 Jun 2022 15:09:00 +1000 (AEST) Received: from donald.themaw.net (180-150-90-198.b4965a.per.nbn.aussiebb.net [180.150.90.198]) by smtp03.aussiebb.com.au (Postfix) with ESMTP id 7F66C1A0072; Fri, 17 Jun 2022 15:08:58 +1000 (AEST) Subject: [PATCH 0/2] vfs: fix a couple of mount table handling problems From: Ian Kent To: Al Viro Cc: Siddhesh Poyarekar , David Howells , Miklos Szeredi , Carlos Maiolino , linux-fsdevel , Kernel Mailing List Date: Fri, 17 Jun 2022 13:08:53 +0800 Message-ID: <165544249242.247784.13096425754908440867.stgit@donald.themaw.net> User-Agent: StGit/1.1 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org First, whenever a mount has an empty "source" (aka mnt_fsname), the glibc function getmntent incorrectly parses its input, resulting in reporting incorrect data to the caller. The problem is that the get_mnt_entry() function in glibc's misc/mntent_r.c assumes that leading whitespace on a line can always be discarded because it will always be followed by a # for the case of a comment or a non-whitespace character that's part of the value of the first field. However, this assumption is violated when the value of the first field is an empty string. This is fixed in the mount API code by simply checking for a pointer that contains a NULL and treating it as a NULL pointer. Second, when a filesystem is mounted with a name that starts with a # the glibc finction getmentent() will interpret the leading # as a comment so that the mount line will not appear in the output. This is fixed by adding a # to the to be translated string in fs/proc_namespace.c:mangle(). Signed-off-by: Ian Kent --- Ian Kent (1): vfs: parse: deal with zero length string value Siddhesh Poyarekar (1): vfs: escape hash as well fs/fs_context.c | 10 +++++++--- fs/proc_namespace.c | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) -- Ian Kent