From mboxrd@z Thu Jan 1 00:00:00 1970 From: Al Viro Subject: Re: [PATCH v15 2/9] namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution Date: Wed, 13 Nov 2019 01:24:26 +0000 Message-ID: <20191113012426.GY26530@ZenIV.linux.org.uk> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-3-cyphar@cyphar.com> Mime-Version: 1.0 Return-path: Content-Disposition: inline In-Reply-To: <20191105090553.6350-3-cyphar@cyphar.com> Sender: linux-kernel-owner@vger.kernel.org List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Aleksa Sarai Cc: Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Ingo Molnar , Peter Zijlstra , Christian Brauner , David Drysdale , Andy Lutomirski , Linus Torvalds , Eric Biederman , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , Chanho Min , Oleg Nesterov , Ras On Tue, Nov 05, 2019 at 08:05:46PM +1100, Aleksa Sarai wrote: > @@ -1078,6 +1079,10 @@ const char *get_link(struct nameidata *nd) > } else { > res = get(dentry, inode, &last->done); > } > + if (nd->flags & LOOKUP_MAGICLINK_JUMPED) { > + if (unlikely(nd->flags & LOOKUP_NO_MAGICLINKS)) > + return ERR_PTR(-ELOOP); > + } Minor nit - the first check probably wants unlikely() more than the second one; it's probably noise anyway, but most of the symlinks traversed are not going to be procfs ones, so you get test + branch taken most of the time. OTOH, that just might compile into fetch nd->flags and with LOOKUP_MAGICLINK_JUMPED | LOOKUP_NO_MAGICLINKS compare with the same constant unlikely branch when equal Anyway, that's no more than a minor nit and can be dealt with later (if at all) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zeniv.linux.org.uk ([195.92.253.2]:38684 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726960AbfKMB1E (ORCPT ); Tue, 12 Nov 2019 20:27:04 -0500 Date: Wed, 13 Nov 2019 01:24:26 +0000 From: Al Viro Subject: Re: [PATCH v15 2/9] namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution Message-ID: <20191113012426.GY26530@ZenIV.linux.org.uk> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-3-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105090553.6350-3-cyphar@cyphar.com> Sender: linux-arch-owner@vger.kernel.org List-ID: To: Aleksa Sarai Cc: Jeff Layton , "J. Bruce Fields" , Arnd Bergmann , David Howells , Shuah Khan , Shuah Khan , Ingo Molnar , Peter Zijlstra , Christian Brauner , David Drysdale , Andy Lutomirski , Linus Torvalds , Eric Biederman , Andrew Morton , Alexei Starovoitov , Kees Cook , Jann Horn , Tycho Andersen , Chanho Min , Oleg Nesterov , Rasmus Villemoes , Alexander Shishkin , Jiri Olsa , Namhyung Kim , Christian Brauner , Aleksa Sarai , containers@lists.linux-foundation.org, linux-alpha@vger.kernel.org, linux-api@vger.kernel.org, libc-alpha@sourceware.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-ia64@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-m68k@lists.linux-m68k.org, linux-mips@vger.kernel.org, linux-parisc@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, sparclinux@vger.kernel.org Message-ID: <20191113012426.sTedr7iyFHCzmC4Z879iqcbdJJnTgJmBnQ_fmKEA8Eo@z> On Tue, Nov 05, 2019 at 08:05:46PM +1100, Aleksa Sarai wrote: > @@ -1078,6 +1079,10 @@ const char *get_link(struct nameidata *nd) > } else { > res = get(dentry, inode, &last->done); > } > + if (nd->flags & LOOKUP_MAGICLINK_JUMPED) { > + if (unlikely(nd->flags & LOOKUP_NO_MAGICLINKS)) > + return ERR_PTR(-ELOOP); > + } Minor nit - the first check probably wants unlikely() more than the second one; it's probably noise anyway, but most of the symlinks traversed are not going to be procfs ones, so you get test + branch taken most of the time. OTOH, that just might compile into fetch nd->flags and with LOOKUP_MAGICLINK_JUMPED | LOOKUP_NO_MAGICLINKS compare with the same constant unlikely branch when equal Anyway, that's no more than a minor nit and can be dealt with later (if at all) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08F6CC43331 for ; Wed, 13 Nov 2019 01:29:56 +0000 (UTC) Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 77EB1222CE for ; Wed, 13 Nov 2019 01:29:55 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 77EB1222CE Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 47CRqh1DZPzF5F6 for ; Wed, 13 Nov 2019 12:29:52 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=ftp.linux.org.uk (client-ip=195.92.253.2; helo=zeniv.linux.org.uk; envelope-from=viro@ftp.linux.org.uk; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Received: from ZenIV.linux.org.uk (zeniv.linux.org.uk [195.92.253.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 47CRnB3nHczF5vq for ; Wed, 13 Nov 2019 12:27:40 +1100 (AEDT) Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUhOU-0006xS-Cx; Wed, 13 Nov 2019 01:24:26 +0000 Date: Wed, 13 Nov 2019 01:24:26 +0000 From: Al Viro To: Aleksa Sarai Subject: Re: [PATCH v15 2/9] namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution Message-ID: <20191113012426.GY26530@ZenIV.linux.org.uk> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-3-cyphar@cyphar.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20191105090553.6350-3-cyphar@cyphar.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-BeenThere: linuxppc-dev@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Linux on PowerPC Developers Mail List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , Rasmus Villemoes , Alexei Starovoitov , linux-kernel@vger.kernel.org, David Howells , linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, Christian Brauner , Shuah Khan , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Tycho Andersen , Aleksa Sarai , Jiri Olsa , Alexander Shishkin , Ingo Molnar , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, Kees Cook , Arnd Bergmann , Jann Horn , linuxppc-dev@lists.ozlabs.org, linux-m68k@lists.linux-m68k.org, Andy Lutomirski , Shuah Khan , Namhyung Kim , David Drysdale , Christian Brauner , "J. Bruce Fields" , libc-alpha@sourceware.org, linux-parisc@vger.kernel.org, linux-api@vger.kernel.org, Chanho Min , Jeff Layton , Oleg Nesterov , Eric Biederman , linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Linus Torvalds , containers@lists.linux-foundation.org Errors-To: linuxppc-dev-bounces+linuxppc-dev=archiver.kernel.org@lists.ozlabs.org Sender: "Linuxppc-dev" On Tue, Nov 05, 2019 at 08:05:46PM +1100, Aleksa Sarai wrote: > @@ -1078,6 +1079,10 @@ const char *get_link(struct nameidata *nd) > } else { > res = get(dentry, inode, &last->done); > } > + if (nd->flags & LOOKUP_MAGICLINK_JUMPED) { > + if (unlikely(nd->flags & LOOKUP_NO_MAGICLINKS)) > + return ERR_PTR(-ELOOP); > + } Minor nit - the first check probably wants unlikely() more than the second one; it's probably noise anyway, but most of the symlinks traversed are not going to be procfs ones, so you get test + branch taken most of the time. OTOH, that just might compile into fetch nd->flags and with LOOKUP_MAGICLINK_JUMPED | LOOKUP_NO_MAGICLINKS compare with the same constant unlikely branch when equal Anyway, that's no more than a minor nit and can be dealt with later (if at all) From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9240C43331 for ; Wed, 13 Nov 2019 01:29:19 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 9B733222CF for ; Wed, 13 Nov 2019 01:29:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="pQGSSltZ" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 9B733222CF Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=d02ttNTkasyRbgJSq7A4E/CoQTjTDaIuY/XcuSwkEFo=; b=pQGSSltZtQHrzR Mw7Ls395GNBQn/GzGjQF6/efAbJAdZZyZXCCtFflky3je+IYN5tSfKlueW61dfroX+HvAwFBlfamq HM2KvvVDS5hN7hefHQnqjI/do/eTvV+12UzqdAyXATrsdfgqMLKCh94qxhp9CNcJhUbceqjjGChHj Ca8oSZBfdLXWFteXOUC32YVIevFshYWD6+sNHG/NqjbQkR/zwKKIPvi9H+T8IDH9JQHSzx4q3vBKI S/uq+dtO+GPsK7Uk2x/F6sFQIynlPY8uOGjxs58BXJnwAkyj04rGBDMRJcohbP99gNCfnLse68se/ /bOfRoOs8Q8hfyfGaW8g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUhTC-0002ON-BW; Wed, 13 Nov 2019 01:29:18 +0000 Received: from zeniv.linux.org.uk ([195.92.253.2]) by bombadil.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUhT7-0002F6-6i for linux-arm-kernel@lists.infradead.org; Wed, 13 Nov 2019 01:29:16 +0000 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.3 #3 (Red Hat Linux)) id 1iUhOU-0006xS-Cx; Wed, 13 Nov 2019 01:24:26 +0000 Date: Wed, 13 Nov 2019 01:24:26 +0000 From: Al Viro To: Aleksa Sarai Subject: Re: [PATCH v15 2/9] namei: LOOKUP_NO_MAGICLINKS: block magic-link resolution Message-ID: <20191113012426.GY26530@ZenIV.linux.org.uk> References: <20191105090553.6350-1-cyphar@cyphar.com> <20191105090553.6350-3-cyphar@cyphar.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20191105090553.6350-3-cyphar@cyphar.com> User-Agent: Mutt/1.12.1 (2019-06-15) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20191112_172913_245305_96AD8927 X-CRM114-Status: UNSURE ( 9.79 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-ia64@vger.kernel.org, linux-sh@vger.kernel.org, Peter Zijlstra , Rasmus Villemoes , Alexei Starovoitov , linux-kernel@vger.kernel.org, David Howells , linux-kselftest@vger.kernel.org, sparclinux@vger.kernel.org, Christian Brauner , Shuah Khan , linux-arch@vger.kernel.org, linux-s390@vger.kernel.org, Tycho Andersen , Aleksa Sarai , Jiri Olsa , Alexander Shishkin , Ingo Molnar , linux-arm-kernel@lists.infradead.org, linux-mips@vger.kernel.org, linux-xtensa@linux-xtensa.org, Kees Cook , Arnd Bergmann , Jann Horn , linuxppc-dev@lists.ozlabs.org, linux-m68k@lists.linux-m68k.org, Andy Lutomirski , Shuah Khan , Namhyung Kim , David Drysdale , Christian Brauner , "J. Bruce Fields" , libc-alpha@sourceware.org, linux-parisc@vger.kernel.org, linux-api@vger.kernel.org, Chanho Min , Jeff Layton , Oleg Nesterov , Eric Biederman , linux-alpha@vger.kernel.org, linux-fsdevel@vger.kernel.org, Andrew Morton , Linus Torvalds , containers@lists.linux-foundation.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Nov 05, 2019 at 08:05:46PM +1100, Aleksa Sarai wrote: > @@ -1078,6 +1079,10 @@ const char *get_link(struct nameidata *nd) > } else { > res = get(dentry, inode, &last->done); > } > + if (nd->flags & LOOKUP_MAGICLINK_JUMPED) { > + if (unlikely(nd->flags & LOOKUP_NO_MAGICLINKS)) > + return ERR_PTR(-ELOOP); > + } Minor nit - the first check probably wants unlikely() more than the second one; it's probably noise anyway, but most of the symlinks traversed are not going to be procfs ones, so you get test + branch taken most of the time. OTOH, that just might compile into fetch nd->flags and with LOOKUP_MAGICLINK_JUMPED | LOOKUP_NO_MAGICLINKS compare with the same constant unlikely branch when equal Anyway, that's no more than a minor nit and can be dealt with later (if at all) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel