Received: by 10.223.164.202 with SMTP id h10csp3517808wrb; Tue, 28 Nov 2017 12:37:46 -0800 (PST) X-Google-Smtp-Source: AGs4zMaBuM2/9O/Nn+GdHbA7gChZqYha5yPfQJJQvRmsYUN2yeYYes3RuZtJrKelveDETAU4K3Tc X-Received: by 10.99.123.21 with SMTP id w21mr376645pgc.67.1511901466120; Tue, 28 Nov 2017 12:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511901466; cv=none; d=google.com; s=arc-20160816; b=zznJk+6iqaxcjqXAOQYUKsmwx4clPdchV8+9zKRGrfsyYXYMDZEtucL8vImcdAqlOs SPy/KNc/z8bmRqj2WoyNMPIPzlm9pzq3YMjYv74E/a8uNU3SHzHLTKyQzye4znJQ5Apc /ugglvvb0y2s/WUqd2tXpigjEcBiU4I5uTvQCpUCpxOywYewVjcKkXlRQGI5s/DJ+vgZ G9N49NfUhCyRTaN5tNRWr2AYWb+b17vWsTWHpJhrmO4gSEhSNPB//Wku83hLTanXhj8J nhEUoFzTdJt0rwMvLZ2GuvogFssB48GtYQcTCj/oAeSWLMTPOBiHAI70A5KaOBHGgLK3 0JPw== 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 :references:in-reply-to:mime-version:dkim-signature:dkim-signature :arc-authentication-results; bh=oy4dNfu1S6YJhKn3eCWT0PNldcAlc580yqPGwlSeWqg=; b=o+7Pd/gICUthpsJ/PR62UJTbjK9w8xdJJD9YOzQe6sOPaeXGHCjLkXjc/zj5/ureBn YY+Lno+ZPDD2iRpVreLXg5G0Lx3g55vUpZNkfamu7aV/za/wlIyUmwH39zcYZGxoDN7a ckGAMcOkMK/gLEwT5iF7Xryut0Af1yon62nvzca90M5vRCD1VDdKXDiDLxrnV5MljmQ3 KfCJgl/18XfdI8Xmqjs8mQvJdU89fUss8ihqLTP2CUqR3ql/UI+odDZ/+fTI3pWE/jd/ 2RJAbA66UoCy0FkCOJqHZfFC4HiOSRVFcRT0dJ7tKpHlbn55qyNkmJtCdwXB6rJ4PzNR b5VA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@google.com header.s=20161025 header.b=GCN4M9Qd; dkim=fail header.i=@chromium.org header.s=google header.b=R43M04qe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p33si11831pld.453.2017.11.28.12.37.35; Tue, 28 Nov 2017 12:37:46 -0800 (PST) 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=fail header.i=@google.com header.s=20161025 header.b=GCN4M9Qd; dkim=fail header.i=@chromium.org header.s=google header.b=R43M04qe; 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=fail (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932197AbdK1Ue4 (ORCPT + 70 others); Tue, 28 Nov 2017 15:34:56 -0500 Received: from mail-ua0-f193.google.com ([209.85.217.193]:40111 "EHLO mail-ua0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932144AbdK1Uex (ORCPT ); Tue, 28 Nov 2017 15:34:53 -0500 Received: by mail-ua0-f193.google.com with SMTP id i92so1458787uad.7 for ; Tue, 28 Nov 2017 12:34:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=oy4dNfu1S6YJhKn3eCWT0PNldcAlc580yqPGwlSeWqg=; b=GCN4M9QdNKoX98B9Z5AyyYnUf/nvVfTCfzKvTYdzWVIP42cVVQdHALhzbubOZqZ6il qIFwPm09fsJ8BX6AMhjeD179nt2lB302ILJhWf1WEPGVcAmw2rkYnJlKpKFQgc1P+XQR i9Mffyo1erHQ2lcb5Zs00HaQXWyrGgi7VuTrdXI8qh0y+cyX6wuo6glm0nSa0s2f640E m7MG+iENyIX58MdoxPBz0QUORKbLvxnNIO9J7wBSs9s40JPUvNLz5RG8swNYUHSY7Am5 1k1vP2i9qWskJnMZEXlSxbk48LglXIX7QCl5PnezugKzeNseF4KsfOcgo4pVQATdh4uQ GkDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=oy4dNfu1S6YJhKn3eCWT0PNldcAlc580yqPGwlSeWqg=; b=R43M04qeaFY6FUh8k5DBZq7/8wbQhHcZXDufpESo5ik369EU3Mjcf3B3q6MxlfFJhI 5T+6OF0zDxSssDJ5FOi00rsTk1WRKY7rHzdA63ZBfb7sNjB0+S241/Ewbmge4UMSM6o6 0kVzxwmCiGlz9vLRSQ+PdV5uaC+/czxWdcLKc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=oy4dNfu1S6YJhKn3eCWT0PNldcAlc580yqPGwlSeWqg=; b=qnlKMqJzwsF6ZRe7Ek6BKuTLPEV10DfCMTOx5SaJe+cd2qeFuJyNa7cY1WGYDrwSlT rvcnX01rBAFDLIQ5nSTOx2IqgL3KZNFk3ADCnaeXY4dmFsgvr1fYrx70BgoMSrcijpMF 1bKpZDRqZ4/rJrE9ortD8Y729NLl4xfVADfurURsWw2iTt33smyA/ulUSt0nn8J/y178 2ObibTgwYm14ZCV6NUcj9my9BHbHj/diV7qrqJazrErbzYXsN14DIXRYMS124Lb4uwuu WfY8GHv7AJ+2DdamGB+LuQJLBGEdLPpLChcgH6QiIDqsVf5f1StqNYmRXSAWpkbTD1It kSzA== X-Gm-Message-State: AJaThX6lasChsYKocTOAr7FSj8Vsb/V8x4EL6tzjnjolVtyHryweweFW n5pMew1yLWJvPt4QEwScKLC8eTDJitpAMGrLVHCCKg== X-Received: by 10.176.71.226 with SMTP id w34mr421710uac.33.1511901292789; Tue, 28 Nov 2017 12:34:52 -0800 (PST) MIME-Version: 1.0 Received: by 10.31.49.15 with HTTP; Tue, 28 Nov 2017 12:34:51 -0800 (PST) In-Reply-To: References: <20171127235253.GA20384@embeddedor.com> <20171128120512.Horde.1mz61Up1PsNtyHbrjWmK8L7@gator4166.hostgator.com> <20171128122235.Horde.vFP-9ZfAP0f9BFNePB8Z8xi@gator4166.hostgator.com> <20171128190032.2b1fa464@alans-desktop> From: Kees Cook Date: Tue, 28 Nov 2017 12:34:51 -0800 X-Google-Sender-Auth: FZ9gNB30cThTfj84PoBbWT9FRqY Message-ID: Subject: Re: [PATCH] x86/syscalls: Mark expected switch fall-throughs To: Thomas Gleixner Cc: Linus Torvalds , Alan Cox , "Gustavo A. R. Silva" , Ingo Molnar , "H. Peter Anvin" , "the arch/x86 maintainers" , LKML 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 On Tue, Nov 28, 2017 at 12:08 PM, Thomas Gleixner wrote: > On Tue, 28 Nov 2017, Linus Torvalds wrote: > >> On Tue, Nov 28, 2017 at 11:00 AM, Alan Cox wrote: >> > >> > The notation in question has been standard in tools like lint since the >> > end of the 1970s >> >> Yes. >> >> That said, maybe one option would be to annotate the "case:" and >> "default:" statements if that makes people happier. >> >> IOW, we could do something like >> >> #define fallthrough __atttibute__((fallthrough)) >> >> and then write >> >> fallthrough case 1: >> ... >> >> which while absolutely not traditional, might look and read a bit more >> logical to people. I mean, it literally _is_ a "fallthrough case", so >> it makes semantic sense. >> >> Or maybe people hate that kind of "making up new syntax" too? > > Fine with me. Better than any comment. One of the strong reasons to do this with comments is because it lets us leverage existing static analyzers. The long-standard method of marking fall-through has been with comments, and that's what the kernel should be (and has been) doing. If we invent another method, we'll be shooting ourselves in the foot by making it harder to spot these cases using existing tools. Fall-through is uncommon, and it's not a big price to carry these comments when the gain is so clear. The most "ugly" cases of these are when the switch statement is _entirely_ fall-through (usually for bit-width processing of some kind), but again, they're rare in the grand scheme of things. -Kees -- Kees Cook Pixel Security From 1585342907000306431@xxx Tue Nov 28 20:26:53 +0000 2017 X-GM-THRID: 1585265423856272058 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread