Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1790451lqe; Mon, 8 Apr 2024 23:27:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX5yYQFWW8AJ96dl9ZN8JdKSZX494wSXwXee8q4W1HiDVpz0UjieTO4loO3t26J85UOOYy/lk/kspcSutiMZg2sQNBhY9rogeX4S0PVTQ== X-Google-Smtp-Source: AGHT+IEHCuflmJJlyTWdpOvVaBrALHFegKC5ZFagF17wZnqeGIMiUSdnIWVhXTCJOeBkh1eB5R7i X-Received: by 2002:a05:6358:6817:b0:17b:f672:4abe with SMTP id b23-20020a056358681700b0017bf6724abemr10829493rwh.16.1712644032573; Mon, 08 Apr 2024 23:27:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712644032; cv=pass; d=google.com; s=arc-20160816; b=CpSDpdmpuZzJhKQAet4fKUUzyYJed7S49LN7Ei1kzPImmGVwgs5FE65b2UNC2Ep574 IO1eHBuu5gWWOm8+VLsqzybdNNEb+2R8TQLj/l5s+JOSFr//IR9c/PDVTwbQ85Qmz+ge Inl+RTf1Fw7Eg8SEO+aKHviTCNco7h0SzNOBiHZ5ywfNRaGWIAHGKrUdbjzBkmJXJvHm iDpL0R6S32pUzue5br9eICXeKrW1Xn910j4z3q9JunmNZYPAasr2WjGjg5GRvU2Od5Un 50qWLO38iWB4X/Q9tnMKiYnLQI/6ygZ9hI6LsukrtFF3h95NfrSR/2fN9tB16rpLeJlo /pew== 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=ZGaOLMAwWEbHzlVvJbIY7WaGUlj5DXjFn2iEaNlsiUw=; fh=CtMX7jXgCuRTCs+LJflQr3HA6ouEy7TXd7UymPzO2OM=; b=XNZ29UFpZ+lr5knDsfoygnrWquU3fOdm1He2h2GWthwVYo+aE4iUh05jWLEz60tv2x +LfaaxQOmZQ4RaS4YLLAjS5eLsgkBmZzwLBojXCpZSPtBHF1BWPCdrQlBHTGM47paFrB JW4DNcOJFYwMibVl7OvVfONC9OxycW1sBRfS6XbPua3o+yl95/zvgA0GYi4M9QSYwmaO YTu5321RiPjHemc982Vls4dsl9HCxlcixzUW1qfRm9jpmJ8WhpW0JCoWvX0STsMADfuD 3cNJ/zrGtndhb+PxO0wwg4ukWIC8ddgDyXY31LsTZSZ1iFG06/pfY97Zp2gM47Lu1/LT ItkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlednAEh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-136293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136293-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h7-20020a63c007000000b005d760c23e09si7918581pgg.146.2024.04.08.23.27.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 23:27:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AlednAEh; arc=pass (i=1 spf=pass spfdomain=linaro.org dkim=pass dkdomain=linaro.org dmarc=pass fromdomain=linaro.org); spf=pass (google.com: domain of linux-kernel+bounces-136293-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136293-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 604C5B23A8F for ; Tue, 9 Apr 2024 06:24:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8375A7317D; Tue, 9 Apr 2024 06:23:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AlednAEh" Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (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 509D76EB72 for ; Tue, 9 Apr 2024 06:23:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712643834; cv=none; b=Tzf4pe/hBfm9RMs6dTXF4ENdJHFUM1KU40X5dUCwNRlmOQQlw2QrSMNG3gj/+I+gNm3NlNOlzOy93qrYCSm0Hevhef9QDPhKZMXLi9lZB3WMChrgouGh9ikorBEArFc0lMLHFfqa/2Hc2cuSFR7AW6BfltOjaA8EHUgXNnTvggs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712643834; c=relaxed/simple; bh=4FCqcdUY4noIr3hyXGLjsXuMQ28NOckQh0S4mytZc+w=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=WDbKlUyza/LIJI0x62OTYBUO1gB8BtPqj6iEi1qgHQSOhUyPSCp7M520tse2ZZikcm8odP8edvOEhQOIQgm56zXQx+QFoQX1o3x2JB580fPjENito2yRyAN7hCUW2j//ycL5cuvsrF5EUQSMTQuf6r4vqTQOz7l04pIBiaFRCtU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org; spf=pass smtp.mailfrom=linaro.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b=AlednAEh; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linaro.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linaro.org Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-516d1c8dc79so5616823e87.1 for ; Mon, 08 Apr 2024 23:23:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712643830; x=1713248630; 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=ZGaOLMAwWEbHzlVvJbIY7WaGUlj5DXjFn2iEaNlsiUw=; b=AlednAEhe1YT/OUUncjleNOiANU+v9UAJUHmuERK2kA5YVb21ZP3h9ZdEfqgN6gX+u u58l1M/90pb90gHlnwV284hq3bJxLJaJZKcjUlRaaQk12Aj80rntU0v3yhr/hQ13IEW/ wsKzyn9XA5oa4MhlNaAEByv7GBt2XlG/xm1RcDYMxJcMTcQ1RTDbsKy+xC08q58AQGoP /7A0KMx8EvtXYn6RjvhHuKeIxcLrn84aYjUfFDGx/sdSQPpgJJf+wCm5X3Chda4/hCz0 CL2Zg98y2Bz+MNi9v/DjLAxg8my8XqY59LbdKHINNWWqDPmsG+euFern+oFDO4zioiUz IfbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712643830; x=1713248630; 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=ZGaOLMAwWEbHzlVvJbIY7WaGUlj5DXjFn2iEaNlsiUw=; b=vL1NKuM429iaxo699jQ0lR83Aw9tANVPyqsXAf5SqVbQNAVXIAxtLgFhFV23lJI02S XfuPpJiqKW1IlPmfCB9HuSFbK2NtUOEwbAQ1MVHvO7ouYOXL2mOEIvNrwp0QJGsk3Kdb IZT9TCWXL8y6LSRhlhhli7HRXnkQ2K2YLZghtssQUjGiSQsgfTwDpMGyjXPgHA5K6e8e fMGVohwxEeXhqlGJ2ba8nwd0rgfZx5FOCdrU65/EuUZDeTQgqDP2lg0yC1avcTuTsyQf 8U/BnIZNOFFT285x8+2KzKm+8uS09JZEZT42BpCjAp/VY3ETK5Hzx5NqPPNPPpD9RjqT 6mgA== X-Forwarded-Encrypted: i=1; AJvYcCXG87igFchHZ8QUr96r9J283IqG4MQY+ylSX2kE6CXwh02fygxKiAH7IBjCZh1HUejA9I2W1yzkMuN9bqCzH//I8SE2TgR1FGcpfAPY X-Gm-Message-State: AOJu0YzPjGDTDbfuUb4OcZur2FeIV7cl2jDVmUEGB7OyvjSsNGObekQk qDqRLJmmsjx2CDNh4W+FCEzRldXNwLP6g4A/Im3iOhvu1M7B+22GAMKw0vWzFUQ= X-Received: by 2002:ac2:59d0:0:b0:513:30fb:d64 with SMTP id x16-20020ac259d0000000b0051330fb0d64mr8012172lfn.44.1712643830122; Mon, 08 Apr 2024 23:23:50 -0700 (PDT) Received: from localhost ([102.222.70.76]) by smtp.gmail.com with ESMTPSA id b93-20020a509f66000000b0056e0376286bsm5021838edf.24.2024.04.08.23.23.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 23:23:49 -0700 (PDT) Date: Tue, 9 Apr 2024 09:23:45 +0300 From: Dan Carpenter To: Arnd Bergmann Cc: Greg Kroah-Hartman , Justin Stitt , Arnd Bergmann , linux-staging@lists.linux.dev, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/3] [v2] staging: rts5208: replace weird strncpy() with memcpy() Message-ID: References: <20240408194821.3183462-1-arnd@kernel.org> 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: <20240408194821.3183462-1-arnd@kernel.org> On Mon, Apr 08, 2024 at 09:48:09PM +0200, Arnd Bergmann wrote: > From: Arnd Bergmann > > When -Wstringop-truncation is enabled, gcc finds a function that > always does a short copy: > > In function 'inquiry', > inlined from 'rtsx_scsi_handler' at drivers/staging/rts5208/rtsx_scsi.c:3210:12: > drivers/staging/rts5208/rtsx_scsi.c:526:17: error: 'strncpy' output truncated copying between 1 and 28 bytes from a string of length 28 [-Werror=stringop-truncation] > 526 | strncpy(buf + 8, inquiry_string, sendbytes - 8); > | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ > > The code originally had a memcpy() that would overread the source string, > and commit 88a5b39b69ab ("staging/rts5208: Fix read overflow in memcpy") > fixed this but introduced the warning about truncation in the process. > > As Dan points out, the final space in the inquiry_string always gets > cut off, so remove it here for clarity, leaving exactly the 28 non-NUL > characters that can get copied into the output. In the 'pro_formatter_flag' > this is followed by another 20 bytes from the 'formatter_inquiry_str' > array, but there the output never contains a NUL-termination, and the > length is known, so memcpy() is the more logical choice. > > Cc: Dan Carpenter > Link: https://lore.kernel.org/lkml/695be581-548f-4e5e-a211-5f3b95568e77@moroto.mountain/ > Signed-off-by: Arnd Bergmann > --- > v2: remove unneeded space byte from input string for clarity, > rework changelog text Reviewed-by: Dan Carpenter regards, dan carpenter