Received: by 2002:a05:7412:1e0b:b0:fc:a2b0:25d7 with SMTP id kr11csp1287332rdb; Fri, 16 Feb 2024 10:40:35 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV9fpi5m8bzxnfSjvtQkMjrf7E9d27iYuwcAkf4W45V1T4g/ARETEcOZD9E3lTk01ZK+P5JHt9O7Egj06pyVs8TTwurRGxbzt5zI3JoCw== X-Google-Smtp-Source: AGHT+IGpytG4AxFHmkjzWp8a9vDG/I+/4a7qZgE3Z1sw8vonOUEgxEgjnjYVfp9sBF1wFitU/jO6 X-Received: by 2002:aa7:d614:0:b0:561:5a24:65fc with SMTP id c20-20020aa7d614000000b005615a2465fcmr4368060edr.5.1708108835678; Fri, 16 Feb 2024 10:40:35 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708108835; cv=pass; d=google.com; s=arc-20160816; b=xvX4wMgYcXhHSCxxxNURQnMJfdH9az3VB1CGgSZfbJKi/IKsKMUh8OZnK3whmKZOKm 0T+ICBthzX0spgs9rAqXz5zTExX9ugYvfPggWtruWHxcL8Zmmwk6vFj07hgS+l+TVTxV hOSIf9CmovQbr95tl1rsFBNZva4gvMyl4WPBjoOWHPATIpPleO6Zp3MADl92ixHHOUxc v+SowUl5PiUWVmYOdb5ls4kD8D4FNSAW6MGoyFM9Vjpyua1efLNf/JktBFl1bP+sOXtQ nfFLle4tOdUeVx973yDqYkxuYeJZ7YIQ38W80BWy4fbCiImYqNtusbTSr4c90ff6hrSl rhuA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=78yCkR98MtM+p4wYvsxZI+i3GmUiyMdPBkkAbm+jo8c=; fh=upO+1EF+cLAPgnMShB6nR2OpRnXG17yc5Pp9Fb6wq0I=; b=z5rD1jDUXNotDq0RjuNG+NEjYkOcBD6KOovycCTLTfNmB2WLVv5LdNxGWoxCHbq8zy S84FHHJfZRZWEX2yvZhQMrlTIFq4Z0sjNRzyo499XaBLGtIF4t8lfay95s/gvQKbaERb WqNFktGXngX+B15RohAakRA1rStemHch/MhSi7j0N2s+E62oKvEkUzp5f8lHuDIOdDZ6 cX8OZ7JWx3U9Ckr8W5B5QJJDdCByda+pe9GzxQnWnJ87rWd00IFn9mSvQqO9XtU+4yGs GXecHD9XRjTzyJEuHREs/NV53fILNCgxkAR6pgMe+/1z/n59uyTZhTMrTyMfWmXD/9vM POjg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZBksYlYq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id c25-20020a50f619000000b00564053daf5bsi191777edn.299.2024.02.16.10.40.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:40:35 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-69177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=ZBksYlYq; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-69177-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-69177-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4714E1F25C59 for ; Fri, 16 Feb 2024 18:40:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9ACCC135A4B; Fri, 16 Feb 2024 18:40:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZBksYlYq" Received: from mail-lj1-f179.google.com (mail-lj1-f179.google.com [209.85.208.179]) (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 C66221353FF; Fri, 16 Feb 2024 18:40:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.179 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108804; cv=none; b=eDfd3o27nWXUOml32iDca168YMjEJ3snUy7HNlNm5+7EvoAksXNw76vX5R+KkwJy+R/tZC43Cf65RU7oR6TdLrUmU2R9glGngNGk0rMBI69QfyYckCzkygpaRIH1XpDzU86x8n7TVdgGGDeMGZexR1uPkZCvcrZUjbGp4XrHR0U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708108804; c=relaxed/simple; bh=KFXs/nTuMM+dWIefmFTAjCBQ7XDB+JXn9nNipT7JTdY=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ptdOKv957LqwlGRg5DRC+qHNMklKuaqU1F7W4XrCIzLnwnt6/4bWMm7Y5+29KF6UHuX3tb2omtTjxiT0KuEPGyIQ6A+D3g6nRpcLUYDjFwu0fW6Dji/xkWwxGMn9bftLTouLsR5wx+cWm/1Fz+Gm7O4BXASOowXhbh1a1uGyP18= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZBksYlYq; arc=none smtp.client-ip=209.85.208.179 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lj1-f179.google.com with SMTP id 38308e7fff4ca-2d21a68dd3bso10833201fa.1; Fri, 16 Feb 2024 10:40:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708108801; x=1708713601; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=78yCkR98MtM+p4wYvsxZI+i3GmUiyMdPBkkAbm+jo8c=; b=ZBksYlYqd0qX38Ohl63ZfywnHOxEVFKtzXVffHLhTQ4g+1iZyCfcwl6iYlzMUIbpi8 E5y0IhgRIAy2ashQkIFhP2UmCo4kJF3W7Q0mcfoVAFwhosL6CnW5QlN4zBFY3HZ41gpq wVHsMHV5l0ypYViGffoRgmHtjqWAV+zihMcS99scjjRfLxnOD+uls16qi6JrMh6zHa8f OdJE6uLW7pngQg3HZ6aK0AC7UpMz0Thj+7wr4/8aTmb7VqiCjkkpU+Iw6qOQXvHMvV28 0n/kFnK1ZEPa1elqjpau2YJY3XFHVXMKTjmMEApemQwxbjbSLWSRmq8ZsFjb950VP2dT n4zQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708108801; x=1708713601; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=78yCkR98MtM+p4wYvsxZI+i3GmUiyMdPBkkAbm+jo8c=; b=TzUt1ffT1eTEZ+KSWRJnZ397wZlBx5dq8OmWzqXdrBwPQzd1Ea1ho2NGlCw64Vdxa6 jEkjiiIxLmYpn4OujZ5Ny8edGZZyU4kt87d/Re8oxUd821SJ7QEKGomTOzTa159iVYuj Llo/v2eeu38aT80y792qJSvoo2MIl2cfYwtJpOA23jOdSvFddXxOsKs6/RKnADwW8eIc RdbsRWUCF5YE6v73qOQrCwDJeuO6EBiGNiRWfcL/0PoI793h2SpZnsfV9+IXRPrccZb8 glB5XNlQuB7FU9x5ZX5rtk/Hnzid/56bLiJMr8ni8lTzYifyMqqvufr2b7nOMN2wnblo VS3w== X-Forwarded-Encrypted: i=1; AJvYcCW3sQNTguPEXn2YuekWPJwFekgK07yiat8ehvr8sCiC7G1B0aZ/3C5DS4Otbpkb26VzroCd4oQERZVSYm8oTs1cceFs9/ut8fjOgXiDN/qwXaFV1yGN3RJYc9tOc7vkfX1h4NNb X-Gm-Message-State: AOJu0YzuOnYg9cQSz/TKOHfYJuHZ8+j4wrxzY8BTq63jm9Wakxza91ti CUqCbBVZFg2QkTKWSZZ2a7SSqybVkyXEzwxg/1YCkVBkXfR0bzpekqQJaBvK9/o= X-Received: by 2002:ac2:5197:0:b0:512:851d:82c5 with SMTP id u23-20020ac25197000000b00512851d82c5mr3905235lfi.0.1708108800548; Fri, 16 Feb 2024 10:40:00 -0800 (PST) Received: from mobilestation ([178.176.56.174]) by smtp.gmail.com with ESMTPSA id x8-20020ac24888000000b005129e5d7f11sm39651lfc.125.2024.02.16.10.39.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 16 Feb 2024 10:40:00 -0800 (PST) Date: Fri, 16 Feb 2024 21:39:57 +0300 From: Serge Semin To: Pavel Sakharov Cc: Simon Horman , Alexandre Torgue , Jose Abreu , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Maxime Coquelin , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org, Alexey Khoroshilov Subject: Re: [PATCH net v2] net: stmmac: Fix incorrect dereference in interrupt handlers Message-ID: <52l2oudptsknq7tkorvz6o3h2t2gzstkk34oorks3eul5k22br@kqm674m5cwyy> References: <20240206150704.GD1104779@kernel.org> <20240214092718.331891-1-p.sakharov@ispras.ru> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240214092718.331891-1-p.sakharov@ispras.ru> On Wed, Feb 14, 2024 at 12:27:17PM +0300, Pavel Sakharov wrote: > If 'dev' or 'data' is NULL, the 'priv' variable has an incorrect address > when dereferencing calling netdev_err(). > > Since we get as 'dev_id' or 'data' what was passed as the 'dev' argument > to request_irq() during interrupt initialization (that is, the net_device > and rx/tx queue pointers initialized at the time of the call) and since > there are usually no checks for the 'dev_id' argument in such handlers > in other drivers, remove these checks from the handlers in stmmac driver. > > Found by Linux Verification Center (linuxtesting.org) with SVACE. LGTM. Thanks! Reviewed-by: Serge Semin -Serge(y) > > Fixes: 8532f613bc78 ("net: stmmac: introduce MSI Interrupt routines for mac, safety, RX & TX") > Signed-off-by: Pavel Sakharov > --- > v2: Drop the second argument checks in the handlers as suggested by Serge Semin . > > .../net/ethernet/stmicro/stmmac/stmmac_main.c | 20 ------------------- > 1 file changed, 20 deletions(-) > > diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > index 75d029704503..e80d77bd9f1f 100644 > --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c > @@ -6059,11 +6059,6 @@ static irqreturn_t stmmac_mac_interrupt(int irq, void *dev_id) > struct net_device *dev = (struct net_device *)dev_id; > struct stmmac_priv *priv = netdev_priv(dev); > > - if (unlikely(!dev)) { > - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__); > - return IRQ_NONE; > - } > - > /* Check if adapter is up */ > if (test_bit(STMMAC_DOWN, &priv->state)) > return IRQ_HANDLED; > @@ -6079,11 +6074,6 @@ static irqreturn_t stmmac_safety_interrupt(int irq, void *dev_id) > struct net_device *dev = (struct net_device *)dev_id; > struct stmmac_priv *priv = netdev_priv(dev); > > - if (unlikely(!dev)) { > - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__); > - return IRQ_NONE; > - } > - > /* Check if adapter is up */ > if (test_bit(STMMAC_DOWN, &priv->state)) > return IRQ_HANDLED; > @@ -6105,11 +6095,6 @@ static irqreturn_t stmmac_msi_intr_tx(int irq, void *data) > dma_conf = container_of(tx_q, struct stmmac_dma_conf, tx_queue[chan]); > priv = container_of(dma_conf, struct stmmac_priv, dma_conf); > > - if (unlikely(!data)) { > - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__); > - return IRQ_NONE; > - } > - > /* Check if adapter is up */ > if (test_bit(STMMAC_DOWN, &priv->state)) > return IRQ_HANDLED; > @@ -6136,11 +6121,6 @@ static irqreturn_t stmmac_msi_intr_rx(int irq, void *data) > dma_conf = container_of(rx_q, struct stmmac_dma_conf, rx_queue[chan]); > priv = container_of(dma_conf, struct stmmac_priv, dma_conf); > > - if (unlikely(!data)) { > - netdev_err(priv->dev, "%s: invalid dev pointer\n", __func__); > - return IRQ_NONE; > - } > - > /* Check if adapter is up */ > if (test_bit(STMMAC_DOWN, &priv->state)) > return IRQ_HANDLED; > -- > 2.43.0 >