Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp5628605ybi; Sun, 7 Jul 2019 09:04:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqybBrnppFm7Lh8zjWItLceabtMHWkygJo4jJru/DJCI3ol+/N9smpAKLLquUR98M74i1QsV X-Received: by 2002:a65:4304:: with SMTP id j4mr18055929pgq.419.1562515448387; Sun, 07 Jul 2019 09:04:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562515448; cv=none; d=google.com; s=arc-20160816; b=uBBHbZnHkn6anQg/k/4X9jhWgmSphYF6pSTwMMZpJxxsO1Rd5FLz6zn7O4uJ3S16Rq z8fPpCP5Ok4Yba8CZMo7G1FuMmrLNfB8iMYa2yf0l7lXxPrUmThxvMbVOA9p3tMWTN5e coN48FhEopHznTpiTQFVPY4xd04LNbvJ/7KvZ8IxgXzyTVJdNzmvHB3YWHGAEraVxd85 w9ML6s7YKwpaFY8yot85dkDeYOOKIBtSBX2ouZPItWk0J45FdK6LBwZNEp5fFFIrjQ11 vKwoTFApxRBP/O+n3rq5f6xpe6oDo9T23u6YhVwK1X34mOGeEFqWq6tE6EAs7yY/O8Pm M1Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=b4nSr8C4VJLXjo2WMEW+SSHBlpQfsTI/51+kxtK6GPA=; b=wLyDZg21U5o7tL7fSnUrDBZZK97WS/NT4dGRxVuSgw799nWId8g2P0N5V5lRWiPKTZ /fq2wQZxsBiqMO7HHuHnCSJhOedGa1t9iLaWNYPLorYN1sMfRt2+jLxAX5iP6SUNU8TW Gt8dZjcfZ9LeSYAYytaVMUXHbOXmSzLdu8uI9lb8XYvGTce8kmCSvLgo0/wgP6VbzYQT p20b+FjZyXS/nvXlvRqofHZ0bUSZJo9ihY3D2ph3vUcrM/MkEHTb3RNpm+cSy5HJ5rcZ 5ijsZA7RDA9pRdUZnqteNXcWJHCzo8rJckLkDfUDI2MZbM53PRcVteTgm7oGHcmuCsy4 FofA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YvbEjwwJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si15060528pgc.75.2019.07.07.09.03.52; Sun, 07 Jul 2019 09:04:08 -0700 (PDT) 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=@gmail.com header.s=20161025 header.b=YvbEjwwJ; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727325AbfGGPts (ORCPT + 99 others); Sun, 7 Jul 2019 11:49:48 -0400 Received: from mail-io1-f68.google.com ([209.85.166.68]:35311 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725901AbfGGPts (ORCPT ); Sun, 7 Jul 2019 11:49:48 -0400 Received: by mail-io1-f68.google.com with SMTP id m24so19910255ioo.2; Sun, 07 Jul 2019 08:49:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=b4nSr8C4VJLXjo2WMEW+SSHBlpQfsTI/51+kxtK6GPA=; b=YvbEjwwJ0MctJmyVW2533O+SajBFaUp96J65ETZP+TatSMINnLBybugK6AoA58+MfZ yd15CnKnxIQnb+432TC0RnoimNjVmfkheHmHbAo/DwijS92RSoszBySc4s83WHsLef+p ZXtoF5JncfYaRuocLhwSQN5OoVp+NjBZozVDL1n9KB5gbQrKGBokpNMsMHF7ScczNG9W VErLPBTv8kbBqF0FjQSgB5IYmd3oOKSbu8CTCDMwj97kfsW30VCistO+f40EnHTS7A1p IDbwYqJzeKXw/J4laVfJb/T57lFaIteuOcrYiq8sMQEpG3HKhJKB2f+Q6gR5Akx+kl5u 1M5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=b4nSr8C4VJLXjo2WMEW+SSHBlpQfsTI/51+kxtK6GPA=; b=GMxOMXCqS3LHnlI5y3C+V08+j4JME1dV+tGpDw7pOycRfYqcti+GGeOESLK4PLidbJ P+VRqkFKgwVj8n3IugOflX3WmWRIM7WAy9hZtAktJS8XJuvi+CRanH+9NOIbA3BaN0Vs xVaW/Ki4uCsXhBn0rxU/FrbqiguIEyhd3xJR75Yji/abPoFtCX5SZshVoz0+I9ZHC8bZ kM5Sd7IvUz+hSWv3J2dRJJRiky3JkCbytXldIYfg4lojlnmUsOHzuzHTMWyIog2UVxYB UYIdFMe7R+1yxGEXtMT7/oeCbyNx1NPjlNPUrgY7GQnfJJiQi1tBBXOtgTLaLJ8cBxNI iqJQ== X-Gm-Message-State: APjAAAX8VcdiOUUqqdEBMcE+SiFtX8FIF8for0C2JIM1DGglstulh8Bs R0lE1uzjWSbjTt68XgnEkRYvG3WFnJK2qi4qRA4= X-Received: by 2002:a6b:c9d8:: with SMTP id z207mr13631851iof.184.1562514586987; Sun, 07 Jul 2019 08:49:46 -0700 (PDT) MIME-Version: 1.0 References: <1562410493-8661-1-git-send-email-s.mesoraca16@gmail.com> <1562410493-8661-7-git-send-email-s.mesoraca16@gmail.com> <20190706192852.GO17978@ZenIV.linux.org.uk> In-Reply-To: <20190706192852.GO17978@ZenIV.linux.org.uk> From: Salvatore Mesoraca Date: Sun, 7 Jul 2019 17:49:35 +0200 Message-ID: Subject: Re: [PATCH v5 06/12] S.A.R.A.: WX protection To: Al Viro Cc: linux-kernel@vger.kernel.org, Kernel Hardening , linux-mm@kvack.org, linux-security-module@vger.kernel.org, Brad Spengler , Casey Schaufler , Christoph Hellwig , Jann Horn , Kees Cook , PaX Team , "Serge E. Hallyn" , Thomas Gleixner , James Morris Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Al Viro wrote: > > On Sat, Jul 06, 2019 at 12:54:47PM +0200, Salvatore Mesoraca wrote: > > > +#define sara_warn_or_return(err, msg) do { \ > > + if ((sara_wxp_flags & SARA_WXP_VERBOSE)) \ > > + pr_wxp(msg); \ > > + if (!(sara_wxp_flags & SARA_WXP_COMPLAIN)) \ > > + return -err; \ > > +} while (0) > > + > > +#define sara_warn_or_goto(label, msg) do { \ > > + if ((sara_wxp_flags & SARA_WXP_VERBOSE)) \ > > + pr_wxp(msg); \ > > + if (!(sara_wxp_flags & SARA_WXP_COMPLAIN)) \ > > + goto label; \ > > +} while (0) > > No. This kind of "style" has no place in the kernel. > > Don't hide control flow. It's nasty enough to reviewers, > but it's pure hell on anyone who strays into your code while > chasing a bug or doing general code audit. In effect, you > are creating your oh-so-private C dialect and assuming that > everyone who ever looks at your code will start with learning > that *AND* incorporating it into their mental C parser. > I'm sorry, but you are not that important. > > If it looks like a function call, a casual reader will assume > that this is exactly what it is. And when one is scanning > through a function (e.g. to tell if handling of some kind > of refcounts is correct, with twentieth grep through the > tree having brought something in your code into the view), > the last thing one wants is to switch between the area-specific > C dialects. Simply because looking at yours is sandwiched > between digging through some crap in drivers/target/ and that > weird thing in kernel/tracing/, hopefully staying limited > to 20 seconds of glancing through several functions in your > code. > > Don't Do That. Really. I understand your concerns. The first version of SARA didn't use these macros, they were added because I was asked[1] to do so. I have absolutely no problems in reverting this change. I just want to make sure that there is agreement on this matter. Maybe Kees can clarify his stance. Thank you for your suggestions. [1] https://lkml.kernel.org/r/CAGXu5jJuQx2qOt_aDqDQDcqGOZ5kmr5rQ9Zjv=MRRCJ65ERfGw@mail.gmail.com