Received: by 10.223.164.202 with SMTP id h10csp901268wrb; Thu, 23 Nov 2017 08:02:15 -0800 (PST) X-Google-Smtp-Source: AGs4zMbTRnHj/tCe/t6wVL94idrxPA1xeQsMQZeTMX/sKCoYCwchEsAf0arv1pgXNY8/Ctuc42dK X-Received: by 10.101.74.73 with SMTP id a9mr14115628pgu.444.1511452935053; Thu, 23 Nov 2017 08:02:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511452935; cv=none; d=google.com; s=arc-20160816; b=dMXKchOhPd2q3SBCCOuUDGLiFliwvZQF1xYGAfoOgnihDCVX9y05LiRqVaN6bJA4Tm KLDO6WjbMov4hPvqLLFR+J2BFbOYfjl7XR5VW46U2ahdNux51LrwbKE7ObKe2rdwZj+x B17hCLiAJS3k01RZgK/eKIDs5T62CTYdqm3bmZIFkPmKrOQyc7+CrXR6QMubhpE4Uqbt yIMZ0Hb7/fpa3+YeQD1Vi5GKseqLWk2EfwrGuR8a2zEGVWaHOL3oAgxTVsWX4VWMYoMZ mJvFkraLRgq2g+LLw/FPD052nKKuEKTV3REe0CdpXBeWW5bH0mULBhdn1xUacfCw1QSN E+/w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=zsJEklH9U1TcEr0bIc4LHh8y2/W4eWf6p1Bp/Uc5DLU=; b=MmsjbwE9qvlDkJTyDNx39+ChdzW1uAX53b4g/pWoo5Z3jSHOHQG6bkc6X1OnAbMYiY bRK3le9MVLdp/SBWWu15cPwXxfiZWjiHB3ceBE/a6opDbAp1quiMIE+17wIUdyxU0rgf YH/BXSL7Pb+2u/Pcuiv8Ol9lKngFoSwYMLTfQOAPxprPtsxQAMPLe4UT1EuKWjroit7H PiES0N12yT31AB2nSuHKIP1zvtfw24fXrgt0LDe+NgPeoJ3Brdn91g2OSTSNQyVsBjbL NuAgzTp2yxxkDoQU8cfgZudgpGbVOv7tJ5fIkiIPmhdSfJ18eQ51nuBV/m2MZeIxl9/v 3QBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=SQDeP/Dm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m26si16248139pli.826.2017.11.23.08.02.03; Thu, 23 Nov 2017 08:02:14 -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=@gmail.com header.s=20161025 header.b=SQDeP/Dm; 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=pass (p=NONE sp=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753138AbdKWQAz (ORCPT + 76 others); Thu, 23 Nov 2017 11:00:55 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:46870 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752925AbdKWQAy (ORCPT ); Thu, 23 Nov 2017 11:00:54 -0500 Received: by mail-lf0-f65.google.com with SMTP id g35so22513072lfi.13 for ; Thu, 23 Nov 2017 08:00:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=zsJEklH9U1TcEr0bIc4LHh8y2/W4eWf6p1Bp/Uc5DLU=; b=SQDeP/DmQojP7N+wzRgjKZV267WTjSixDXaVQgymygsBnhItKIAwe6qG9VEwfPWWb7 m6U6CID3a/tvL4AK/dPaMknzLgNPW8fPytpgbswRObLfd8yTVzSh+tRohOHFeEES2lj7 8o/Hjo6e6RoloI/CZYq6j/JDg+NG6ffQL/qMZ1IAx0jgzI9juo7V9yueJm0ivOQSVlSs 1a9EAVdZDb2letiKBjYMLj/uOLvrQ8IgNXFcFiLlbLHKtEAjj7NtY3mglD3sg+4KunfK WYgiuE7JEWoXk5aY/cfxBHBZ+s9s9lr5nroWg+Dxh69UBmpZZdapB8lER4znLv5a25Of vZLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zsJEklH9U1TcEr0bIc4LHh8y2/W4eWf6p1Bp/Uc5DLU=; b=mGm6n9u5q3B+B+u3y/yW+oRj24EZpDrdkscFevUpoz1UifIkQMn6v5dfnB+IhUMoMk XDfEJwgvgW7Rjf/HlPQ0gMc5JuyeBBYV3L8dKQMWYJFRSjNrRY1/LqhgyxvyF/e5rNAa JGSEVlTsPk24K7e6HrSChY3D4Jz46OIAj+x+6zyjp41T3BhUNVmYiE9sS7M3cG0Mn8IX z4JIGeeKZsGQFm6NR6WqW7/dmObEZ1IpYSwAwMKIwmSZ+9q4ey+8EwFRAeZdyxA+rGhE aVBbA7xdsniupHWjM6HgqI/5Fr3UkS+q2ge7uulyfFbTMAQv+3oF1FfZbGH2mbSBnSPi qeig== X-Gm-Message-State: AJaThX7U0ywR7KBC6nTBDTd3HgQJf3hzzpoi3s21DxMdIw8xAnlILm63 CN62hJl25kvvD8aoDXvvhSQ= X-Received: by 10.25.26.207 with SMTP id a198mr5887177lfa.193.1511452852915; Thu, 23 Nov 2017 08:00:52 -0800 (PST) Received: from localhost.localdomain ([195.254.138.66]) by smtp.gmail.com with ESMTPSA id l76sm3373274lfe.22.2017.11.23.08.00.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 23 Nov 2017 08:00:52 -0800 (PST) From: Vasyl Gomonovych To: keescook@chromium.org, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, gomonovych@gmail.com Subject: [PATCH] lkdtm: Missing kmalloc check Date: Thu, 23 Nov 2017 17:00:42 +0100 Message-Id: <1511452842-10680-1-git-send-email-gomonovych@gmail.com> X-Mailer: git-send-email 1.9.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Handling a possible memory allocation failure. Signed-off-by: Vasyl Gomonovych --- drivers/misc/lkdtm_heap.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/misc/lkdtm_heap.c b/drivers/misc/lkdtm_heap.c index f5494a6d4be5..65026d7de130 100644 --- a/drivers/misc/lkdtm_heap.c +++ b/drivers/misc/lkdtm_heap.c @@ -16,6 +16,8 @@ void lkdtm_OVERWRITE_ALLOCATION(void) { size_t len = 1020; u32 *data = kmalloc(len, GFP_KERNEL); + if (!data) + return; data[1024 / sizeof(u32)] = 0x12345678; kfree(data); @@ -33,6 +35,8 @@ void lkdtm_WRITE_AFTER_FREE(void) size_t offset = (len / sizeof(*base)) / 2; base = kmalloc(len, GFP_KERNEL); + if (!base) + return; pr_info("Allocated memory %p-%p\n", base, &base[offset * 2]); pr_info("Attempting bad write to freed memory at %p\n", &base[offset]); -- 1.9.1 From 1585394830655117916@xxx Wed Nov 29 10:12:11 +0000 2017 X-GM-THRID: 1585394830655117916 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread