Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp140764pxk; Fri, 11 Sep 2020 02:45:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxf+mpizgACxl2cEv0BLm1CO1PlrQkjjMdxsv9r4OVwdpnEjS8gAWv2OuAGMlzVCXVwPFiq X-Received: by 2002:aa7:cb92:: with SMTP id r18mr1108850edt.158.1599817555032; Fri, 11 Sep 2020 02:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599817555; cv=none; d=google.com; s=arc-20160816; b=iqehl8MGSVZWmhwUmC4HXShjyt0z3jIHdd8f+fkFBamuiZW8je0ga4UjqRtLIsPaPZ 6bLhP8EfKMxC4a2gtOwiRkBle2jBoSflmBB+rmixUISUtelWEeNnrgIo5rp00hLL3HA1 nxIb/cpWhGcFz/1KqTIZdYWOyu9kF7AlX4gKYQ7ny0+1N2mgimh2uvwNxaX7BimlGxNV ChP9Fc5o+H9GjbyS7KS0PFXD4nUE4AuOcOJ10awDl4br6Qsg+hvwz5a1ac0uIu1c5M78 ck4vy2m1d5YnbGBnUGFF0XH28N2oDZ6XwbblSYBsUX7xr2tYFJWNY1MjAQOakzkbenqP PHHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=R2qGF7yERmMAU8dGcjKeKqRGk5IWwYFjQLOwCzYOvew=; b=L8xO+yF++ks0DA6KFC4gFAHrRNbL+XBb4p+QWU+AjMlzUj25OgpjFnhqv0ud8mNfIr QVdVtAL905d074gcr89c2F2AQZ4oHcrspWudQ4q7XjVGofeAmOzVhQWem0PBwDZDFRBL DGwfI6itXkyGHQFZDMCOfzDmMhFi1dDfnOJZTVUXqBbfa/CXwVD+MLLpY9HlI9eKODkL 4R/DfWuyrJZKCgrATG3Tx/zh2lmWNGzcFt6+XQjviD63PSUmS32x79t2rVwgXZgmY/Ss JcjoFemgtBWyL8tilV5VPFDg6t/TlHjxhb0y1lOCehMvKfpxAkfYXNYPkyg0hGhTjmG6 O1fA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=nlrxSROI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x20si902329edv.305.2020.09.11.02.45.31; Fri, 11 Sep 2020 02:45:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@infradead.org header.s=casper.20170209 header.b=nlrxSROI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725803AbgIKJoi (ORCPT + 99 others); Fri, 11 Sep 2020 05:44:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725730AbgIKJoh (ORCPT ); Fri, 11 Sep 2020 05:44:37 -0400 Received: from casper.infradead.org (casper.infradead.org [IPv6:2001:8b0:10b:1236::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48A6FC061573; Fri, 11 Sep 2020 02:44:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=R2qGF7yERmMAU8dGcjKeKqRGk5IWwYFjQLOwCzYOvew=; b=nlrxSROIaG+nAIAL365fVBrVNP AK6QNG8gmrAANAQW8v+1ItEcHuCoLR7ztlhn3Bcqq8pHy/zBUDaekucUvrVQzycr2GVW3ss3qL1go 1NBysp8+kAjTtZLh3IdrjNbSXTKIyHbJ5dl+5Z5LFgR59N+s8AaWifub4I+7hg3iIkCHjGFKt6f8B xYbVtvQdwt6xKTUKZdOQJq3YzKAhEPIgEv0r7d/TjgF1ylq2lkjJThllLOS4xM5bF7PLdmX9YDq0d 5prNXsUxp02n8N9E6ZkF2dEPacKESmy4jyFUwLuM7+x6reR8GtDuyMDmUOmLwuRHpPUNO1rnvrAov 5FHZcWIw==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by casper.infradead.org with esmtpsa (Exim 4.92.3 #3 (Red Hat Linux)) id 1kGfbc-0003k6-Kt; Fri, 11 Sep 2020 09:44:32 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 749623050F0; Fri, 11 Sep 2020 11:44:31 +0200 (CEST) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 5F21C2B06B001; Fri, 11 Sep 2020 11:44:31 +0200 (CEST) Date: Fri, 11 Sep 2020 11:44:31 +0200 From: peterz@infradead.org To: Gabriel Krisman Bertazi Cc: luto@kernel.org, tglx@linutronix.de, keescook@chromium.org, x86@kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, willy@infradead.org, linux-kselftest@vger.kernel.org, shuah@kernel.org, kernel@collabora.com, Paul Gofman Subject: Re: [PATCH v6 5/9] kernel: Implement selective syscall userspace redirection Message-ID: <20200911094431.GF1362448@hirez.programming.kicks-ass.net> References: <20200904203147.2908430-1-krisman@collabora.com> <20200904203147.2908430-6-krisman@collabora.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200904203147.2908430-6-krisman@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Sep 04, 2020 at 04:31:43PM -0400, Gabriel Krisman Bertazi wrote: > +struct syscall_user_dispatch { > + char __user *selector; > + unsigned long dispatcher_start; > + unsigned long dispatcher_end; > +}; > +int do_syscall_user_dispatch(struct pt_regs *regs) > +{ > + struct syscall_user_dispatch *sd = ¤t->syscall_dispatch; > + unsigned long ip = instruction_pointer(regs); > + char state; > + > + if (likely(ip >= sd->dispatcher_start && ip <= sd->dispatcher_end)) > + return 0; If you use {offset,size}, instead of {start,end}, you can write the above like: if (ip - sd->dispatcher_offset < sd->dispatcher_size) return 0; which is just a single branch.