Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1517793lqe; Mon, 8 Apr 2024 11:05:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVRxLEUE0f4kaiXdG46d62+qdEr4h7YNh698SGygq7TCa9gvgcu8R7Z6C/8F6fCAdUt1FbuQPpCE93p2RqgitKbZWc7RrW39OD5zOoUKw== X-Google-Smtp-Source: AGHT+IE1HOcaYYMYZx3O3PARtnep72VIjJv+tsbZsKQmWeu3YOikwGpYA46ZkFhZnOFTBlARxezc X-Received: by 2002:a05:6830:3493:b0:6ea:10ec:d06d with SMTP id c19-20020a056830349300b006ea10ecd06dmr6930807otu.6.1712599548372; Mon, 08 Apr 2024 11:05:48 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712599548; cv=pass; d=google.com; s=arc-20160816; b=HRIo6TRtW40VfM+VhzxP/g1XoA+/JHCikMJIDb10/V9Smg+N4X0B+0symP6/aJPp4t wlgMfsWZYDZuhioVa0VGPp84P0p2UsSjXJ1S/hR+wo4r/cc3NksD6p3KV74Wn859ZB9T fHTribZvRIoLz80BkFteQpienccFM6Lv7ZEByDyMo1K4Mv18eXfSGkRGDkOMC58Ss/gt yvXijUZjJXsSV8VLZdD37Njl6i72GPlxVRGugz+M7E85h4GeF4/6sxmItJvkwFaq9eTU ADJJ4VRcchpgOhjWZl3yKBq3skOq/GCKmvjHNeIgP20oSGtYUJYVDFg2oJoI3OzZvYrr WuLQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=subject:cc:to:from:date:references:in-reply-to:message-id :mime-version:list-unsubscribe:list-subscribe:list-id:precedence :user-agent:feedback-id:dkim-signature:dkim-signature; bh=PJwIR6tKpg7jOqh/bzOaK5yAmP9nnbueAasCvlzwCdQ=; fh=G+5ti8KrO/WblJ6YsOrl4RELh9+9UsSDIO3ZHb8Xd/g=; b=or5rQlN2CLLfJ3MCN/59z4rB2OY0BIFMoal8YQPDQxL1IWv1ycMh30fVeqLjqK96J2 JqAe1Dgt/nnGK0xHTXBU6puuJ0nbviNLm1VSz1+QqTkWEKiyX+RJje9IKuhefW6Jas+n b6m32Tsc3t8o2M5UDXPjxBYxn940vk8LZjmxPZdYebNbmcC0/WwfTnnPt83PJDo49JQq XC9PBO6z1QNuKBM3SVF54hJpm4P/FfAOHSH4VxU3UpO2oc0sm2PlTR2PnbT7enaOL7Yl shvDcnGBCFegLevsCnw5dqTfioLX3CM+cQlIRTl77/QVtNl7cP70zNOhj+49SKtELKbR hOQg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm2 header.b=Xuzsq5sO; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=a76WxLYW; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-135798-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id m6-20020a1fee06000000b004d13a64e12dsi1129842vkh.60.2024.04.08.11.05.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 11:05:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135798-linux.lists.archive=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=@arndb.de header.s=fm2 header.b=Xuzsq5sO; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=a76WxLYW; arc=pass (i=1 spf=pass spfdomain=arndb.de dkim=pass dkdomain=arndb.de dkim=pass dkdomain=messagingengine.com dmarc=pass fromdomain=arndb.de); spf=pass (google.com: domain of linux-kernel+bounces-135798-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135798-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=arndb.de 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 170691C24875 for ; Mon, 8 Apr 2024 18:05:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2F0661448C3; Mon, 8 Apr 2024 18:05:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b="Xuzsq5sO"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="a76WxLYW" Received: from wfhigh7-smtp.messagingengine.com (wfhigh7-smtp.messagingengine.com [64.147.123.158]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1810E433A9; Mon, 8 Apr 2024 18:05:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.158 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712599537; cv=none; b=ftfUvZ+x8IXRGAXCvn6qfImCYv/gsq41dkwmCcnSwE3rsnZ0bqWP/3L9Ryf8tZQnQ6NQxdDc01ZMyQ6XeMho3iM1laWCeiDkJgF2RTN+35ku82QsfsKV7wo65gd9xqlBC3KkB3xhtzMBzG8iES7n8ZXzWxChnKyx4RtAa33IMdQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712599537; c=relaxed/simple; bh=PLP2UVK/7a5fC42DAjpkpGkvVPaV+2lnuMzTDN603l8=; h=MIME-Version:Message-Id:In-Reply-To:References:Date:From:To:Cc: Subject:Content-Type; b=pQ8jiHRh/1FMXS0jk+F3L6ND1oeGhOWrRzHHllkGWyIefYOCK/MwKalZAFBy1FOIH70EcL0R6p0NaAPzCYR/aVQ2w5GzQ2H1dKkKy/y2vBDy1ZF3FCXtg8d3d7+30/ruuR7Am3dp2Bq/oPTXfy6LhnC4bOFzJ/ThmcFHAHyR1dU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de; spf=pass smtp.mailfrom=arndb.de; dkim=pass (2048-bit key) header.d=arndb.de header.i=@arndb.de header.b=Xuzsq5sO; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=a76WxLYW; arc=none smtp.client-ip=64.147.123.158 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arndb.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arndb.de Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailfhigh.west.internal (Postfix) with ESMTP id 8E4F918000FB; Mon, 8 Apr 2024 14:05:34 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute5.internal (MEProxy); Mon, 08 Apr 2024 14:05:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm2; t=1712599534; x=1712685934; bh=PJwIR6tKpg 7jOqh/bzOaK5yAmP9nnbueAasCvlzwCdQ=; b=Xuzsq5sOIPcE9Ql19RZOrsaRi4 /9YvSlpm84mODIJZ+NSxNT4N8Cr0GyB3vdYVcwcKGL4MV1GdHaBk5o7kLKtRuNZG xQxEBGacZPI2ixvzqT92TLJOFu60Zp71xoathwjfaTJC0f6YknYmn2NPXQv9E4Gd AwO1j2fziebPrH9KGwETiwlDO0ERPj4mRi5gAjiUhgdk+kO9U3HqVdUiEY1G9qjq So8syYlgtuA28tUs9zL3X10G8llvL1mwVi7yq/QD4wHvLl9yv2NStJOCO19n31x/ PMbdZo9gNhTv/jqhK8QXKbqdL+saOrPrxJXWTIOb1o1nY4yzReO2+uhjOE5g== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm2; t=1712599534; x=1712685934; bh=PJwIR6tKpg7jOqh/bzOaK5yAmP9n nbueAasCvlzwCdQ=; b=a76WxLYWJq80MbHVnbTM/cyBUYoWthFRsRk3zN0qwVka WnmY/s+DOwUUnHSUrFKo9cG8j/k5c+CrgQ8BDtkVac7fH2woxwffBT4muiXfsM9Q vtnZrt6da+4WqgLkcCPvL2jGNHyvk6bDnaYxAO5qoNMix3IJVAu/cRZS3zEinKoU joyetow+77DFZQKPnrCV7GGMrGjkqmn6yNLHk7Un8afjKkZkeRMLquZapdmHZnKc M85Hpbx04G/NOmdnDL30K7C8THbNLlusEkUVziS/vRNSw3A6DXq3Aj0A1Cx48czD azPyYZPpJqeHcb9104evNrvMJfObeTJu6e+Gu3+a7g== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrudegiedguddvtdcutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefofgggkfgjfhffhffvvefutgesthdtredtreertdenucfhrhhomhepfdet rhhnugcuuegvrhhgmhgrnhhnfdcuoegrrhhnugesrghrnhgusgdruggvqeenucggtffrrg htthgvrhhnpeffheeugeetiefhgeethfejgfdtuefggeejleehjeeutefhfeeggefhkedt keetffenucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpe grrhhnugesrghrnhgusgdruggv X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 522B2B6008D; Mon, 8 Apr 2024 14:05:33 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.11.0-alpha0-368-gc733b1d8df-fm-20240402.001-gc733b1d8 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <3cd7ef89-0a41-427c-880f-faa48a9b7d62@app.fastmail.com> In-Reply-To: <20240328101422.37e1c4f0@gandalf.local.home> References: <20240328140512.4148825-1-arnd@kernel.org> <20240328140512.4148825-9-arnd@kernel.org> <20240328101422.37e1c4f0@gandalf.local.home> Date: Mon, 08 Apr 2024 20:05:12 +0200 From: "Arnd Bergmann" To: "Steven Rostedt" , "Arnd Bergmann" Cc: linux-kernel@vger.kernel.org, "Jens Axboe" , "Masami Hiramatsu" , "Mathieu Desnoyers" , linux-block@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: Re: [PATCH 08/11] blktrace: convert strncpy() to strscpy_pad() Content-Type: text/plain On Thu, Mar 28, 2024, at 15:14, Steven Rostedt wrote: > On Thu, 28 Mar 2024 15:04:52 +0100 >> >> diff --git a/kernel/trace/blktrace.c b/kernel/trace/blktrace.c >> index d5d94510afd3..95a00160d465 100644 >> --- a/kernel/trace/blktrace.c >> +++ b/kernel/trace/blktrace.c >> @@ -524,8 +524,7 @@ static int do_blk_trace_setup(struct request_queue *q, char *name, dev_t dev, >> if (!buts->buf_size || !buts->buf_nr) >> return -EINVAL; >> >> - strncpy(buts->name, name, BLKTRACE_BDEV_SIZE); >> - buts->name[BLKTRACE_BDEV_SIZE - 1] = '\0'; >> + strscpy(buts->name, name, BLKTRACE_BDEV_SIZE); > > The commit message says "Using strscpy_pad()" but it doesn't do so in the > patch. > > Rule 12 of debugging: "When the comment and the code do not match, they are > probably both wrong" Thanks for double-checking this, I had a hard time deciding which one to use here and ended up with an obviously inconsistent version. I've changed it now to strscpy_pad() for v2, which is the slightly safer choice here. The non-padding version would still not leak kernel data but would write back user-provided data after the padding instead of always zeroing it. Arnd