Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3216ybl; Tue, 7 Jan 2020 12:58:58 -0800 (PST) X-Google-Smtp-Source: APXvYqwu/MhTgb/PdEjkPo5vRZpUdAqXO+3P9dgIBcSjCiHRZEv4rKQGSSyEg7S4JPpRXv0kZi0x X-Received: by 2002:aca:cf11:: with SMTP id f17mr325744oig.40.1578430737852; Tue, 07 Jan 2020 12:58:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578430737; cv=none; d=google.com; s=arc-20160816; b=WQJP9QzE4juAClVyTbyaAusnEzPhOyXcikFSf/anreH4INLwXP1vwrN15IET2japrK bp9vrcWhSODYbnx6GHQL1NnPikq20xinaZoA9HF+wKqIVSYibS0rMW7FZ35Vd5ZyvQKX JnHNcx+SdRIm3sN5KMZFUHilgXxg60YKLUTx7hQ2pCG0ybGsbtTY0zWBGKfEpsC2juEC Tq10mzerCgUb4JM0QJakwM3vvho/hzTlyhkFFm0t/usUjj749HUPGEW4gU1M6MM+VNL1 DvRD+rOD6oxYWpXsIEs8+cf9HJxDypqOkHQZ1GuevMDsaWN94uLzCAFZEXcR7vN0yYge Uvjw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=tmuIc79sh6Ts6yjVoUQojUwgmGX6CSnMoYjUeK5m1ko=; b=eysNWlwKUSqpTIrVN78U7CFIBdGDIouWQsBwDtXonTcjGVfZJ+1IXzHquzxFCnkxTm SKZndo9c0+oiQWdRGxiIZLJ63SSO0BAAz+OHi9/txx9zPAh+JyWcj//SyXVWlz7Ic9/x 0V6Gdv72kofMzyH5HIdgaYivgcxXF2h9lkprseYndMwEMXqgKoJQjkK5x140aIyR6H8V 19PQp7I6W2Y0dJqzFpHBYgpSe/oftDaxcD9jYLKC+dnalDqS1IiriNoQ+XAZxksD4Eb8 IH4o4ukYQDnAbiH2G+jSyrxM3SQ6l9xuBYMog8XM/irXmL+Rc4O8Kyz8qoogydKU0g1n LW2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kSezIfPh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q72si617280oic.18.2020.01.07.12.58.44; Tue, 07 Jan 2020 12:58:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=kSezIfPh; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727642AbgAGU5h (ORCPT + 99 others); Tue, 7 Jan 2020 15:57:37 -0500 Received: from mail.kernel.org ([198.145.29.99]:54974 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727620AbgAGU5f (ORCPT ); Tue, 7 Jan 2020 15:57:35 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 79C1A2087F; Tue, 7 Jan 2020 20:57:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578430654; bh=hFlnMAuexBIYadEPJ22i3/BbCHDfpBlVwdKylJjByHE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=kSezIfPhipttu/ldV9kG7LA12t9eJ3Cu6VXtSJRis4TvP0i8der0fgn1Kv0/gm2rr 3EfBGnjAnEZx47UrL+nuE5F731HzrNQVBlc6w9Umhy2Eil/Z+xgPGApSLWKF4YUtrF ihhBx9fV1kS4uHwE+JOP4cOJuOBYMoqt07GcHXRI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Billings , David Howells , Marc Dionne , Sasha Levin Subject: [PATCH 5.4 041/191] afs: Fix mountpoint parsing Date: Tue, 7 Jan 2020 21:52:41 +0100 Message-Id: <20200107205335.192793624@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200107205332.984228665@linuxfoundation.org> References: <20200107205332.984228665@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: David Howells [ Upstream commit 158d58335393af3956a9c06f0816ee75ed1f1447 ] Each AFS mountpoint has strings that define the target to be mounted. This is required to end in a dot that is supposed to be stripped off. The string can include suffixes of ".readonly" or ".backup" - which are supposed to come before the terminal dot. To add to the confusion, the "fs lsmount" afs utility does not show the terminal dot when displaying the string. The kernel mount source string parser, however, assumes that the terminal dot marks the suffix and that the suffix is always "" and is thus ignored. In most cases, there is no suffix and this is not a problem - but if there is a suffix, it is lost and this affects the ability to mount the correct volume. The command line mount command, on the other hand, is expected not to include a terminal dot - so the problem doesn't arise there. Fix this by making sure that the dot exists and then stripping it when passing the string to the mount configuration. Fixes: bec5eb614130 ("AFS: Implement an autocell mount capability [ver #2]") Reported-by: Jonathan Billings Signed-off-by: David Howells Reviewed-by: Marc Dionne Tested-by: Jonathan Billings Signed-off-by: Sasha Levin --- fs/afs/mntpt.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/afs/mntpt.c b/fs/afs/mntpt.c index f532d6d3bd28..79bc5f1338ed 100644 --- a/fs/afs/mntpt.c +++ b/fs/afs/mntpt.c @@ -126,7 +126,7 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt) if (src_as->cell) ctx->cell = afs_get_cell(src_as->cell); - if (size > PAGE_SIZE - 1) + if (size < 2 || size > PAGE_SIZE - 1) return -EINVAL; page = read_mapping_page(d_inode(mntpt)->i_mapping, 0, NULL); @@ -140,7 +140,9 @@ static int afs_mntpt_set_params(struct fs_context *fc, struct dentry *mntpt) } buf = kmap(page); - ret = vfs_parse_fs_string(fc, "source", buf, size); + ret = -EINVAL; + if (buf[size - 1] == '.') + ret = vfs_parse_fs_string(fc, "source", buf, size - 1); kunmap(page); put_page(page); if (ret < 0) -- 2.20.1