Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp780162ybt; Wed, 17 Jun 2020 13:54:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYjD/wrYSPNoyS9Q6CBzZQKZxHkWFU3wCjlqgh82gHxifsUU9iKhv0xNXFWpgbQS0Lz0iq X-Received: by 2002:aa7:c4c7:: with SMTP id p7mr996881edr.271.1592427267391; Wed, 17 Jun 2020 13:54:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592427267; cv=none; d=google.com; s=arc-20160816; b=RDDi5k6vAQLH6PDPMDdSJtUZnbvKPtDlAZfr3+K32gIcJw8ck5mTuac16FDUizY4Ye V4LPBxj3w5wQNt4K+ocIkylIEjVE4irj7+eJUCwH8QUFJejgfa2w3aJknFoMmBbnF+GY fbePYzNJoMIkE7W7su0gSv04bQ0IXTthO/+B5jwuP//pFjaCHw0UWurJajVPKs9qSHB6 5qKCWPSK7VFAsh3d1HtQP4leLnWqFO5ce/paoB7aaTNtVT/RzpK9gukflc7QhDkqZmar 3zOLuHxSsmMMgfX+WSNWT7CUAVOfZSso9NTcW1BLN0xrlBXitGqKyR82/RRO7b7IuIJU cppw== 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=r7d9D7DdOBCkM3WVfrd5zaJp7zmJiHbkabHOk+GNLzg=; b=SqCPmwOSmI8QyxybZW0LRur2Tt2Vg2ozaxqpi34PFbVHz60cQBBegZrkyjE1ZnQeok 3erz4gEVSM77BP1p+m8AgUSaIRUQe6Je4yMlGvlu4havdvtdXoB8m5de+odj9pzc7Wc9 lmvHNK/zowSK/3ZOc1KRGzgdEOu3MguuFffc/iU9wBYNvRk3kw3zI1NbhnaYDMXmVMkB VtHBMqpdvm8ZQXha6PwF+6ch1hIjj9+rgmJ1rV8/tggy62+CrcZYVWM9NpQ0FV+u2FJ3 BD8EKXhye0e9CtLOt7w+SRIgqCYNvASmjN58puRDHJAvpi3YHv2V8EHYQLCzsw4nl/pB PuEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=WHB3heK0; 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 sb15si555167ejb.478.2020.06.17.13.54.04; Wed, 17 Jun 2020 13:54:27 -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=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=WHB3heK0; 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 S1726949AbgFQUvt (ORCPT + 99 others); Wed, 17 Jun 2020 16:51:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33816 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbgFQUvs (ORCPT ); Wed, 17 Jun 2020 16:51:48 -0400 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2CA52C061755 for ; Wed, 17 Jun 2020 13:51:47 -0700 (PDT) Received: by mail-ej1-x641.google.com with SMTP id w16so4062808ejj.5 for ; Wed, 17 Jun 2020 13:51:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=r7d9D7DdOBCkM3WVfrd5zaJp7zmJiHbkabHOk+GNLzg=; b=WHB3heK02RYqhtR3KBCfEAY1anEU5eNIbCqZeFyh4umG6SHs/pxirhfkrcZguGC2uI Pv4pKoM8JCf5BgObp/El9D556uBr+jPuURqa6sI/MGoO1flZH7hQNhsKHWd4PYo7EMza aOka3zm67A/gc3Nc3nNSY9/w6AtLi+49g3t2ZydOFcijMcWOe2KTDA89Sa3+UfCh8mWZ ofTwgLi3HOhjwakYHlC9cefjBiMgR6yrZcdCUpSk32j1K2cvSciElvUSmtpoH+x/6zsx 2xOjp7E0J8/I/uTfs0ZkJ5EV9KxVqmy7yI9jfusnYrDWcdrFc2Ni2/WdhHrXaQJNvvDd Uvrw== 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=r7d9D7DdOBCkM3WVfrd5zaJp7zmJiHbkabHOk+GNLzg=; b=bCG5NEYRorH4wJiqyHEoLkyjpiSH93Q3hvJFAqtCHaKGWpzTCgNmy1IEb8yOW5pL0Z Onnp/picLI5iCBCuR39j3NnsvXvhDGloQKVmVsrmYTQTRji6EAIWFIRz3cZI6kepwCz8 X/q8wPeARJaKm0zMAaHNaqUKuMnOQ7IpEZ7YfBdkCH1WsirtCWhJroops2DaT+5Z+0Zm G46vKR5BcJmQcDkF6QvbUJT4gdNoDt2KLZfjkKsZQYDZpT1scSbPn76oEkcoef514Awd 0qfkbJlRv+xHk4Ni/UMxXYvNl6DC4JV0kCw6y1OzRg1HmkoqMMyuwDAJ5BsJVKZ0Jqwx M21w== X-Gm-Message-State: AOAM530B7HV73TTvNJLBRme7EpU5C0boFpvj/cg+Vyy7HnH9HEsrBC8Y V4kU9lCd3UaoG3YjLKJVC2f57SFUlS9/cYKIfPcf X-Received: by 2002:a17:906:434f:: with SMTP id z15mr951887ejm.178.1592427105550; Wed, 17 Jun 2020 13:51:45 -0700 (PDT) MIME-Version: 1.0 References: <20200617124028.14130-1-trix@redhat.com> In-Reply-To: From: Paul Moore Date: Wed, 17 Jun 2020 16:51:34 -0400 Message-ID: Subject: Re: [PATCH] selinux: fix undefined return of cond_evaluate_expr To: trix@redhat.com Cc: Stephen Smalley , Eric Paris , Ondrej Mosnacek , weiyongjun1@huawei.com, SElinux list , linux-kernel 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 Wed, Jun 17, 2020 at 9:58 AM Stephen Smalley wrote: > On Wed, Jun 17, 2020 at 8:40 AM wrote: > > > > From: Tom Rix > > > > clang static analysis reports an undefined return > > > > security/selinux/ss/conditional.c:79:2: warning: Undefined or garbage value returned to caller [core.uninitialized.UndefReturn] > > return s[0]; > > ^~~~~~~~~~~ > > > > static int cond_evaluate_expr( ... > > { > > u32 i; > > int s[COND_EXPR_MAXDEPTH]; > > > > for (i = 0; i < expr->len; i++) > > ... > > > > return s[0]; > > > > When expr->len is 0, the loop which sets s[0] never runs. > > > > So return -1 if the loop never runs. > > > > Signed-off-by: Tom Rix > > Acked-by: Stephen Smalley > > clang didn't complain about the similar pattern in > security/selinux/ss/services.c:constraint_expr_eval()? Related question: I appreciate the work you are doing Tom, can you share how far along you are testing the SELinux code with clang? I ask because it would be nice to roll all of these patches up into one PR for Linus instead of sending multiple updates. -- paul moore www.paul-moore.com