Received: by 10.223.185.116 with SMTP id b49csp1294195wrg; Wed, 21 Feb 2018 16:04:25 -0800 (PST) X-Google-Smtp-Source: AH8x226vNSaMOFClLETBNMG51uvVOR8DWdtEBojGAAWpDMdVqJtg2sB7ljE3svSoizliWfnlU1zC X-Received: by 2002:a17:902:a705:: with SMTP id w5-v6mr3566694plq.299.1519257865683; Wed, 21 Feb 2018 16:04:25 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519257865; cv=none; d=google.com; s=arc-20160816; b=FzTD6kYb1JmR9wfXIeNybEP3eGxRNoSshmLPF8kYIvq/jabTToeN/W4VIY5i6XE7Zv XycQar935LAfxnO3vlNbq20IPBh7/LZtBfo6XSEE3HJg1IyiagZQND2TasYFzdUX8Acp WuPVm+6jHSfM6uir+EIdcdUOq5QUtm1DdcMn0LXcs0ZOoeUmPjzjRt2ym9lO42BOCxl0 my9k6UpwnEHtGG/HBvDTyKmuma1WEoAhlgkVSL5/AOts9vc2orKCFQysLHpMGN1kAODQ EacDWY5JxNkrLza1FnhPOKO1AYZsSMo3K41TwUzaaeQaQ7EKrMGa5aiNx98hxiTr2kGR VrmQ== 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=2Go7iE8kPEXGIBW7/uIln042CE15sNYIfovI6X8CA7M=; b=vbq+0uWGdhh7SBk4iUHbYRMiNA/ka+j9BOMzNpneVt0ZI8wkyoziYKC7XDy4o0JsVE s1d7HDe6v6njgaAA2qzClu8KqW4U5sqDS5LeojsMqiwEgX0Wy/im/upd7x1QGrg/Flzp ZcmCReZCEpXHLMEB0UtYg4xoaedjzeStiHgvKk5J9HTInsz1SAS8f7FqcybRA/JAw4ru OW7M6EOi8EBGTqOrAqOJH28eKOd4KX4RdmcEOiF/1KCTUp77oKw8W+/05qLg8T5bDIcG NjHStQ2ppw9jYZy6kJS1IvXCjSLykmZM3tehtok3H6VlSOtgJPMGLTWkjlKZCUPhlCqX Tg9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=e1O5naUy; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m8-v6si573377plk.593.2018.02.21.16.04.11; Wed, 21 Feb 2018 16:04:25 -0800 (PST) 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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b=e1O5naUy; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751329AbeBVACP (ORCPT + 99 others); Wed, 21 Feb 2018 19:02:15 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:40075 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750752AbeBVACO (ORCPT ); Wed, 21 Feb 2018 19:02:14 -0500 Received: by mail-lf0-f68.google.com with SMTP id 37so4867654lfs.7 for ; Wed, 21 Feb 2018 16:02:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=2Go7iE8kPEXGIBW7/uIln042CE15sNYIfovI6X8CA7M=; b=e1O5naUytIrfHSIyJE/YLC196K7UmWU8Gf03gEVC1ZMNE0GE14c1GfCfbuIy4obouo KYnSB8bO1Cx+Z4uskJ9ZkM2rUjmO7eAoPSMLQJHZ+TNQ92r3/OBVF4AUhvSI8yCzk5My jHTkgCh6XCcnTV8afXXeSkmtfsJKN70ALil4hR2s2s2b9a9SjGSQdFj7JgH2KXxJEIFr gerUjqoDNs1dw4sUDH2S2jOG/vcoSeXsSRdeKh2iMElghww8IikD+mT/f6IdtsOYP9WL N9bf53y/ETuuAP0wP7dWgSTym+Eg+uMxn8ctEHSxI4U+r2yQzxT/EJj0FarQXdkB4fVK sdpQ== 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=2Go7iE8kPEXGIBW7/uIln042CE15sNYIfovI6X8CA7M=; b=Lwtbt/PX8YAttYLNHkCtucVgPHqX/53S82gfX0Tbkpzw7VGzU2jOXgFEjDTsmSczZN 6B8Ll9YT5ZYdb1IrUbBuMtzUT/4r9E9k077YfAbDMr9tqj/4x52Uq3A/OuWa65L/uBzi y6KU2MQTtfGCfEE52O9/zzWH8Bzp5r+qt/Cq+FgiP7UQdDyutKGxowoypobmctq5Y0As RY3sgwg8Kq+fFjtZ7bmvLtyMIxfSyAA3s2T+I96RxPMaOkmZ4zUzQr5HUvF9VJ37yqT+ 47qoL3qSblVLvExqWJLv9V++21pMZFQbZugtYpW7Wrjh+io399bEkzLKSex9BoTo8/Wm WkWQ== X-Gm-Message-State: APf1xPDLBdvawf1U/Yr5GhdnCCVZriNDViODoWwvw6j4cRa6xYojapgZ 8EuZ9RZHoFjIXkDFXRWlg/XAeyZmaFDbinN/PR2mcyc= X-Received: by 10.25.21.101 with SMTP id l98mr3754141lfi.139.1519257732601; Wed, 21 Feb 2018 16:02:12 -0800 (PST) MIME-Version: 1.0 Received: by 10.25.216.167 with HTTP; Wed, 21 Feb 2018 16:02:11 -0800 (PST) X-Originating-IP: [108.20.156.165] In-Reply-To: References: <2000f6951431b4f19947d7aa41bb8efd2fe3f15b.1519196084.git.rgb@redhat.com> From: Paul Moore Date: Wed, 21 Feb 2018 19:02:11 -0500 Message-ID: Subject: Re: [PATCH] audit: return on memory error to avoid null pointer dereference To: Richard Guy Briggs Cc: Linux-Audit Mailing List , LKML , Eric Paris , Steve Grubb 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, Feb 21, 2018 at 6:49 PM, Paul Moore wrote: > On Wed, Feb 21, 2018 at 4:30 AM, Richard Guy Briggs wrote: >> If there is a memory allocation error when trying to change an audit >> kernel feature value, the ignored allocation error will trigger a NULL >> pointer dereference oops on subsequent use of that pointer. Return >> instead. >> >> Passes audit-testsuite. >> See: https://github.com/linux-audit/audit-kernel/issues/76 >> Signed-off-by: Richard Guy Briggs >> --- >> kernel/audit.c | 2 ++ >> 1 file changed, 2 insertions(+) > > Thanks, merged. > > In the future a "[PATCH v2]" prefix would be appreciated for patches > like this, it makes things a little easier in my inbox. After merging this I went through all the other callers to see if they suffered the same mistake and everyone except for IMA was checking the returned pointer for NULL. Upon looking at the IMA code, and the audit code which is called, I realized we are actually "ok" as audit_log_task_info(), audit_log_format(), audit_log_end(), and others all check for a NULL audit_buffer at the very top of the functions. I'm going to leave this patch merged, it's a good practice after all, but I don't believe that unpatched systems are in any danger of oops'ing here. >> diff --git a/kernel/audit.c b/kernel/audit.c >> index 5c25449..2de74be 100644 >> --- a/kernel/audit.c >> +++ b/kernel/audit.c >> @@ -1059,6 +1059,8 @@ static void audit_log_feature_change(int which, u32 old_feature, u32 new_feature >> return; >> >> ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_FEATURE_CHANGE); >> + if (!ab) >> + return; >> audit_log_task_info(ab, current); >> audit_log_format(ab, " feature=%s old=%u new=%u old_lock=%u new_lock=%u res=%d", >> audit_feature_names[which], !!old_feature, !!new_feature, >> -- >> 1.8.3.1 -- paul moore www.paul-moore.com