Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp409371pxb; Mon, 25 Apr 2022 12:33:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSCificPBkKrB44M8RpCh/tZah20Cde69nGf3SH6AlwRye6w1KK3uM572cxNDSX1IVbfs1 X-Received: by 2002:a17:90a:cf:b0:1d9:44ad:2607 with SMTP id v15-20020a17090a00cf00b001d944ad2607mr12884608pjd.25.1650915196859; Mon, 25 Apr 2022 12:33:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650915196; cv=none; d=google.com; s=arc-20160816; b=RfZZW/EDkjdhihVyIVOzavu285RHY6gsun5Jeh7D7598Mc4FdJdk/t2Qt+bpxidWWt DRl04SNt8icrYROjwx7CNbbjjjeEcGFoR1l22S0Hd4nAGT7jXU+/qXAnNiS3NxPmx0fE ge9bGR5v2W/cPo3HJAcK6xMEqFmBAmwCjsb2FRE1wCoC+r08wpOFUAUnlqeCxvf0IcWW ZBdu5JA/7GeTTz6Kv9iUpoJ+hyO3lb5LuH5pVqrjYuqPKNLT/JLhz+Nm4Br8+iFrShiM 3Z8SpQc/9eFy4CDtysWJ4VALKBh1CttJj20KBwC2Ygz7kwcNyU9lYIQ7OabJV5o6rq5l 7p4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=m8zyZFhgZtJWBx1ewY9EOqVFGvVP4XffFDuTR4TMpZg=; b=RPNDfDQmrlhE8jAQZ2rSFenv6qGaDj81FS5iGVfhfJP4fizAn/RcQXB1kDJn2sPDqk 2dPPu9YaAe+G9EbXF0kRFheb4tJFM3KzcWkmEIpTH1/x7aGXDUjMXVb8fo4qZbZE9mf7 4MzsstmfArcyaqpub6mKL2ONaSCfnxGiugHKOwwdLDskyqkdQvUVkMeX4Le5HsmAVJsC JN9W0FZAZDSHm1K3VJT5AHp28Aw7UY33qzxvlnOkwQTuTnxwPnvC5cz7L5bSK1iatiev VRAXR2PTv55TV/txaziOFOVJK/ebbNbHQ5zaLB95s3V3zW145ePQrLoaz/jY2pszNs3N Q+PA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=MQGT7rHP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n19-20020a170902969300b00153b2d16485si15519020plp.141.2022.04.25.12.33.00; Mon, 25 Apr 2022 12:33:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=MQGT7rHP; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237034AbiDYQYg (ORCPT + 99 others); Mon, 25 Apr 2022 12:24:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243332AbiDYQYe (ORCPT ); Mon, 25 Apr 2022 12:24:34 -0400 Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6A406D1B6 for ; Mon, 25 Apr 2022 09:21:30 -0700 (PDT) Received: by mail-io1-xd2e.google.com with SMTP id z19so11802940iof.12 for ; Mon, 25 Apr 2022 09:21:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=m8zyZFhgZtJWBx1ewY9EOqVFGvVP4XffFDuTR4TMpZg=; b=MQGT7rHPHJlegzzdydwoJhuaK1pG/0OJnThzowwuLn6x+cXtb77D9y87kJTDstyih4 YK/CNOa++pAeVSwwTe6cUUrtkx09oMp5w3WBMvA1GfvwY0vxBhcovOYOaasRLYY1ARbM OngZjpYsSL2SXEYYNa/u687tdECwchngQQkWc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=m8zyZFhgZtJWBx1ewY9EOqVFGvVP4XffFDuTR4TMpZg=; b=z7u8AKq9V4EOT4MJXXrZmIRIVfSo9qUoiWGdqdvHpfT7wrobqYIzrgDapeL0L5fgDJ eXFdnLewNrDWVJFP2SNwlhwjwlpkCDq6TnVeE44p9UShSvLw2lWAH5Fd3tdbalwRhxsA 3lAiVWGv22Qs9fUh26J36FkxHx/KWr+YilykBl/Z9Mv3aduJ0VsWZYzX6dqvKyFQTNht HGlijnWpIiha60Y7f8ITkii7qqvwGw0xW8YibvtVBaKKvd14fXLggmysXYJKuAqoKc/h OianOKMIs4rRrEfdXmAF5FcTmraaX2iPrujd6b/qdOFkNVwgtGK8O4wRP69iM0PvyZOe Za1w== X-Gm-Message-State: AOAM5331rJEbOLlJ8W0EA9jlcq2THLN/eyHEk1tPRBfy1cyAr/18uVBE 1MxyPQ11mgZpFVkF6zoJQOoP7w== X-Received: by 2002:a05:6638:41a0:b0:32a:90ae:f7a1 with SMTP id az32-20020a05663841a000b0032a90aef7a1mr7963693jab.101.1650903690100; Mon, 25 Apr 2022 09:21:30 -0700 (PDT) Received: from [192.168.1.128] ([71.205.29.0]) by smtp.gmail.com with ESMTPSA id m8-20020a92cac8000000b002ca9d826c3fsm6495170ilq.34.2022.04.25.09.21.29 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 25 Apr 2022 09:21:29 -0700 (PDT) Subject: Re: [PATCH] selftests/resctrl: Fix null pointer dereference on open failed To: "Colin King (gmail)" , Fenghua Yu , Reinette Chatre , Shuah Khan , Babu Moger , Sai Praneeth Prakhya , linux-kselftest@vger.kernel.org Cc: kernel-janitors@vger.kernel.org, linux-kernel@vger.kernel.org, Shuah Khan References: <20220424211536.1373878-1-colin.i.king@gmail.com> <04a35a47-d83a-67a1-5ed4-ba314c6e1ecf@linuxfoundation.org> <604ea061-c566-e032-67cf-9bc622aa76ae@gmail.com> From: Shuah Khan Message-ID: Date: Mon, 25 Apr 2022 10:21:29 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: <604ea061-c566-e032-67cf-9bc622aa76ae@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 4/25/22 10:06 AM, Colin King (gmail) wrote: > On 25/04/2022 16:51, Shuah Khan wrote: >> On 4/24/22 3:15 PM, Colin Ian King wrote: >>> Currently if opening /dev/null fails to open then file pointer fp >>> is null and further access to fp via fprintf will cause a null >>> pointer dereference. Fix this by returning a negative error value >>> when a null fp is detected. >>> >> >> How did you find this problem and how can it be reproduced? Is there >> a case where test fails to open "/dev/null"? > > Found with static analysis, cppcheck. Open on /dev/null is unlikely to fail, but it's good to fail reliably rather than have a SIGSEGV :-) > I don't see how /dev/null open could fail here in this test. However, I will take this fix. Please add information how you found it and include the cppheck log in the commit log and send me v2. thanks, -- Shuah