Received: by 10.213.65.68 with SMTP id h4csp687946imn; Tue, 13 Mar 2018 18:20:00 -0700 (PDT) X-Google-Smtp-Source: AG47ELtIKYFf1txLmZepx9i8pmpegq/JnBYrWZ8EaPlypOOtc8zDQvbo27zNqGRRLZ8Tp1514GoC X-Received: by 10.99.9.195 with SMTP id 186mr2126011pgj.152.1520990400221; Tue, 13 Mar 2018 18:20:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520990400; cv=none; d=google.com; s=arc-20160816; b=SGBRyhDFyrJgfv7tmLfDrnyd4HFbilZ7r7GHGCaFYWRl9BmnuW+8My1gDOLyrE7chj YparR8BbAKr8pkI3wyfs6Qcbow8mCK88ca7EYk4yNHNMV30e88QAUdWRx69F2MEg7j7H 2ddeIBVWtkfc6S3vs9aorDNoZ70i6pBSNMyeeh/8yko0ZIXBK6b5Cl59pozvbCs6MZBK +qEY/m8lsnaBXiOB2rDZkjx8xbcDsledmJ46QA4SQrqZLOG+xH2Qxv6bOYvnJxtbhJ2s xjdIqrNbhXDtJ3foYKeQ0n6K5oSF0YOUEJC0Oq6XJFQRoAv2LsXA6N2G2i8cnGtYI1l8 /zZA== 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 :arc-authentication-results; bh=JRkuCtiO2q99zk6TMZ1olV8cgEf7p4M6E1DtDTFheuo=; b=ap32+j6tIFmrdc+BxaYqiFw66qhF6EqFYnM8LXTJ5sgNET4wOf0EHHrZGC7BmcTMDh t2EoAVIJd01nzoEKCE/X++SER9/L0oxRQFKiRJvWYGN3ktPh3hNO6c9fODaN5p3yfQOL ex8BUmtHWO5JPAhJP7/zCfDWj8CF0m2oaU8VumowsDIXOFAvi+iBZLTqLP9rMVe0niPC hCsaa9UvoXALDh9Sd+CaVZyHw5Okbvv1EWk8eGmOi/ZK8gW9cf7SV19oUmznAvPaleF8 d3Eldj6awNfeAJWXlN4gsywJpxa0SIoR8j8wf2Y3lYunzGTfoFB0qOgNDQ79reYiYkvU reJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=pZVLaGtv; 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 v15si980536pgt.635.2018.03.13.18.19.46; Tue, 13 Mar 2018 18:20:00 -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=pZVLaGtv; 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 S933034AbeCNBSs (ORCPT + 99 others); Tue, 13 Mar 2018 21:18:48 -0400 Received: from mail-qt0-f195.google.com ([209.85.216.195]:44391 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932634AbeCNBSr (ORCPT ); Tue, 13 Mar 2018 21:18:47 -0400 Received: by mail-qt0-f195.google.com with SMTP id g60so1778795qtd.11; Tue, 13 Mar 2018 18:18:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=JRkuCtiO2q99zk6TMZ1olV8cgEf7p4M6E1DtDTFheuo=; b=pZVLaGtvmAmO4UvOmSj/N1ZTb2VtQMOuDmBB7aHBRKq5iqh2LuXN4p/CMaOhZ8o0Am wDYFNTdfxnFZiAxF6OnpcWU5pGQEAxnKOhezfWQH1agaffbPfBh14KD2lTOUEIjnh8V6 H3yr+8iDLy/CMH5Z1nPuxdO34X+zHqM5PeX/vbEv0T9TQFMNvF3jiuTdWEnQWm8OCSyh tAi9J+bx1OqlitG4clOjHDMg1nBpWgKwx6apIEDKwF6F3DNetgRhsC3H6Fxc5Ba7r4Bq 96OMaz2R6JotStyAJlagxgcl7dgnphC0dNyxqeb40iTnVIBkWP3t+MTCSZXQGoIkPz/M Y4Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=JRkuCtiO2q99zk6TMZ1olV8cgEf7p4M6E1DtDTFheuo=; b=BZEdeLUhFyJ8QNaFFger3SnmtAhANStt/nJ4IwDL9UgS39t1Kd3gelSmZcnNwoaGQV 1Ysysc8E6qK0lVPclrilrRSKn2dSkEcOoOsPPkiysbPJwVzahNePAPOUjqy8kxouWRXD iouyIPOTAuo5qD4YU1LX7dr3qP2PP5DwDQQT9HMzWLkpbXf9gysrC9nO+KBSvixoYeLT M+skEjPD2R/0o3prgfdcs16vl6WGFTrXVpbXVot7Zds1ssvN6ILTdnKFFQW3ErMLawVi 2JqyWcwsTNcpkKJiQFC4Jru/2EZY0mNhPeyk1JE+rTY4BttnIYHQYUWEdFyXJClUFy9w el4A== X-Gm-Message-State: AElRT7EVCcGR0itHh5OaY9GjGQT16LQrBtXpEGNl+exdiLEY6NdPbwHO zTgea+y2iIk2onCrZvXVeC4gEexkh2bBMqdZ0AQ= X-Received: by 10.200.55.157 with SMTP id d29mr4370125qtc.61.1520990326198; Tue, 13 Mar 2018 18:18:46 -0700 (PDT) MIME-Version: 1.0 Received: by 10.200.20.134 with HTTP; Tue, 13 Mar 2018 18:18:45 -0700 (PDT) In-Reply-To: <423b529d48c54eba9f7ed51922814d46@AcuMS.aculab.com> References: <1520598613-3641-1-git-send-email-andreaschristofo@gmail.com> <5AA464DE.90100@broadcom.com> <423b529d48c54eba9f7ed51922814d46@AcuMS.aculab.com> From: Daniel Micay Date: Tue, 13 Mar 2018 21:18:45 -0400 Message-ID: Subject: Re: [PATCH] drivers: net: wireless: ath: ath9: dfs: remove VLA usage To: David Laight Cc: Arend van Spriel , Andreas Christoforou , Kees Cook , Kernel Hardening , QCA ath9k Development , Kalle Valo , "linux-wireless@vger.kernel.org" , Netdev , kernel list 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 No, it's undefined behavior to write to a const variable. The `static` and `const` on the variable both change the code generation in the real world as permitted / encouraged by the standard. It's placed in read-only memory. Trying to write to it will break. It's not "implemented defined" to write to it, it's "undefined behavior" i.e. it's considered incorrect. There a clear distinction between those in the standard. You're confusing having a real `const` for a variable with having it applied to a pointer. It's well-defined to cast away const from a pointer and write to what it points at if it's not actually const. If it is const, that's broken. There's nothing implementation defined about either case. The C standard could have considered `static const` variables to work as constant expressions just like the C++ standard. They borrowed it from there but made it less useful than const in what became the C++ standard. They also used stricter rules for the permitted implicit conversions of const pointers which made those much less usable, i.e. converting `int **` to `const int *const *` wasn't permitted like C++. I don't think the difference between C and C++ const pointer conversions, it's a quirk of them being standardized on different timelines and ending up with different versions of the same thing. On the other hand, they might have left out having ever so slightly more useful constant expressions on purpose since people can use #define.