Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1031275AbcDMOAW (ORCPT ); Wed, 13 Apr 2016 10:00:22 -0400 Received: from out2-smtp.messagingengine.com ([66.111.4.26]:51298 "EHLO out2-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1031165AbcDMOAS (ORCPT ); Wed, 13 Apr 2016 10:00:18 -0400 X-Sasl-enc: Rn9xJLV7Gq+TH95Ywz6LUMl60z2bI0wQxcc/KQ7VURfI 1460556017 Date: Wed, 13 Apr 2016 06:59:50 -0700 From: Greg KH To: "Richard W.M. Jones" Cc: linux-kernel@vger.kernel.org, tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com, akpm@linux-foundation.org, luto@kernel.org, viro@zeniv.linux.org.uk, mathieu.desnoyers@efficios.com, zab@redhat.com, emunson@akamai.com, paulmck@linux.vnet.ibm.com, aarcange@redhat.com, josh@joshtriplett.org, xemul@parallels.com, sfr@canb.auug.org.au, milosz@adfin.com, rostedt@goodmis.org, arnd@arndb.de, ebiederm@xmission.com, gorcunov@openvz.org, iulia.manda21@gmail.com, dave.hansen@linux.intel.com, mguzik@redhat.com, adobriyan@gmail.com, dave@stgolabs.net, linux-api@vger.kernel.org, gorcunov@gmail.com, fw@deneb.enyo.de Subject: Re: [PATCH v2 0/2] vfs: Define new syscall getumask. Message-ID: <20160413135950.GA12128@kroah.com> References: <1460552272-15985-1-git-send-email-rjones@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1460552272-15985-1-git-send-email-rjones@redhat.com> User-Agent: Mutt/1.6.0 (2016-04-01) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1483 Lines: 52 On Wed, Apr 13, 2016 at 01:57:50PM +0100, Richard W.M. Jones wrote: > v1 -> v2: > > - Use current_umask() instead of current->fs->umask. > > - Retested it. > > ---------------------------------------------------------------------- > > It's not possible to read the process umask without also modifying it, > which is what umask(2) does. A library cannot read umask safely, > especially if the main program might be multithreaded. > > This patch series adds a trivial system call "getumask" which returns > the umask of the current process. > > Another approach to this has been attempted before, adding something > to /proc, although it didn't go anywhere. See: > > http://comments.gmane.org/gmane.linux.kernel/1292109 > > Another way to solve this would be to add a thread-safe getumask to > glibc. Since glibc could own the mutex, this would permit libraries > linked to this glibc to read umask safely. > > I should also note that man-pages documents getumask(3), but no > version of glibc has ever implemented it. > > Typical test script: > > #include > #include > #include > #include > > int main(int argc, char *argv[]) > { > int r = syscall(329); > if (r == -1) { > perror("getumask"); > exit(1); > } > printf("umask = %o\n", r); > exit(0); > } Why not add this to the ktest infrastructure, we strongly encourage that for new syscalls, along with a man page patch. thanks, greg k-h