Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp658383rdb; Tue, 16 Jan 2024 11:36:56 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyAFBFFYst115RUvV7vOKJB1ps1kstHld8Khei95m2syFSopCfmfiv3CkvDuI3h+ro+V7c X-Received: by 2002:a05:6a00:1804:b0:6d9:dfec:1509 with SMTP id y4-20020a056a00180400b006d9dfec1509mr10148888pfa.31.1705433816080; Tue, 16 Jan 2024 11:36:56 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705433816; cv=pass; d=google.com; s=arc-20160816; b=YqgTCNG1/itUcltWvbj/73DjGo6+B8ahXoL6LNZLXCpYQf0BajPcvbhTPAt5mQCq06 B1NZRaYEfU5EJD1vlIA8BLrrHYH2gh067DHmNIqj6tvIsodawnGUllfeVkoJSnlCE/G5 CDR5fcWzw5KvXKYOD885v11f8eGTyInnwpRcHw4p0jGAiH+Li/7pXs0vsUU63u15eu2M dwdDPVGKsqDcYkUD6CH8Gwecd7kwa+hgAg3Q//6qwxp8KPoSSZzftOeGZlISNh+3GKj2 PnosBCAEbB5wyBS6RWfNeFzIAM/BHl976FbCeIe2d8A1QP21O5GVQX8PXuchXz+gEk82 nWSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent: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=tNYuziFWfl9MkUwCZOX6uEvosc04pHrqJNu/2pkS60A=; fh=v6HqA5M9Apbcwt0Tk53VcglJAYrxW440hM/b+w+SF8U=; b=DsCG+NaAHZIY/7oMyZMFHiKhZC6XghCgcmGHxVA48TmeHBUWd305jLs4j1Dtloz4gI pBIH+9x8wtrkScORfBaAwxzxqL05L75+QRBNH5c1Lun0tzPEkh/sqp8EbeQSfLieIkc3 6UGiAPYVcnUiWQiNzR9SQJZK7IjZM6YIK2CBzpA0O5MKNgGZPOKXl7IsldUmgA/urv1W RNLJBz/hW/SOXbzA9Ngc+k/RQnOTjZ3+UJ/cPtLbH8b8E42+8aTwptX7yci3PPqvn0Aa Saqhp9Qo/iJ9YRh/F91HuBNtFI7OlC5DOyClUmfw6ANZyVvuh+nwNs+l7TXWX+C75k2w l96Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=TKHCKZLZ; arc=pass (i=1 dkim=pass dkdomain=chrisdown.name); spf=pass (google.com: domain of linux-kernel+bounces-27761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=chrisdown.name Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j190-20020a6380c7000000b005ce1372eb68si11292349pgd.808.2024.01.16.11.36.55 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 11:36:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-27761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chrisdown.name header.s=google header.b=TKHCKZLZ; arc=pass (i=1 dkim=pass dkdomain=chrisdown.name); spf=pass (google.com: domain of linux-kernel+bounces-27761-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-27761-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=chrisdown.name 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 7E06228644F for ; Tue, 16 Jan 2024 19:36:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 37C4E1D540; Tue, 16 Jan 2024 19:36:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b="TKHCKZLZ" Received: from mail-lj1-f171.google.com (mail-lj1-f171.google.com [209.85.208.171]) (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 342B21BF39 for ; Tue, 16 Jan 2024 19:36:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chrisdown.name Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.171 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705433807; cv=none; b=VjBYzW1kNvVRRRn5LvgcuiHR9+yxAwjQPzkdlO5wKPe7oyZ00dZPLK5dEkhFEvDkuv75Zp/FHLcSmfxqz8QrmU8DC4mJMPyA8Pq33HDOnwSU/oy1id1F5qNPC+sBeky4PGOPcVuM+R+6YC41NT/joaT4la9sTjBVA07/H6Q0ViI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705433807; c=relaxed/simple; bh=YH9I4mIwagxCplANYVB6qh/qLIS7W5riVXR8JjeVHCk=; h=Received:DKIM-Signature:X-Google-DKIM-Signature: X-Gm-Message-State:X-Google-Smtp-Source:X-Received:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:User-Agent; b=YnaW9d2gtJQl9uAkUEnPaIBkh5Qvgh7NGuVwDSB+SP5rrXY1Ccx30nAVVvrGkcEKOPJIhbJ8X7vT853lD2G/YQqhv78xZmn+xPjFplMT6zvgEbXiNDCXjwWeLt8Ja/fKOMyolsJBFbjBf9d8s0qMH1YTySMZnPSW6iwOnKKyAQU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chrisdown.name header.i=@chrisdown.name header.b=TKHCKZLZ; arc=none smtp.client-ip=209.85.208.171 Received: by mail-lj1-f171.google.com with SMTP id 38308e7fff4ca-2cd1232a2c7so127190971fa.0 for ; Tue, 16 Jan 2024 11:36:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chrisdown.name; s=google; t=1705433803; x=1706038603; darn=vger.kernel.org; h=user-agent: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=tNYuziFWfl9MkUwCZOX6uEvosc04pHrqJNu/2pkS60A=; b=TKHCKZLZ2dE1VlQKL5KFR8xMYBddWn0fe5S2R5qtyA4yTfnMbauww2Q/puqo0e8V1I tJvWedNmAORceFInJQc6TYgvDj38fZNELjUrR6aEO7rcRe2JprNzdlN/LID9mhGkgj76 pmAhm57mA4KqRzQ47BmUrXDtueCCE6LrQ/PIk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1705433803; x=1706038603; h=user-agent: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=tNYuziFWfl9MkUwCZOX6uEvosc04pHrqJNu/2pkS60A=; b=qKUmPBbN3BbBg8UAPlk7PP6WqhPQ8Sef4y+LHhQOF54m0Z25yk+4YN+ASTcCEvQEEX dAImORUufch/D5DrhegPKe8FDsYEsW5r7aq/L9r4GU+TslYKAiURh8o4AjMu3Anq6p5F tZ4EqIrgssbZXRS3u5w/nP9NA5ofXF9/XpYyH/5erduHiWsslDZnIiXTagZCf+AmtrTh DLnWCmjoj9TBez83AoT8+3kGgaEZaqvKrgXtmFQp4bva1Pmf22lL+sweClZb7wmFnH/C nT/bLb4j8jaCrl6c2kikyP7zKZq9bx6oXRqF8hW2lwv06YbNA6PUj7AOcn9388LokoKJ NDWQ== X-Gm-Message-State: AOJu0YwiC3rBhkRfLsSF24etsThaaKMqR70Qa2w/NO26aWyJcN4BFxh+ XV/XD+FmoLPOApmSqAvHjak7KPNOT5yY1A== X-Received: by 2002:a2e:9b97:0:b0:2cc:9435:a5f8 with SMTP id z23-20020a2e9b97000000b002cc9435a5f8mr3606713lji.6.1705433803162; Tue, 16 Jan 2024 11:36:43 -0800 (PST) Received: from localhost ([2a01:4b00:8432:8600:5ee4:2aff:fe50:f48d]) by smtp.gmail.com with ESMTPSA id e11-20020a2e930b000000b002cd9e966ed1sm1400877ljh.127.2024.01.16.11.36.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jan 2024 11:36:42 -0800 (PST) Date: Tue, 16 Jan 2024 19:36:41 +0000 From: Chris Down To: Petr Mladek Cc: "James E . J . Bottomley" , "Martin K . Petersen" , linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, oe-kbuild-all@lists.linux.dev, kernel test robot Subject: Re: [PATCH] scsi: core: Safe warning about bad dev info string Message-ID: References: <20240111162419.12406-1-pmladek@suse.com> 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; format=flowed Content-Disposition: inline In-Reply-To: <20240111162419.12406-1-pmladek@suse.com> User-Agent: Mutt/2.2.12 (2023-09-09) Petr Mladek writes: >Both "model" and "strflags" are passed to "%s" even when one or both >are NULL. > >It is safe because vsprintf() would detect the NULL pointer and print >"(null)". But it is a kernel-specific feature and compiler warns >about it: > > > In file included from include/linux/kernel.h:19, > from arch/x86/include/asm/percpu.h:27, > from arch/x86/include/asm/current.h:6, > from include/linux/sched.h:12, > from include/linux/blkdev.h:5, > from drivers/scsi/scsi_devinfo.c:3: > drivers/scsi/scsi_devinfo.c: In function 'scsi_dev_info_list_add_str': >>> include/linux/printk.h:434:44: warning: '%s' directive argument is null [-Wformat-overflow=] > 434 | #define printk(fmt, ...) printk_index_wrap(_printk, fmt, ##__VA_ARGS__) > | ^ > include/linux/printk.h:430:3: note: in definition of macro 'printk_index_wrap' > 430 | _p_func(_fmt, ##__VA_ARGS__); \ > | ^~~~~~~ > drivers/scsi/scsi_devinfo.c:551:4: note: in expansion of macro 'printk' > 551 | printk(KERN_ERR "%s: bad dev info string '%s' '%s'" > | ^~~~~~ > drivers/scsi/scsi_devinfo.c:552:14: note: format string is defined here > 552 | " '%s'\n", __func__, vendor, model, > | ^~ > > >Do not rely on the kernel specific behavior and print the message a safe way. Acked-by: Chris Down While I agree with the other thread that in reality this is ok, it's worth reducing the addition to LKP noise for now and worrying about that later. Thanks! > >Reported-by: kernel test robot >Closes: https://lore.kernel.org/oe-kbuild-all/202401112002.AOjwMNM0-lkp@intel.com/ >Signed-off-by: Petr Mladek >--- >Note: The patch is only compile tested. > > drivers/scsi/scsi_devinfo.c | 6 +++--- > 1 file changed, 3 insertions(+), 3 deletions(-) > >diff --git a/drivers/scsi/scsi_devinfo.c b/drivers/scsi/scsi_devinfo.c >index 3fcaf10a9dfe..ba7237e83863 100644 >--- a/drivers/scsi/scsi_devinfo.c >+++ b/drivers/scsi/scsi_devinfo.c >@@ -551,9 +551,9 @@ static int scsi_dev_info_list_add_str(char *dev_list) > if (model) > strflags = strsep(&next, next_check); > if (!model || !strflags) { >- printk(KERN_ERR "%s: bad dev info string '%s' '%s'" >- " '%s'\n", __func__, vendor, model, >- strflags); >+ pr_err("%s: bad dev info string '%s' '%s' '%s'\n", >+ __func__, vendor, model ? model : "", >+ strflags ? strflags : ""); > res = -EINVAL; > } else > res = scsi_dev_info_list_add(0 /* compatible */, vendor, >-- >2.43.0 >