Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2992564AbbHHQsU (ORCPT ); Sat, 8 Aug 2015 12:48:20 -0400 Received: from mfb02-md.ns.itscom.net ([175.177.155.110]:51877 "EHLO mfb02-md.ns.itscom.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2992474AbbHHQsS (ORCPT ); Sat, 8 Aug 2015 12:48:18 -0400 X-Greylist: delayed 380 seconds by postgrey-1.27 at vger.kernel.org; Sat, 08 Aug 2015 12:48:18 EDT From: "J. R. Okajima" Subject: Re: [PATCH] fs: create and use seq_show_option for escaping To: Kees Cook Cc: Andrew Morton , "Yan, Zheng" , Sage Weil , Ilya Dryomov , Steve French , Jan Kara , Andreas Dilger , "Theodore Ts'o" , Steven Whitehouse , Bob Peterson , Jeff Dike , Richard Weinberger , Mark Fasheh , Joel Becker , Miklos Szeredi , Dave Chinner , xfs@oss.sgi.com, Tejun Heo , Li Zefan , Johannes Weiner , "David S. Miller" , Paul Moore , Stephen Smalley , Eric Paris , James Morris , "Serge E. Hallyn" , Jens Axboe , Fabian Frederick , Christoph Hellwig , Firo Yang , David Howells , Jiri Slaby , Al Viro , Joe Perches , Steven Rostedt , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20150807234150.GA11735@www.outflux.net> References: <20150807234150.GA11735@www.outflux.net> Date: Sun, 09 Aug 2015 01:41:55 +0900 Message-ID: <8996.1439052115@jrobl> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1359 Lines: 44 Kees Cook: > This fixes the problem by adding new seq_show_option and seq_show_option_n > helpers, and updating the vulnerable show_option handlers to use them as > needed. Some, like SELinux, need to be open coded due to unusual existing > escape mechanisms. How about other ctrl chars such as CR or FF? I am using the similar function for many years, and it might be more generic because it supports all cntrl chars other than "\t\n\\" (see below). Many of other ctrl chars may not be necessary. But some people uses non-ASCII chars for their pathnames which may contain ESC or other chars. Any crazy chars can corrupt the output of /proc/mount and others. So it might be better to consider all ctrl chars. ---------------------------------------------------------------------- static char au_esc_chars[0x20 + 3]; /* 0x01-0x20, backslash, del, and NULL */ int au_seq_path(struct seq_file *seq, struct path *path) { return seq_path(seq, path, au_esc_chars); } module_init(void) { ::: p = au_esc_chars; for (i = 1; i <= ' '; i++) *p++ = i; *p++ = '\\'; *p++ = '\x7f'; *p = 0; ::: } J. R. Okajima -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/