Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3791586pxj; Tue, 11 May 2021 11:57:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwiNSQ0ERVNk1//ax/ap+9MXFK+fplRz7G5oWNkQvWqwSysXIMiPyJFfQdAUG7FZNIhBg+4 X-Received: by 2002:a17:906:3989:: with SMTP id h9mr32869966eje.309.1620759422142; Tue, 11 May 2021 11:57:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620759422; cv=none; d=google.com; s=arc-20160816; b=XSYUkoeO96jz0/8rSmEXCn7e2kdGGnU6wQbS0IQgB+DetIMYJldb65K+Fshz1P36Da TBiW4aY+hVwIJlFuBisIO5/V0/D9LFd1THEfPofH9FPohBwFv33Q2utoifX8gMWuQbTL IEbANU8tEUMKSPHTynEZd5h5THAfZashPAYqV76CjAWwaRYzwZS/myc9UX7DYaJhYHUI D0eNX3Nh4yGDsGpH0ZEH0hwgysTAxRAQq5YQfz4fBXy15+gHHLWy7J2tqayGIEknWtVJ AKiJGKqgTy9njsPvcDIxNGrvJEjgnWU3WSJ3p+yJIgipD5EuwIhy4gsfAzUWCYX2pnDn yaqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=v/Ph7k82kiUENJBSQiDSR8itgIh5RXyi6b0YkXaL6Qw=; b=pYwIts1AW17hGWk0Za4Pvdo8744pDe8CM7YEm4g8XR3keSTt99WDBm4iL0UKTsVCfN sx2R6oL4nT0g/jpEiYDntRCZhI4tow1Wa5n5izBYl/Y8V/e3pSPvbIrLko20qXNhXKWU KdAIc4aYVXd46YOnXHz9jr75GoyokAupdwj6s5uQPqMBD3AdzSM9Ak6J+ZPh8JpT0eYc F9aaOESPhi3ALa9GFbbg9YWqvZvYeCAnNQIXWkSjQncMQYma2rQKWoRbrOEj1UIe9yXG vDDRHO/S1nwxN0uQu/pQgof2hzl9e0qrbwOEnaIMoZudONkH1tT+K0ZvuRRs/m9YVa55 wJ7A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BdHqxobx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g19si5010310edu.41.2021.05.11.11.56.38; Tue, 11 May 2021 11:57:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BdHqxobx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232458AbhEKSxi (ORCPT + 99 others); Tue, 11 May 2021 14:53:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232229AbhEKSxC (ORCPT ); Tue, 11 May 2021 14:53:02 -0400 Received: from mail-io1-xd29.google.com (mail-io1-xd29.google.com [IPv6:2607:f8b0:4864:20::d29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 671CBC06134C for ; Tue, 11 May 2021 11:51:51 -0700 (PDT) Received: by mail-io1-xd29.google.com with SMTP id o21so18778500iow.13 for ; Tue, 11 May 2021 11:51:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v/Ph7k82kiUENJBSQiDSR8itgIh5RXyi6b0YkXaL6Qw=; b=BdHqxobx3i0b8GFby3ylXvLvy5TPzMJHaZElk+Rric9BlIXo/eZoPETSI69DwIDOyb qMzvAlAQ8IQa75MMu3o6phnrh7J2iWj41hr2aTQfhoINsY8bDgSE67fn1w6eLeDz9rPV r4MihMi0N1wvc3cA3R9iAhw/YoTaDHZvzPJ+qtskdkSjfmwligZc/T3ybGAh8DXo50eE IcbrW1wVbCkW/w+kwGKPxbT5ZTSj5fWm+ZkdPAz0coqBZ5KjCIOogdrIzucq+KytsPDB QftccG/y/a3Fkw68Yg+8cIPxLCRpXVBoGtypkty4GZIe4A2zbB2BXt3UtVJn8pwM5EKK fAyg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=v/Ph7k82kiUENJBSQiDSR8itgIh5RXyi6b0YkXaL6Qw=; b=ZGTENLkUb0s9oV8STzolZcb11+d0i9WPr2zRE7Av5dGKZysm/rYD6nPC00UIqFzANC zrffyomr0OAMmXzyZ3pC4NwxEopYGzGYZyOMCWeEx3EWlYNy+JpIzyAEdFbdE2ZVdNYp AInnF4m4lWDdrAhEkRhyw97pg/nXk4QB96DI+KW8ftZsea1qsTyya1GBf2HXj/FFDE0c YAghpYjQole2n5wNLRGtZ1q9eYhbTNiy++aB+xDmyafJe+61eEo2baLVz98kWThP9AqP G6rOO3yx9W3BIm+T6FaqPRhK7WYHeGz3X7pxui1vzmLG3wMPVXA0xqyC0bhn2L3IM0Bn QgWQ== X-Gm-Message-State: AOAM533AGZulLWRIvumt6qRtnVGVGyxGksz7xFCDz+Qxe5MxNC+Re40j 5n/K9dvAWoQ42dt/0207LEg= X-Received: by 2002:a6b:d10c:: with SMTP id l12mr23361714iob.179.1620759110663; Tue, 11 May 2021 11:51:50 -0700 (PDT) Received: from frodo.mearth (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id t10sm405096ils.36.2021.05.11.11.51.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 May 2021 11:51:50 -0700 (PDT) From: Jim Cromie To: Jason Baron , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, Jim Cromie Subject: [RFC PATCH v5 22/28] dyndbg: fix NULL deref after deleting sites Date: Tue, 11 May 2021 12:50:51 -0600 Message-Id: <20210511185057.3815777-23-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210511185057.3815777-1-jim.cromie@gmail.com> References: <20210511185057.3815777-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After `echo module main +D > control` zeros the site pointer for main's callsites, `cat control` causes a NULL deref in ddebug_site_get(). Fix this with: - in vpr_infos, avoid dp->site->module, use dh->sites[dp->_index] - qualify WARN_ONs that test against dp->site. Also return dp->site, which may be null. This restores the abbreviated control output of deleted sites, rather than pretending it wasnt deleted. Deleting sites isn't an important feature, and its current form will be obsolete when the site pointer gets dropped. Its also pointless if the site data is in compressed blocks. But its still worthwhile to maintain !site robustness for a bit. Signed-off-by: Jim Cromie --- lib/dynamic_debug.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index af9791258f8f..d0477450ec0c 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -154,8 +154,8 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) if (dp >= __start___dyndbg && dp < __stop___dyndbg) { - v5pr_info("get: %s is builtin: %d %d %s:%s:%d\n", - dp->site->modname, dp->_index, (int)(dp - dh), + v5pr_info("get: %s is builtin: %d %s:%s:%d\n", + dh->site[dp->_index].modname, dp->_index, dh->site[dp->_index].filename, dh->site[dp->_index].function, dp->lineno); @@ -165,15 +165,16 @@ static struct _ddebug_site *ddebug_site_get(struct _ddebug *dp) dp->_index == (dp - __start___dyndbg) && dp->_index == (&__start___dyndbg_sites[dp->_index] - &__start___dyndbg_sites[0]))); - - WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); + if (dp->site) + WARN_ON(&__start___dyndbg_sites[dp->_index] != dp->site); } else { v4pr_info("get: %s is loaded: %d %s:%s:%d\n", - dp->site->modname, dp->_index, + dh->site[dp->_index].modname, dp->_index, dh->site[dp->_index].filename, dh->site[dp->_index].function, dp->lineno); } - WARN_ON(&dh->site[dp->_index] != dp->site); + if (dp->site) + WARN_ON(&dh->site[dp->_index] != dp->site); return dp->site; } -- 2.31.1