From patchwork Thu Feb 15 14:13:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Kellermann X-Patchwork-Id: 201491 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:b825:b0:106:860b:bbdd with SMTP id da37csp426720dyb; Thu, 15 Feb 2024 06:13:59 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUfHs4+2eKjkHcSKYfAyu0KwSwX6kb5GF8/npM+0GZpA0j/3hr//bqfUpAoe9nI+9kPfTVoHuwtt5uqtMa2vzi7Ucr+Tw== X-Google-Smtp-Source: AGHT+IH0tWKJd5JeCeQwwSxsTeY3BZ31RIkJ4o2htyvnXWlscMYZjDtPjrh7BZL31SouQITQB7x6 X-Received: by 2002:a05:620a:2283:b0:787:3311:4327 with SMTP id o3-20020a05620a228300b0078733114327mr1926636qkh.73.1708006439131; Thu, 15 Feb 2024 06:13:59 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708006439; cv=pass; d=google.com; s=arc-20160816; b=EP5ByzIShdavcvtRUy0o4PKCKD4++zswPcSgKf6S/+U8rEwXIm5JK0EweuuFe8kw50 pMfaj4Psi2dOPzcGe/UT3pGKRYtWYOPgHCrcivAF0uME3oY/Bo1wpz2L4ZY/N0+xiQJ/ M+StnLcMyIOB1uxVfMdSP4SkmK6rL6LFWfeuDzB++8hXeGOQqOLuuNGIp+N+1LusHU4p 5cecKz+hyfGsufdY/O8xFo8Qx2zqwRQNvfu+aE7c+RW30Q+RqG5jWrpt2HvHcwwDzsat tbS6xaKGwamKC/Pz9SZwPofHlJLonnlWhT+sJAMxSQnMlMak64+SMXVfezfnq5QsH0az KB2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=qZLd9NX3ymKq7wMa9QaV0cpLQd+CyTlNqfrZR5Cx3Qk=; fh=LZGSmb1OUheFSD9lhFK3S1fSrS90c6HP5eX/CXV+Tm8=; b=kwxqdcZCXkWPGLCTt4pLXvyyfbBP+mWJ2Dg4thPAX86XqZVBr+Xsus0dDz0D37Jhfc iVJ5IaW6062PBFCrabGc6dbJ0Qeh9yaxvx/dHfekLRf7GBZgQMzsQhatOoX/dM4acHrQ tDVt631foUGZoQRCDVt+wP3TLlEAifHTTX98nNjnpi4Qa1yNF6t5PiaGLkCaKw4XUZet etea4k6BF4ys+DqY4nDLenS4c4Hr+kgULAz4J6AD20sBJ/5GxyLhF7bqWASKoUlYvVwQ +f4wNr4Gcktbgc3vUx3qNG5BqT1Av67hoTNifFGUNHsmAd+Rk8wcSLkg/wEjDg3yN48E 4q9Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=cdCVBnDZ; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id k8-20020a05620a414800b007869b730c77si1682049qko.659.2024.02.15.06.13.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:13:59 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-67063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ionos.com header.s=google header.b=cdCVBnDZ; arc=pass (i=1 spf=pass spfdomain=ionos.com dkim=pass dkdomain=ionos.com dmarc=pass fromdomain=ionos.com); spf=pass (google.com: domain of linux-kernel+bounces-67063-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-67063-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=ionos.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id DEF201C21241 for ; Thu, 15 Feb 2024 14:13:58 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FFDC131E3E; Thu, 15 Feb 2024 14:13:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b="cdCVBnDZ" Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51487130E40 for ; Thu, 15 Feb 2024 14:13:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006423; cv=none; b=HOEDrQppKbabReuSIK5aARtu78s+OqVGDEx5vlmoH+q/NkbwqtvC55G2nUssjF/dZwRC6eXxUd0DeJH6QNitIbJIK6gKAkikl0xexNuAcwe903mKbr5QN4sELGTOm54CRBvBrvj54MelZ2ye8Rc22w/gcr2I58wA+p/uX6fS4W8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708006423; c=relaxed/simple; bh=Y6qeuARksgU+rEgbZqHNJm3BXr+2VBnjsm2duHdLWIs=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=sMnEuya+u864Qy/eOwDB0sSIZR6r0YPvr0wAHIg3sbpgR8IIPuhow0V1ERSh9LAR/gWedyvQJAIgfee4XYwveSiEd4WqX18SY5UTPpkY1METxrtnuJnPlPjZPSe3qmZzzwW3Q7PyVD5QKEYUvO6oddaHJt3lRkSkRFtjeawY4yM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com; spf=pass smtp.mailfrom=ionos.com; dkim=pass (2048-bit key) header.d=ionos.com header.i=@ionos.com header.b=cdCVBnDZ; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ionos.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ionos.com Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a29c4bbb2f4so117672066b.1 for ; Thu, 15 Feb 2024 06:13:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; t=1708006419; x=1708611219; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qZLd9NX3ymKq7wMa9QaV0cpLQd+CyTlNqfrZR5Cx3Qk=; b=cdCVBnDZffml7fx5wZG0IJJ9LetSwIKOOQy7Zay4w9XW+nog88Ia5Q9G/RMVBlgYPn mjyyrNx0YHUWlpcoTW+VSLgP12+WpoZT2tw/5PHRub6x185I871lJj8rpBauMKabPh0y SPuyUSsMm63M+yEELILU45siOPiZleS3AMK3bqh0AUTVHYhcjcZhKh8gIMZGWqHWoonx 2rO5xHBTm5j/RI6/+VMSy735CtO2OX0HJTlO+aDnctz/OW+rJ+4ccFQGpeKsdqCeWKcw Z+PIPnl2IYlz8pUgNI/gGuNIrSi49JMYEmAr8Cr23fkTdJwIeayn/TigL6DU2Qm67bik hOuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708006419; x=1708611219; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qZLd9NX3ymKq7wMa9QaV0cpLQd+CyTlNqfrZR5Cx3Qk=; b=Q5ydNNSrOUZrxxt+7TliIhozYW0OZmTogoyVMxikA36Dk83GU+MuDt6oXLHzUP2HDS IoOKY1Xz23KCK68Q+YQfEjxd7m6ka2ahwmxTDPM45HSXS8Ie0OyUBY6R+LPuBdOSEesa hv/udKgMFf4UYHyZFjzhfPL1/jx/YS+bEzWD65Bgfv9xB5je2lIfW+PDiUID4lFs6hNX PY6Hq0BrGhGppFNdGdhJEMhXaskh4Be0v/YhbL0ZfMsfpoGtJLX1Mwpo+lF0v6m4/kY/ xkc7pYhAsYgtGYEwT4SLGXENy2pdn8W46KHNOnkx8WzYNWK4V0HVOyLyj8xyvcccXEIX oA7g== X-Forwarded-Encrypted: i=1; AJvYcCXxA/MywKI6Q9Bv8/4RmSidduZSobHGkQm37TE3+yoyGntIw2CIZ31vw5TTTLok/6nJcMvVNHAI8PdpAuO71tlCYoZRK0I1HpkHRXFM X-Gm-Message-State: AOJu0Ywsvb/QXqUthaF+/x7gDTqQ6UQTaRimBTXzbl266CMkSFanbgR7 Y2Em6rqwWTazsE3pSRMPKm3mCqqTdA4N9PHjgFg7iF9k4e7j3IJDAjO4rxfC8J9xbjC31BC5+aU R X-Received: by 2002:a17:906:3ca:b0:a3d:b60a:3701 with SMTP id c10-20020a17090603ca00b00a3db60a3701mr330019eja.41.1708006419575; Thu, 15 Feb 2024 06:13:39 -0800 (PST) Received: from raven.blarg.de (p200300dc6f267100023064fffe740809.dip0.t-ipconnect.de. [2003:dc:6f26:7100:230:64ff:fe74:809]) by smtp.gmail.com with ESMTPSA id gs36-20020a1709072d2400b00a3d0a094574sm585985ejc.66.2024.02.15.06.13.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 15 Feb 2024 06:13:39 -0800 (PST) From: Max Kellermann To: masahiroy@kernel.org, nathan@kernel.org, nicolas@fjasle.eu, linux-kbuild@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Max Kellermann Subject: [PATCH] scripts/mod/modpost: fix null pointer dereference Date: Thu, 15 Feb 2024 15:13:21 +0100 Message-Id: <20240215141321.899675-1-max.kellermann@ionos.com> X-Mailer: git-send-email 2.39.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790974559921126904 X-GMAIL-MSGID: 1790974559921126904 If the find_fromsym() call fails and returns NULL, the warn() call will dereference this NULL pointer and cause the program to crash. This happened when I tried to build with "test_user_copy" module. With this fix, it prints lots of warnings like this: WARNING: modpost: lib/test_user_copy: section mismatch in reference: (unknown)+0x4 (section: .text.fixup) -> (unknown) (section: .init.text) Signed-off-by: Max Kellermann --- scripts/mod/modpost.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index bf7c4b4b5ff4..6b37039c9e92 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c @@ -1050,7 +1050,9 @@ static void default_mismatch_handler(const char *modname, struct elf_info *elf, sec_mismatch_count++; warn("%s: section mismatch in reference: %s+0x%x (section: %s) -> %s (section: %s)\n", - modname, fromsym, (unsigned int)(faddr - from->st_value), fromsec, tosym, tosec); + modname, fromsym, + (unsigned int)(faddr - (from ? from->st_value : 0)), + fromsec, tosym, tosec); if (mismatch->mismatch == EXTABLE_TO_NON_TEXT) { if (match(tosec, mismatch->bad_tosec))