Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp2253539img; Sun, 24 Mar 2019 03:58:31 -0700 (PDT) X-Google-Smtp-Source: APXvYqweGq2akT2xgS0l/EMK5jRt2s+oE7dpeBwdZWHpIm5AwgP3sroRZuE5jQ7FFqyMuJMhrqn1 X-Received: by 2002:aa7:9116:: with SMTP id 22mr7078534pfh.165.1553425111447; Sun, 24 Mar 2019 03:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553425111; cv=none; d=google.com; s=arc-20160816; b=RAkyHaGuBO4iaNMwdHm9UVH8HNzzEXIcCjeptrtA7MYxpFNYPuAgOLFS01PerEBMNl PK5Sy78OXAdUcgIABNOKyScSpVPVAgZYT94TOIUF1x8z6LAWoq8kGzMsq0tZRRLydeVv TM+CuCR/DXdrD0Xm8+6t8qUuHCtKx/aXbEsXQMo2cz+wWvzVthr8FiZbmaIFPBcpuyyf n368zPJv3LEMX+sbEGZG3t1GX665QQgXMkTR0mz0A1SYBggP0bQ8zM0he0jWFmh24S70 7BAos85VACZeNuDHtE3F1eekSvGJ2s7H34gr8oFNkxAgtncRY78THFUhM7uSfcYj6WdU WycA== 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; bh=9hVUhsAgvZtnx8r3Ef39s656IuqsCyUYiw0poxDFLhs=; b=YRc/LrZUdWarwQr9I529roEOwxdDFtu4e3lNcbhNTV2DkEuUe7nNyXdGm+Y9QoYLLO 1FOxRelYHFOaiosiUFPj3aNuaZSxjMSAsiYMnTptjVtDzk9aUQKSyEDuT1s1ANsyxhsx dCutBZL7v/1VmsUZTDT43gfSBegiflVYjezGprsHNaqRkOCXyfsEswU9f8fQtaBHfSCS 246FEmJsMmtaOA6Ejb6UvWAyx3Z0wmEEpxtlZnxz62qYbAQFy9jJfZfYrwmuPFLVkW2m fhhaxlybop3IVSMnfO3qSzyiTF3VGFtVTdUUx1Ju4ZcXKUN5JgsRmAMzMAtM109olHbx hR7g== ARC-Authentication-Results: i=1; mx.google.com; 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 36si11001867pgx.547.2019.03.24.03.58.14; Sun, 24 Mar 2019 03:58:31 -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; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727192AbfCXK5g (ORCPT + 99 others); Sun, 24 Mar 2019 06:57:36 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:38344 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726090AbfCXK5g (ORCPT ); Sun, 24 Mar 2019 06:57:36 -0400 Received: by mail-oi1-f194.google.com with SMTP id w137so4865820oiw.5 for ; Sun, 24 Mar 2019 03:57:36 -0700 (PDT) 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=9hVUhsAgvZtnx8r3Ef39s656IuqsCyUYiw0poxDFLhs=; b=b8VapZLDO+BxXTeFgCbTeorm3bqO5rvQRiIoJ0EQYtQo4mjEQ39gWvkrIp+VUtEC9A G5g0YzexY+HtbCX3SL+bV7yk1zEVhaeWnhtNe3oSY3Qbd18DOpOcwiodm0jEbRoExq07 5vLcUQubgmXRI+u1gKK9unLtE17LEIbSWb1guD0p8v6j+1YLDcIrpcip6usMzcT/5awg VSkEBroLrPS4E2fK32Bkqbj9wyVuPDJPLuQglbpUA7ZKmA6uoS+9kzVOlBLg1EPxp1Y5 WlvkMhKqXWzULXKrXOyWw33alDa6KxYKVx/0nMVxr0YHIE/mrbl4ozL75A2ag5gWHvr6 nD7Q== X-Gm-Message-State: APjAAAWIpCxQV85zzNmVwbt2tv/P9oO65cdNrZQdtpW1NiS4dvDVo+C/ PPrT55WVHDlxvo4skw9c8FKS4CQwGYoC2ID/qgsWVQ== X-Received: by 2002:aca:5747:: with SMTP id l68mr8367963oib.103.1553425055605; Sun, 24 Mar 2019 03:57:35 -0700 (PDT) MIME-Version: 1.0 References: <20190324101003.GA17131@hari-Inspiron-1545> In-Reply-To: <20190324101003.GA17131@hari-Inspiron-1545> From: Ondrej Mosnacek Date: Sun, 24 Mar 2019 11:57:27 +0100 Message-ID: Subject: Re: [PATCH] selinux: fixed parse warning Using plain integer as NULL pointer To: Hariprasad Kelam Cc: Paul Moore , Stephen Smalley , Eric Paris , Kees Cook , Richard Guy Briggs , jannh@google.com, Alexey Dobriyan , sgrover@codeaurora.org, peter.enderborg@sony.com, Kent Overstreet , selinux@vger.kernel.org, Linux kernel mailing 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 On Sun, Mar 24, 2019 at 11:10 AM Hariprasad Kelam wrote: > Changed 0 --> NULL to avoid sparse warning > > Sparse warning below: > > sudo make C=2 CF=-D__CHECK_ENDIAN__ M=security > > CHECK security/selinux/ss/services.c > security/selinux/ss/services.c:1323:32: warning: Using plain integer as > NULL pointer > > Signed-off-by: Hariprasad Kelam > --- > security/selinux/ss/services.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c > index ec62918..30cea59 100644 > --- a/security/selinux/ss/services.c > +++ b/security/selinux/ss/services.c > @@ -1320,7 +1320,7 @@ static int security_sid_to_context_core(struct selinux_state *state, > } > if (only_invalid && !context->len) { > scontext = NULL; > - scontext_len = 0; > + scontext_len = NULL; > rc = 0; The warning is correct, but this patch is the wrong fix. I intended to set the values to the objects pointed to by the pointers, not the pointers themselves. As is, the assignments have no effect, because they only modify the local variables, which are not used further in the function. Fortunately, *scontext and *scontext_len are already set to NULL/0 at the beginning of the function, so the code is technically correct even without them. The correct fix is actually to remove the assignments entirely. I'll send a patch that does that tomorrow. > } else { > rc = context_struct_to_string(policydb, context, scontext, > -- > 2.7.4 > Anyway, thank you for catching the mistake! One more reminder for me to finally install sparse and add C=1 to my kernel build command line... -- Ondrej Mosnacek Software Engineer, Security Technologies Red Hat, Inc.