[committed] analyzer: fixes to free of non-heap detection [PR104560]

2022-02-16 Thread David Malcolm via Gcc-patches
g/analyzer/realloc-1.c (test_7): Updated expected wording. * gcc.dg/analyzer/vla-1.c (test_2): New. Prune output from -Wfree-nonheap-object. Signed-off-by: David Malcolm --- gcc/analyzer/diagnostic-manager.cc| 105 +- gcc/analyzer/engine.cc

[committed] analyzer: fix ICE on cast to NULL type [PR104524]

2022-02-15 Thread David Malcolm via Gcc-patches
call get_or_create_cast if type is non-NULL. gcc/testsuite/ChangeLog: PR analyzer/104524 * gcc.dg/analyzer/pr104524.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-manager.cc | 5 +++-- gcc/testsuite/gcc.dg/analyzer/pr104524.c | 9 + 2 files changed

[committed] analyzer: ignore uninitialized uses of empty types [PR104274]

2022-02-11 Thread David Malcolm via Gcc-patches
nalyzer/104274 * region-model.cc (region_model::check_for_poison): Ignore uninitialized uses of empty types. gcc/testsuite/ChangeLog: PR analyzer/104274 * gcc.dg/analyzer/torture/empty-struct-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/r

[committed] analyzer: handle more casts of string literals [PR98797]

2022-02-10 Thread David Malcolm via Gcc-patches
decl. gcc/testsuite/ChangeLog: PR analyzer/98797 * gcc.dg/analyzer/casts-1.c: Mark xfails as fixed; add further test coverage for casts of string literals. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-manager.cc| 19 +++ gcc/analyzer/regio

[committed] analyzer: fix testsuite issues seen with mingw [PR102052]

2022-02-10 Thread David Malcolm via Gcc-patches
): Use __SIZE_TYPE__ rather than hardcoding long unsigned int. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/fields.c| 2 +- gcc/testsuite/gcc.dg/analyzer/gzio-3.c| 2 +- gcc/testsuite/gcc.dg/analyzer/gzio-3a.c | 2 +- gcc/testsuite/gcc.dg/analyzer/pr98969.c | 4

[committed] analyzer: more uninit test coverage

2022-02-09 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/uninit-1.c: Add test coverage for shifts, comparisons, +, -, *, /, and __builtin_strlen. * gcc.dg/analyzer/uninit-CWE-457-examples.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/uninit-1.c | 85 + .../gcc.dg/

[committed] analyzer: fix hashing of bit_range_region::key_t [PR104452]

2022-02-08 Thread David Malcolm via Gcc-patches
New. (selftest::analyzer_region_model_cc_tests): Call it. * region.h (bit_range_region::key_t::hash): Fix hashing of m_bits to avoid using uninitialized data. gcc/testsuite/ChangeLog: PR analyzer/104452 * gcc.dg/analyzer/pr104452.c: New test. Signed-off-by: David Mal

Re: [PATCH] analyzer: Fix tests for glibc 2.35 [PR101081]

2022-02-08 Thread David Malcolm via Gcc-patches
On Fri, 2022-02-04 at 11:35 -0500, Joel Teichroeb via Gcc-patches wrote: > In recent versions of glibc fopen has __attribute__((malloc)). > Since we can not detect wether this attribute is present or not, > we avoid including stdio.h and instead forward declare what we > need in each test. > >

[committed] analyzer: fix ICE on realloc of non-heap [PR104417]

2022-02-07 Thread David Malcolm via Gcc-patches
tion. (tainted_allocation_size::emit): Likewise. (region_model::check_dynamic_size_for_taint): Likewise. gcc/testsuite/ChangeLog: PR analyzer/104417 * gcc.dg/analyzer/pr104417.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/sm-taint.cc | 9 - gcc/tests

[committed] analyzer: fixes to memcpy [PR103872]

2022-02-07 Thread David Malcolm via Gcc-patches
nate versions of test cases in which the calls to memcpy are hidden from the optimizer. Add further test cases. * gcc.dg/analyzer/taint-size-1.c: Add test coverage for memcpy with tainted size. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-impl-call

[committed] analyzer: fixes to realloc-handling [PR104369]

2022-02-03 Thread David Malcolm via Gcc-patches
. * gcc.dg/analyzer/realloc-4.c: New test. * gcc.dg/analyzer/taint-realloc.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/engine.cc| 2 +- gcc/analyzer/region-model-impl-calls.cc | 33 ++- gcc/analyzer/sm-taint.cc | 1

[committed] analyzer: fix zero-fill of calloc

2022-02-03 Thread David Malcolm via Gcc-patches
c.dg/analyzer/calloc-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-impl-calls.cc | 4 +++- gcc/testsuite/gcc.dg/analyzer/calloc-1.c | 27 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.dg/analyzer/calloc

[committed] docs: mention analyzer interaction with -ftrivial-auto-var-init [PR104270]

2022-02-02 Thread David Malcolm via Gcc-patches
On Wed, 2022-02-02 at 17:14 +, Qing Zhao wrote: > Hi, David, > > Thank you for fixing this issue! > > > On Feb 2, 2022, at 9:06 AM, David Malcolm via Gcc-patches < > > gcc-patches@gcc.gnu.org> wrote: > > > > GCC 12 has gained two features fo

[committed] analyzer: fix missing check for uninit of return values

2022-02-02 Thread David Malcolm via Gcc-patches
to-var-init-zero.c: Move to... * gcc.dg/analyzer/torture/uninit-trivial-auto-var-init-zero.c: ...here. Signed-off-by: David Malcolm --- gcc/analyzer/region-model.cc | 21 ++- gcc/analyzer/region-model.h | 2 -- gcc/analyzer/region.cc

[committed] analyzer: consolidate duplicate code in region::calc_offset

2022-02-02 Thread David Malcolm via Gcc-patches
fset): Consolidate effectively identical cases. Signed-off-by: David Malcolm --- gcc/analyzer/region.cc | 48 +- 1 file changed, 5 insertions(+), 43 deletions(-) diff --git a/gcc/analyzer/region.cc b/gcc/analyzer/region.cc index 9d8fdb22271..77554b86143 10

[committed] analyzer: implement bit_range_region

2022-02-02 Thread David Malcolm via Gcc-patches
New test. Signed-off-by: David Malcolm --- gcc/analyzer/analyzer.h | 1 + gcc/analyzer/region-model-manager.cc | 20 + gcc/analyzer/region-model.cc | 14 +++ gcc/analyzer/region-model.h | 4 + gcc/analyzer/regio

[committed] analyzer: stop -ftrivial-auto-var-init from suppressing uninit warnings [PR104270]

2022-02-02 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/uninit-trivial-auto-var-init-pattern.c: New test. * gcc.dg/analyzer/uninit-trivial-auto-var-init-uninitialized.c: New test. * gcc.dg/analyzer/uninit-trivial-auto-var-init-zero.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/r

[committed] analyzer: show region creation events for uninit warnings

2022-01-27 Thread David Malcolm via Gcc-patches
gcc.dg/analyzer/uninit-alloca.c: New test. * gcc.dg/analyzer/uninit-pr94713.c: Add dg-message directive for expected region creation event. * gcc.dg/analyzer/uninit-pr94714.c: Likewise. * gcc.dg/analyzer/zlib-3.c: Likewise. Signed-off-by: David Malcolm -

[committed] analyzer: fix missing uninit warning on args to stdio builtins [PR104224]

2022-01-26 Thread David Malcolm via Gcc-patches
ite/ChangeLog: PR analyzer/104224 * gcc.dg/analyzer/pr104224.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/region-model.cc | 11 +++ gcc/analyzer/region-model.h | 2 + gcc/testsuite/gcc.dg/analyzer/pr104224.c | 106 ++

[committed] analyzer: fix sense in range::add_bound [PR94362]

2022-01-26 Thread David Malcolm via Gcc-patches
On Sun, 2022-01-23 at 17:34 +0100, Mikael Morin wrote: > Hello, > > Le 21/01/2022 à 00:59, David Malcolm via Gcc-patches a écrit : > > diff --git a/gcc/analyzer/constraint-manager.cc > > b/gcc/analyzer/constraint-manager.cc > > index 568e7150ea7..7c4a85bbb24 10

Re: [PATCH] libgccjit: Add support for register variables [PR104072]

2022-01-24 Thread David Malcolm via Gcc-patches
On Sat, 2022-01-22 at 19:29 -0500, Antoni Boucher wrote: > Hi. > > Le mardi 18 janvier 2022 à 18:49 -0500, David Malcolm a écrit : > > On Mon, 2022-01-17 at 19:46 -0500, Antoni Boucher via Gcc-patches > > wrote: > > > I missed the comment about the new define, so

Re: [PATCH] libgccjit: Add option to hide stderr logs [PR104073]

2022-01-24 Thread David Malcolm via Gcc-patches
Dave > > Le mardi 18 janvier 2022 à 18:22 -0500, David Malcolm a écrit : > > On Mon, 2022-01-17 at 21:02 -0500, Antoni Boucher via Gcc-patches > > wrote: > > > Hi. > > > This option will be useful for rustc_codegen_gcc to hide the > > >

[committed] testsuite: guard usage of _Float16 in analyzer test [PR104150]

2022-01-22 Thread David Malcolm via Gcc-patches
Committed to trunk as r12-6818-ga1fb81bda97014ba14d55c4c2e143d31ffe2e264. gcc/testsuite/ChangeLog: PR analyzer/104150 * gcc.dg/analyzer/pr104089.c: Add "dg-add-options float16" and "dg-require-effective-target float16" directives. Signed-off-by: Dav

[committed] analyzer: reject ((i + 1 > 0) && (i < 0)) for integers [PR94362]

2022-01-20 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/pr94362-1.c: New test. * gcc.dg/analyzer/pr94362-2.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/constraint-manager.cc| 172 -- gcc/analyzer/constraint-manager.h | 15 +- gcc/analyzer/region-model.cc | 5 +- gc

[committed] analyzer: add regression test [PR103685]

2022-01-20 Thread David Malcolm via Gcc-patches
-pc-linux-gnu. Pushed to trunk as r12-6781-gf5a9d76be849b4cf20b1b687febc34a937381dc3. gcc/testsuite/ChangeLog: PR analyzer/103685 * gcc.dg/analyzer/torture/pr103685.c: New test. Signed-off-by: David Malcolm --- .../gcc.dg/analyzer/torture/pr103685.c| 33

[committed] Update per-file selftest and finalization hooks for .c to .cc renaming

2022-01-19 Thread David Malcolm via Gcc-patches
On Wed, 2022-01-19 at 14:46 +0100, Richard Biener wrote: > On Wed, Jan 19, 2022 at 2:45 PM David Malcolm via Gcc-patches > wrote: > > > > This is mostly a mechanical change, apart from: > > - fix the name of opt_proposer_c to match its filename > > (opt-sugges

[PATCH] Update per-file selftest and finalization hooks for .c to .cc renaming

2022-01-19 Thread David Malcolm via Gcc-patches
(cp_tree_cc_tests): ...this. * pt.cc (cp_pt_c_tests): Rename to... (cp_pt_cc_tests): ...this. * tree.cc (cp_tree_c_tests): Rename to... (cp_tree_cc_tests): ...this. Signed-off-by: David Malcolm --- gcc/attribs.cc | 2 +- gcc/bitmap.cc | 2 +-

Re: [PATCH] libgccjit: Add support for register variables [PR104072]

2022-01-18 Thread David Malcolm via Gcc-patches
On Mon, 2022-01-17 at 19:46 -0500, Antoni Boucher via Gcc-patches wrote: > I missed the comment about the new define, so here's the updated > patch. Thanks for the patch. > > Le lundi 17 janvier 2022 à 19:24 -0500, Antoni Boucher via Jit a > écrit : > > Hi. > > This patch add supports for

Re: [PATCH] libgccjit: Add option to hide stderr logs [PR104073]

2022-01-18 Thread David Malcolm via Gcc-patches
On Mon, 2022-01-17 at 21:02 -0500, Antoni Boucher via Gcc-patches wrote: > Hi. > This option will be useful for rustc_codegen_gcc to hide the error > about unsupported 128-bit integer types. > > David, if you know of a better way to check if these types are > supported than creating such a type

Re: [PATCH] libgccjit: Add support for bitcasts [PR104071]

2022-01-18 Thread David Malcolm via Gcc-patches
On Mon, 2022-01-17 at 19:30 -0500, Antoni Boucher via Gcc-patches wrote: > I was missing the define, so I added it. > Here's the new patch with it. Thanks for the patch. > Le lundi 17 janvier 2022 à 17:18 -0500, Antoni Boucher via Jit a > écrit : > > Hi. > > This patch add support for bitcasts

[committed] analyzer: fix ICE on unary ops folding to casts of constants [PR104089]

2022-01-18 Thread David Malcolm via Gcc-patches
sert that we have a CONSTANT_CLASS_P. (region_model_manager::maybe_fold_unaryop): Only fold a constant when fold_unary's result is a constant or a cast of a constant. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/pr104089.c: New test. PR analyzer/104089 Signed-off-by: D

[committed] analyzer: fix ICE on realloc of zeroed memory [PR104062]

2022-01-18 Thread David Malcolm via Gcc-patches
ting to NULL type when folding access to repeated svalue. gcc/testsuite/ChangeLog: PR analyzer/104062 * gcc.dg/analyzer/pr104062.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-manager.cc | 3 ++- gcc/testsuite/gcc.dg/analyzer/pr104062.c

Re: [PATCH v2 RFA] diagnostic: avoid repeating include path

2022-01-16 Thread David Malcolm via Gcc-patches
On Fri, 2022-01-14 at 23:01 -0500, Jason Merrill wrote: > On 1/13/22 17:30, David Malcolm wrote: > > On Thu, 2022-01-13 at 17:08 -0500, Jason Merrill wrote: > > > When a sequence of diagnostic messages bounces back and forth > > > repeatedly

Re: [committed] analyzer: fix ICE in taint checker on unary ops [PR104029]

2022-01-14 Thread David Malcolm via Gcc-patches
On Fri, 2022-01-14 at 17:53 -0500, David Malcolm wrote: > gcc/analyzer/ChangeLog: > PR analyzer/104029 > * sm-taint.cc (taint_state_machine::alt_get_inherited_state): > Remove gcc_unreachable from default case for unary ops. > > gcc/testsuite/Chang

[committed] analyzer: fix ICE when combining taint states has_ub and has_lb

2022-01-14 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as cc3b67e40140ec79f86e79a96d7fdd169b84faaf. gcc/analyzer/ChangeLog: * sm-taint.cc (taint_state_machine::combine_states): Handle combination of has_ub and has_lb. gcc/testsuite/ChangeLog: *

[committed] analyzer: fix ICE in taint checker on unary ops [PR104029]

2022-01-14 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: PR analyzer/104029 * sm-taint.cc (taint_state_machine::alt_get_inherited_state): Remove gcc_unreachable from default case for unary ops. gcc/testsuite/ChangeLog: PR analyzer/104029 * gcc.dg/analyzer/pr104029.c: New test. *

[committed] Add __attribute__ ((tainted_args))

2022-01-13 Thread David Malcolm via Gcc-patches
On Thu, 2022-01-13 at 14:08 -0500, Jason Merrill wrote: > On 1/12/22 10:33, David Malcolm wrote: > > On Tue, 2022-01-11 at 23:36 -0500, Jason Merrill wrote: > > > On 1/10/22 16:36, David Malcolm via Gcc-patches wrote: > > > > On Thu, 2022-01-06 at 09:08 -0500, David M

Re: [PATCH RFA] diagnostic: avoid repeating include path

2022-01-13 Thread David Malcolm via Gcc-patches
On Thu, 2022-01-13 at 17:08 -0500, Jason Merrill wrote: > When a sequence of diagnostic messages bounces back and forth > repeatedly > between two includes, as with > >  #include >  std::map m ("123", "456"); > > The output is quite a bit longer than necessary because we dump the > include >

Re: PING^2 (C/C++): Re: [PATCH 6/6] Add __attribute__ ((tainted))

2022-01-12 Thread David Malcolm via Gcc-patches
On Tue, 2022-01-11 at 23:36 -0500, Jason Merrill wrote: > On 1/10/22 16:36, David Malcolm via Gcc-patches wrote: > > On Thu, 2022-01-06 at 09:08 -0500, David Malcolm wrote: > > > On Sat, 2021-11-13 at 15:37 -0500, David Malcolm wrote: > > > > This patch adds

[committed] analyzer: complain about tainted sizes with "access" attribute [PR103940]

2022-01-12 Thread David Malcolm via Gcc-patches
PR analyzer/103940 * gcc.dg/analyzer/taint-size-access-attr-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/engine.cc| 17 ++- gcc/analyzer/sm-taint.cc | 116 -- gcc/analyzer/sm.h |

[committed] analyzer: fix false +ve on bitwise binops (PR analyzer/102692)

2022-01-11 Thread David Malcolm via Gcc-patches
PR analyzer/102692 reports a false positive at -O2 from -Wanalyzer-null-dereference on: if (!p || q || !p->next) At the gimple level, -O2 has converted the first || into bitwise or controlling a jump: _4 = _2 | _3; if (_4 != 0) and a recursive call has been converted to iteration. The

PING^2 (C/C++): Re: [PATCH 6/6] Add __attribute__ ((tainted))

2022-01-10 Thread David Malcolm via Gcc-patches
On Thu, 2022-01-06 at 09:08 -0500, David Malcolm wrote: > On Sat, 2021-11-13 at 15:37 -0500, David Malcolm wrote: > > This patch adds a new __attribute__ ((tainted)) to the C/C++ > > frontends. > > Ping for GCC C/C++ mantainers for review of the C/C++ FE parts of th

[committed] analyzer: add logging of aliasing

2022-01-07 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as 11a2ff8d981110e1562caf7d98e41c1ff2e76056. gcc/analyzer/ChangeLog: * engine.cc (impl_run_checkers): Pass logger to engine ctor. * region-model-manager.cc

[committed] analyzer: implement __analyzer_dump_escaped

2022-01-07 Thread David Malcolm via Gcc-patches
PR analyzer/103546 seems to involve an issue in how the analyzer tracks which decls have escaped, so this patch adds a way to directly test this from DejaGnu. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-6377-g4409152a4acaec5b58a93996088d0df9aaa779b8.

[committed] analyzer: add region::is_named_decl_p

2022-01-07 Thread David Malcolm via Gcc-patches
This patch adds a debug function that I've found handy when debugging a problem with handling the decl yy_buffer_stack" in PR analyzer/103546. Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-6376-gc1b7d28a5987e74232b7f054849f8bd8ccc7e7de.

[committed] analyzer: make use of may_be_aliased in alias detection [PR103546]

2022-01-06 Thread David Malcolm via Gcc-patches
Whilst debugging PR analyzer/103546 (false +ve in flex-generated lexers) I noticed that the analyzer was considering that writes through symbolic pointers could be treated as clobbering static globals such as: static YY_BUFFER_STATE * yy_buffer_stack = NULL; even for such variables that never

Re: [PATCH 1b/6] Add __attribute__((untrusted))

2022-01-06 Thread David Malcolm via Gcc-patches
On Thu, 2021-12-09 at 15:54 -0700, Martin Sebor wrote: > On 11/13/21 1:37 PM, David Malcolm via Gcc-patches wrote: > > This patch adds a new: > > > >    __attribute__((untrusted)) > > > > for use by the C front-end, intended for use by the Linux kernel for >

PING (C/C++): Re: [PATCH 6/6] Add __attribute__ ((tainted))

2022-01-06 Thread David Malcolm via Gcc-patches
On Sat, 2021-11-13 at 15:37 -0500, David Malcolm wrote: > This patch adds a new __attribute__ ((tainted)) to the C/C++ > frontends. Ping for GCC C/C++ mantainers for review of the C/C++ FE parts of this patch (attribute registration, documentation, the name of the attribute, etc). (I b

Re: [PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854]

2022-01-06 Thread David Malcolm via Gcc-patches
On Thu, 2022-01-06 at 08:53 -0500, David Malcolm wrote: > On Sun, 2021-12-19 at 22:30 +0100, Marc Nieper-Wißkirchen wrote: > > This patch fixes a memory leak in the pass manager. In the existing > > code, > > the m_name_to_pass_map is allocated in > > pass_

Re: [PATCH] gcc: pass-manager: Fix memory leak. [PR jit/63854]

2022-01-06 Thread David Malcolm via Gcc-patches
On Sun, 2021-12-19 at 22:30 +0100, Marc Nieper-Wißkirchen wrote: > This patch fixes a memory leak in the pass manager. In the existing > code, > the m_name_to_pass_map is allocated in > pass_manager::register_pass_name, but > never deallocated.  This is fixed by adding a deletion in >

Re: SV: [PATCH v2] jit: Add support for global rvalue initialization and ctors

2021-12-13 Thread David Malcolm via Gcc-patches
On Sun, 2021-12-12 at 20:39 -0500, Antoni Boucher wrote: > Yes, this patch works for rustc_codegen_gcc perfectly. > It even fixes one issue that was in my patch, so that's nice! Excellent - thanks Antoni. > > Le samedi 11 décembre 2021 à 15:35 +, Petter Tomner a écrit : > > Hi! > > > > >

Re: testsuite: Be more informative for ICEs

2021-12-13 Thread David Malcolm via Gcc-patches
On Mon, 2021-12-13 at 10:53 -0700, Martin Sebor via Gcc-patches wrote: > On 12/10/21 3:42 PM, Thomas Schwinge wrote: > > Hi! > > > > OK to push the attached "testsuite: Be more informative for ICEs"? > > Adding more detail here seems like a useful improvement to me. > > Martin Agreed. I don't

[committed] jit: set DECL_CONTEXT of RESULT_DECL [PR103562]

2021-12-10 Thread David Malcolm via Gcc-patches
62.c: New test. Signed-off-by: David Malcolm --- gcc/jit/jit-playback.c | 1 + gcc/testsuite/jit.dg/all-non-failing-tests.h | 3 + gcc/testsuite/jit.dg/test-pr103562.c | 62 3 files changed, 66 insertions(+) create mode 100644 gcc/testsuite/ji

Re: [PATCH] libgccjit: Add support for types used by atomic builtins [PR96066] [PR96067]

2021-12-09 Thread David Malcolm via Gcc-patches
On Sun, 2021-11-21 at 16:44 -0500, Antoni Boucher wrote: > Thanks for the review! > I updated the patch. > > See notes below. Thanks; the updated patch looks good for trunk. Dave

Re: [PATCH v2] jit: Add support for global rvalue initialization and ctors

2021-12-09 Thread David Malcolm via Gcc-patches
On Mon, 2021-12-06 at 10:47 +, Petter Tomner via Gcc-patches wrote: > Hi! > > Attached is a patch with changes in line with the review of the prior > patch. > The patch adds support for initialization of global variables with > rvalues as well > as rvalue constructors for structs, arrays and

Re: [PATCH 0/6] RFC: adding support to GCC for detecting trust boundaries

2021-12-08 Thread David Malcolm via Gcc-patches
On Mon, 2021-12-06 at 13:40 -0600, Segher Boessenkool wrote: > On Mon, Dec 06, 2021 at 11:12:00AM -0700, Martin Sebor wrote: > > On 11/13/21 1:37 PM, David Malcolm via Gcc-patches wrote: > > > Approach 1: Custom Address Spaces > > > = &g

Re: [PATCH 0/6] RFC: adding support to GCC for detecting trust boundaries

2021-12-08 Thread David Malcolm via Gcc-patches
On Mon, 2021-12-06 at 11:12 -0700, Martin Sebor wrote: > On 11/13/21 1:37 PM, David Malcolm via Gcc-patches wrote: > > [Crossposting between gcc-patches@gcc.gnu.org and > > linux-toolcha...@vger.kernel.org; sorry about my lack of kernel > > knowledge, in case of the

[committed] analyzer: fix equivalence class state purging [PR103533]

2021-12-06 Thread David Malcolm via Gcc-patches
New. (constraint_manager::canonicalize): Call it when determining redundant ECs. (selftest::test_purging): New selftest. (selftest::run_constraint_manager_tests): Likewise. * constraint-manager.h (equiv_class::contains_non_constant_p): New decl. Signed-off-by: D

[committed] analyzer: add regression test for leak false +ve [PR103526]

2021-12-02 Thread David Malcolm via Gcc-patches
Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-5757-g38a0ee2649ef236ea2763bb9cfc42dc917c7d3fd. gcc/testsuite/ChangeLog: PR analyzer/103526 * gcc.dg/analyzer/pr103526.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/pr103526.c

[committed] analyzer: fix false leak seen in Juliet 1.3 [PR102471]

2021-12-01 Thread David Malcolm via Gcc-patches
-off-by: David Malcolm --- gcc/analyzer/region-model-reachability.cc | 13 +++ gcc/testsuite/gcc.dg/analyzer/leak-3.c| 41 +++ 2 files changed, 54 insertions(+) create mode 100644 gcc/testsuite/gcc.dg/analyzer/leak-3.c diff --git a/gcc/analyzer/region-model-reachability.c

[committed] analyzer: add regression test [PR94579]

2021-11-30 Thread David Malcolm via Gcc-patches
Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-5642-g955ea7b58e4f1e3cc5083e88575161168c147254. gcc/testsuite/ChangeLog: PR analyzer/94579 * gcc.dg/analyzer/pr94579.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/pr94579.c | 11

[committed] analyzer: verify that -Wanalyzer-too-complex can be disabled via pragmas [PR100524]

2021-11-30 Thread David Malcolm via Gcc-patches
Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-5640-g03ea0ca1189a39e095188b0425c66446cc84a0a5. gcc/testsuite/ChangeLog: PR analyzer/100524 * gcc.dg/analyzer/pragma-2.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/pragma-2.c

[committed] analyzer: add regression test [PR99269]

2021-11-30 Thread David Malcolm via Gcc-patches
Successfully regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-5641-g9603bccba62e250d0ff64863a1730a167d571a25. gcc/testsuite/ChangeLog: PR analyzer/99269 * gcc.dg/analyzer/pr99269.c: New test. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/pr99269.c | 16

[committed] analyzer: further false leak fixes due to overzealous state merging [PR103217]

2021-11-29 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/pr103217-5.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/store.cc | 14 +- gcc/testsuite/gcc.dg/analyzer/pr103217-2.c | 52 ++ gcc/testsuite/gcc.dg/analyzer/pr103217-3.c | 52 ++ gcc/testsuite/gcc.dg/

Re: [PATCH] libgccjit: Add support for TLS variable [PR95415]

2021-11-21 Thread David Malcolm via Gcc-patches
On Sat, 2021-11-20 at 17:34 -0500, Antoni Boucher wrote: > Hi. > Here's the updated patch. > See comments below. > Thanks for your reviews! > > Le jeudi 20 mai 2021 à 16:11 -0400, David Malcolm a écrit : > > On Tue, 2021-05-18 at 20:43 -0400, Antoni Boucher via Gcc-patche

Re: [PATCH] libgccjit: Add support for types used by atomic builtins [PR96066] [PR96067]

2021-11-20 Thread David Malcolm via Gcc-patches
On Sat, 2021-11-20 at 11:27 -0500, Antoni Boucher wrote: > Hi. > Here's the updated patch. > Thanks for the review! Thanks for the updated patch... > > Le jeudi 20 mai 2021 à 16:24 -0400, David Malcolm a écrit : > > On Mon, 2021-05-17 at 21:02 -0400, Antoni Boucher via J

Re: [PATCH] libgccjit: Add support for setting the link section of global variables [PR100688]

2021-11-20 Thread David Malcolm via Gcc-patches
On Sat, 2021-11-20 at 11:53 -0500, Antoni Boucher wrote: > Hi. > Here's the updated patch. > See comments below. > Thanks for the review! > > Le samedi 20 novembre 2021 à 11:20 -0500, David Malcolm a écrit : > > On Sat, 2021-11-20 at 00:58 -0500, Antoni

Re: [PATCH] libgccjit: Add support for setting the link section of global variables [PR100688]

2021-11-20 Thread David Malcolm via Gcc-patches
eudi 20 mai 2021 à 15:29 -0400, David Malcolm a écrit : > > On Wed, 2021-05-19 at 20:32 -0400, Antoni Boucher via Jit wrote: > > > Hello. > > > This patch adds support to set the link section of global > > > variables. > > > I used the ABI 18 because I submitt

Re: [PATCH] libgccjit: add some reflection functions in the jit C api

2021-11-19 Thread David Malcolm via Gcc-patches
On Mon, 2021-09-27 at 20:53 -0400, Antoni Boucher wrote: > I fixed an issue (it would show an error message when > gcc_jit_type_dyncast_function_ptr_type was called on a type different > than a function pointer type). > > Here's the updated patch. Sorry about the delay in responding. The

[committed] analyzer: fix false leak due to overeager state merging [PR103217]

2021-11-19 Thread David Malcolm via Gcc-patches
s and reject the merger accordingly. gcc/testsuite/ChangeLog: PR analyzer/103217 * gcc.dg/analyzer/explode-1.c: Update for improvement to location of leak warning. * gcc.dg/analyzer/pr103217.c: New test. * gcc.dg/analyzer/pr94858-1.c: Add -Wno-analyzer-to

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-18 Thread David Malcolm via Gcc-patches
On Thu, 2021-11-18 at 14:08 -0600, Segher Boessenkool wrote: > On Wed, Nov 17, 2021 at 10:43:58PM +, Joseph Myers wrote: > > On Wed, 17 Nov 2021, Prathamesh Kulkarni via Gcc-patches wrote: > > > More generally, would it be a good idea to provide attributes for > > > mod/ref anaylsis ? > > > So

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-18 Thread David Malcolm via Gcc-patches
On Wed, 2021-11-17 at 22:43 +, Joseph Myers wrote: > On Wed, 17 Nov 2021, Prathamesh Kulkarni via Gcc-patches wrote: > > > More generally, would it be a good idea to provide attributes for > > mod/ref anaylsis ? > > So sth like: > > void foo(void) __attribute__((modifies(errno))); > > which

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-18 Thread David Malcolm via Gcc-patches
On Wed, 2021-11-17 at 14:53 +0530, Prathamesh Kulkarni wrote: > On Tue, 16 Nov 2021 at 03:42, David Malcolm > wrote: > > > > On Mon, 2021-11-15 at 12:33 +0530, Prathamesh Kulkarni wrote: > > > On Sun, 14 Nov 2021 at 02:07, David Malcolm via Gcc-patches > > >

[PATCH 2/2] libcpp: capture and underline ranges in -Wbidi-chars= [PR103026]

2021-11-17 Thread David Malcolm via Gcc-patches
5356-gbef32d4a28595e933f24fef378cf052a30b674a7. Signed-off-by: David Malcolm gcc/testsuite/ChangeLog: PR preprocessor/103026 * c-c++-common/Wbidi-chars-ranges.c: New test. libcpp/ChangeLog: PR preprocessor/103026 * lex.c (struct bidi::context): New. (bidi::vec): Con

[committed] libcpp: escape non-ASCII source bytes in -Wbidi-chars= [PR103026]

2021-11-17 Thread David Malcolm via Gcc-patches
e983c9ab3. libcpp/ChangeLog: PR preprocessor/103026 * lex.c (maybe_warn_bidi_on_close): Use a rich_location and call set_escape_on_output (true) on it. (maybe_warn_bidi_on_char): Likewise. Signed-off-by: David Malcolm --- libcpp/lex.c | 29

Re: [PATCH v3] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]

2021-11-16 Thread David Malcolm via Gcc-patches
On Tue, 2021-11-16 at 19:37 -0500, Marek Polacek wrote: > On Tue, Nov 16, 2021 at 06:00:58PM -0500, David Malcolm wrote: > > > On Mon, Nov 15, 2021 at 06:15:40PM -0500, David Malcolm wrote: > > > > > On Mon, Nov 08, 2021 at 04:33:43PM -0500, Marek Polacek wrote: > &

[committed] analyzer: fix missing -Wanalyzer-write-to-const [PR102695]

2021-11-16 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/strchr-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/region-model-impl-calls.cc | 69 gcc/analyzer/region-model-manager.cc | 7 +++ gcc/analyzer/region-model.cc | 52 -- gcc/analyzer/region-model.h

[committed] analyzer: don't assume target has alloca [PR102779]

2021-11-16 Thread David Malcolm via Gcc-patches
alloca. * gcc.dg/analyzer/capacity-3.c: Likewise. Signed-off-by: David Malcolm --- gcc/testsuite/gcc.dg/analyzer/capacity-1.c | 4 +++- gcc/testsuite/gcc.dg/analyzer/capacity-3.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/testsuite/gcc.dg/analyzer/capacity-1

Re: [PATCH v2] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]

2021-11-16 Thread David Malcolm via Gcc-patches
> On Mon, Nov 15, 2021 at 06:15:40PM -0500, David Malcolm wrote: > > > On Mon, Nov 08, 2021 at 04:33:43PM -0500, Marek Polacek wrote: > > > > Ping, can we conclude on the name? IMHO, -Wbidirectional is just fine, > > > > but changing the name is a trivial ope

[committed] analyzer: fix overeager sharing of bounded_range instances [PR102662]

2021-11-16 Thread David Malcolm via Gcc-patches
gned-off-by: David Malcolm --- gcc/analyzer/constraint-manager.cc | 4 ++- gcc/testsuite/g++.dg/analyzer/pr102662.C | 39 2 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/g++.dg/analyzer/pr102662.C diff --git a/gcc/analyzer/constr

Re: [PATCH] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026]

2021-11-15 Thread David Malcolm via Gcc-patches
> On Mon, Nov 08, 2021 at 04:33:43PM -0500, Marek Polacek wrote: > > Ping, can we conclude on the name? IMHO, -Wbidirectional is just fine, > > but changing the name is a trivial operation. > > Here's a patch with a better name (suggested by Jonathan W.). Otherwise no > changes. Thanks for

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-15 Thread David Malcolm via Gcc-patches
On Mon, 2021-11-15 at 15:45 +0100, Peter Zijlstra wrote: > On Mon, Nov 15, 2021 at 12:33:16PM +0530, Prathamesh Kulkarni wrote: > > On Sun, 14 Nov 2021 at 02:07, David Malcolm via Gcc-patches > > > > +/* Handle "returns_zero_on_failure" and "retur

Re: [PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-15 Thread David Malcolm via Gcc-patches
On Mon, 2021-11-15 at 12:33 +0530, Prathamesh Kulkarni wrote: > On Sun, 14 Nov 2021 at 02:07, David Malcolm via Gcc-patches > wrote: > > > > This patch adds two new attributes.  The followup patch makes use of > > the attributes in -fanalyzer. [...

Re: [PATCH 0/6] RFC: adding support to GCC for detecting trust boundaries

2021-11-13 Thread David Malcolm via Gcc-patches
On Sun, 2021-11-14 at 00:20 +0100, Peter Zijlstra wrote: > On Sat, Nov 13, 2021 at 03:37:24PM -0500, David Malcolm wrote: > > > This approach is much less expressive that the custom addres space > > approach; it would only cover the trust boundary aspect; it > > wouldn't &

[PATCH 3/6] analyzer: implement infoleak detection

2021-11-13 Thread David Malcolm via Gcc-patches
* gcc.dg/analyzer/infoleak-fixit-1.c: New test. * gcc.dg/analyzer/torture/infoleak-net-ethtool-ioctl.c: New test. * gcc.dg/analyzer/torture/infoleak-vfio_iommu_type1.c: New test. Signed-off-by: David Malcolm --- gcc/Makefile.in | 3 +- gcc/a

[PATCH 6/6] Add __attribute__ ((tainted))

2021-11-13 Thread David Malcolm via Gcc-patches
. * gcc.dg/analyzer/taint-alloc-3.c: New test. * gcc.dg/analyzer/taint-alloc-4.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/engine.cc| 317 +- gcc/c-family/c-attribs.c | 36 ++ gcc/doc/extend.texi

[PATCH 1a/6] RFC: Implement "#pragma GCC custom_address_space"

2021-11-13 Thread David Malcolm via Gcc-patches
ere involved when complaining about mismatching address spaces. gcc/cp/ChangeLog: * tree.c (c_register_custom_addr_space): New stub. gcc/testsuite/ChangeLog: * gcc.dg/custom-address-space-1.c: New test. * gcc.dg/custom-address-space-2.c: New test. * gcc.dg/cus

[PATCH 5/6] analyzer: use region::untrusted_p in taint detection

2021-11-13 Thread David Malcolm via Gcc-patches
lyzer/taint-CVE-2011-0521-6.c: New test. * gcc.dg/analyzer/taint-CVE-2011-0521.h: New test. * gcc.dg/analyzer/taint-antipatterns-1.c: New test. * gcc.dg/analyzer/taint-read-through-untrusted-ptr-1.c: New test. Signed-off-by: David Malcolm --- gcc/analyzer/sm-taint.cc

[PATCH 4b/6] analyzer: implement region::untrusted_p in terms of __attribute__((untrusted))

2021-11-13 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: * region.cc (region::untrusted_p): Implement in terms of __attribute__((untrusted)). gcc/testsuite/ChangeLog: * gcc.dg/analyzer/test-uaccess.h: Change from custom_address_space pragma to __attribute__((untrusted)). Signed-off-by: David

[PATCH 0/6] RFC: adding support to GCC for detecting trust boundaries

2021-11-13 Thread David Malcolm via Gcc-patches
are many examples in the patches, some of which are taken from historical kernel vulnerabilities, and others from my "antipatterns.ko" project ( https://github.com/davidmalcolm/antipatterns.ko ). Thoughts? Dave David Malcolm (6 or 8, depending how you count): 1a: RFC: Implement "#pragm

[PATCH 4a/6] analyzer: implement region::untrusted_p in terms of custom address spaces

2021-11-13 Thread David Malcolm via Gcc-patches
gcc/analyzer/ChangeLog: (region::untrusted_p): New. gcc/testsuite/ChangeLog: * gcc.dg/analyzer/test-uaccess.h: New header. Signed-off-by: David Malcolm --- gcc/analyzer/region.cc | 13 + gcc/testsuite/gcc.dg/analyzer/test-uaccess.h | 19

[PATCH 1b/6] Add __attribute__((untrusted))

2021-11-13 Thread David Malcolm via Gcc-patches
le TYPE_QUAL_UNTRUSTED. * tree.h (TYPE_QUALS): Likewise. (TYPE_QUALS_NO_ADDR_SPACE): Likewise. (TYPE_QUALS_NO_ADDR_SPACE_NO_ATOMIC): Likewise. gcc/testsuite/ChangeLog: * c-c++-common/attr-untrusted-1.c: New test. Signed-off-by: David Malcolm --- gcc/c-family/c-attribs.c

[PATCH 2/6] Add returns_zero_on_success/failure attributes

2021-11-13 Thread David Malcolm via Gcc-patches
i (Common Function Attributes): Document "returns_zero_on_failure" and "returns_zero_on_success". gcc/testsuite/ChangeLog: * c-c++-common/attr-returns-zero-on-1.c: New test. Signed-off-by: David Malcolm --- gcc/c-family/c-attribs.c | 37 ++ gcc/d

[committed] analyzer: add four new taint-based warnings

2021-11-13 Thread David Malcolm via Gcc-patches
ew test. * gcc.dg/analyzer/taint-1.c: Rename to... * gcc.dg/analyzer/taint-read-index-1.c: ...this. Tweak expected wording. Mark some events as xfail. * gcc.dg/analyzer/taint-read-offset-1.c: New test. * gcc.dg/analyzer/taint-size-1.c: New test

[committed] analyzer: "__analyzer_dump_state" has no side-effects

2021-11-12 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as 72f1c1c452198ba1df6f70959180b201cedc506e. gcc/analyzer/ChangeLog: * engine.cc (exploded_node::on_stmt_pre): Return when handling "__analyzer_dump_state". Signed-off-by: David Mal

[committed] jit: fix -Werror=format-overflow= in testsuite [PR103199]

2021-11-12 Thread David Malcolm via Gcc-patches
oyvm.c (toyvm_function_compile): Increase size of buffer. * docs/examples/tut04-toyvm/toyvm.cc (compilation_state::create_function): Likewise. Signed-off-by: David Malcolm --- gcc/jit/docs/examples/tut04-toyvm/toyvm.c | 2 +- gcc/jit/docs/examples/tut04-toyvm/toyvm.cc | 2 +- 2 files chan

[committed] diagnostic: fix unused variable 'def_tabstop' [PR103129]

2021-11-11 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as r12-5176-gabdff441a07f55d16e3d0e5ced3123c83d210a0a. gcc/ChangeLog: PR other/103129 * diagnostic-show-locus.c (def_policy): Use def_tabstop. Signed-off-by: David Malcolm --- gcc/diagnostic-

[committed] c: more precise locations for some -Wpragmas diagnostics

2021-11-09 Thread David Malcolm via Gcc-patches
ns.c: New test. Signed-off-by: David Malcolm --- gcc/c-family/c-pragma.c | 33 +--- gcc/testsuite/gcc.dg/bad-pragma-locations.c | 86 + 2 files changed, 107 insertions(+), 12 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/bad-pragma-locations

[committed] analyzer: fix ICE in sm_state_map::dump when dumping trees

2021-11-04 Thread David Malcolm via Gcc-patches
Successfully bootstrapped & regrtested on x86_64-pc-linux-gnu. Pushed to trunk as 347682ea4637c57c386908d6e1aa52e4efaace53. gcc/analyzer/ChangeLog: * program-state.cc (sm_state_map::dump): Use default_tree_printer as format decoder. --- gcc/analyzer/program-state.cc | 1 + 1 file

Re: [PATCH 1/2] add -Wuse-after-free

2021-11-02 Thread David Malcolm via Gcc-patches
On Mon, 2021-11-01 at 16:17 -0600, Martin Sebor via Gcc-patches wrote: > Patch 1 in the series detects a small subset of uses of pointers > made indeterminate by calls to deallocation functions like free > or C++ operator delete. To control the conditions the warnings > are issued under the new

<    5   6   7   8   9   10   11   12   13   14   >