stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Yi Wang <wang.yi59@zte.com.cn>,
	Jiang Biao <jiang.biao2@zte.com.cn>,
	Richard Guy Briggs <rgb@redhat.com>,
	Paul Moore <paul@paul-moore.com>
Subject: [PATCH 4.14 17/23] audit: fix potential null dereference context->module.name
Date: Sat,  4 Aug 2018 11:01:08 +0200	[thread overview]
Message-ID: <20180804082645.583152736@linuxfoundation.org> (raw)
In-Reply-To: <20180804082643.641435547@linuxfoundation.org>

4.14-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Yi Wang <wang.yi59@zte.com.cn>

commit b305f7ed0f4f494ad6f3ef5667501535d5a8fa31 upstream.

The variable 'context->module.name' may be null pointer when
kmalloc return null, so it's better to check it before using
to avoid null dereference.
Another one more thing this patch does is using kstrdup instead
of (kmalloc + strcpy), and signal a lost record via audit_log_lost.

Cc: stable@vger.kernel.org # 4.11
Signed-off-by: Yi Wang <wang.yi59@zte.com.cn>
Reviewed-by: Jiang Biao <jiang.biao2@zte.com.cn>
Reviewed-by: Richard Guy Briggs <rgb@redhat.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

---
 kernel/auditsc.c |   13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

--- a/kernel/auditsc.c
+++ b/kernel/auditsc.c
@@ -1274,8 +1274,12 @@ static void show_special(struct audit_co
 		break;
 	case AUDIT_KERN_MODULE:
 		audit_log_format(ab, "name=");
-		audit_log_untrustedstring(ab, context->module.name);
-		kfree(context->module.name);
+		if (context->module.name) {
+			audit_log_untrustedstring(ab, context->module.name);
+			kfree(context->module.name);
+		} else
+			audit_log_format(ab, "(null)");
+
 		break;
 	}
 	audit_log_end(ab);
@@ -2387,8 +2391,9 @@ void __audit_log_kern_module(char *name)
 {
 	struct audit_context *context = current->audit_context;
 
-	context->module.name = kmalloc(strlen(name) + 1, GFP_KERNEL);
-	strcpy(context->module.name, name);
+	context->module.name = kstrdup(name, GFP_KERNEL);
+	if (!context->module.name)
+		audit_log_lost("out of memory in __audit_log_kern_module");
 	context->type = AUDIT_KERN_MODULE;
 }
 

  parent reply	other threads:[~2018-08-04  9:01 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04  9:00 [PATCH 4.14 00/23] 4.14.61-stable review Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 01/23] bonding: avoid lockdep confusion in bond_get_stats() Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 02/23] inet: frag: enforce memory limits earlier Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 03/23] ipv4: frags: handle possible skb truesize change Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 04/23] net: dsa: Do not suspend/resume closed slave_dev Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 05/23] netlink: Fix spectre v1 gadget in netlink_create() Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 06/23] net: stmmac: Fix WoL for PCI-based setups Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 07/23] rxrpc: Fix user call ID check in rxrpc_service_prealloc_one Greg Kroah-Hartman
2018-08-04  9:00 ` [PATCH 4.14 08/23] net/mlx5e: E-Switch, Initialize eswitch only if eswitch manager Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 09/23] squashfs: more metadata hardening Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 11/23] can: ems_usb: Fix memory leak on ems_usb_disconnect() Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 12/23] net: socket: fix potential spectre v1 gadget in socketcall Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 13/23] virtio_balloon: fix another race between migration and ballooning Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 14/23] x86/apic: Future-proof the TSC_DEADLINE quirk for SKX Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 15/23] x86/entry/64: Remove %ebx handling from error_entry/exit Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 16/23] kvm: x86: vmx: fix vpid leak Greg Kroah-Hartman
2018-08-04  9:01 ` Greg Kroah-Hartman [this message]
2018-08-04  9:01 ` [PATCH 4.14 18/23] userfaultfd: remove uffd flags from vma->vm_flags if UFFD_EVENT_FORK fails Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 19/23] iwlwifi: add more card IDs for 9000 series Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 20/23] RDMA/uverbs: Expand primary and alt AV port checks Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 21/23] crypto: padlock-aes - Fix Nano workaround data corruption Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 22/23] drm/vc4: Reset ->{x, y}_scaling[1] when dealing with uniplanar formats Greg Kroah-Hartman
2018-08-04  9:01 ` [PATCH 4.14 23/23] scsi: sg: fix minor memory leak in error path Greg Kroah-Hartman
2018-08-04 14:48 ` [PATCH 4.14 00/23] 4.14.61-stable review Guenter Roeck
2018-08-05 11:51 ` Naresh Kamboju

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180804082645.583152736@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=jiang.biao2@zte.com.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=rgb@redhat.com \
    --cc=stable@vger.kernel.org \
    --cc=wang.yi59@zte.com.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).