Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp582914rdb; Tue, 5 Dec 2023 13:42:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IH5npxGyqtY5F4ioJpnQQdCZM+eAGtKc4Wnelc53SIs29m/ejafUEuI8oy7CR4TrqFzgzIX X-Received: by 2002:a17:90a:17af:b0:286:6cc1:3f14 with SMTP id q44-20020a17090a17af00b002866cc13f14mr1826530pja.75.1701812549565; Tue, 05 Dec 2023 13:42:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701812549; cv=none; d=google.com; s=arc-20160816; b=Kwo9WgQYzvFNagC5dZtxeUGh5lucE2DbO4FPTSs04VJ0179+eY1vYu4aOkNdpWl60J CgVToxDDIn6Bdz1Kju/Zq70OZqqezq8CJDC/bBOeLi7ENCxoaPIyNZ5B7PQi4QVY6go9 DIBcEUbSWzmuRgVb/q7rlVWUOY5d8+Uz1rTzzRddiYYVcSHBjtbnjzzMDoAi7XnlFlWY SBZosEOesJYnHbeX/HMZMClM7MRlw/V10kD7q3A+OEK+w4M38lZ135zaTGTbAKICUxSd 4P5vj4lKbExO17U3ZpKxNHfP1O+T81ByK3qkduGes8l9DoGEsKcfsqcgcRnuJwgyLPUw i04A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Q6YS5yNlvl+FKFyGS3DIWxbNX8VWKvkEW8slTswnooc=; fh=yUlPTkiwVM3yAPo8qvZIU52M1/9NxLWotWh3jjexnhk=; b=uB1S0eXXsi3+NPylTCxAtUR+qncVqEpb7DoaHOcKRDBIC4pcvZVA7gpcH6iQjVVcWg FfikNeLyy8knMzfNxrj4n0in5Y9qFrWFVnUpcsgaZ6i3sIXrpKxT1PX0OAeS+U1aHDVx VeRCqTfr7peJfG1erjLbiB4w3InPFcZ3GLKpNMT6l58pzkTze54MqNRFw35A0LxNBJe4 MDESB2hYbseYGb5YXX8cR1pTJOvZ5qLh+ZNEk/TQCXlNrpsgGe1BTkGr/vgJaYprCYK4 nlzgQPoe/vGgWwQUENN2F8N6KTK/bf29OfaQDXdXrg8Q8ejytFm4/1PBgVBvtphg5xOP d3ZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=APSnabA4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from pete.vger.email (pete.vger.email. [2620:137:e000::3:6]) by mx.google.com with ESMTPS id v5-20020a17090a898500b0028558f4e661si1674344pjn.145.2023.12.05.13.42.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Dec 2023 13:42:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) client-ip=2620:137:e000::3:6; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=APSnabA4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:6 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by pete.vger.email (Postfix) with ESMTP id D2176818D523; Tue, 5 Dec 2023 13:42:26 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346259AbjLEVmJ (ORCPT + 99 others); Tue, 5 Dec 2023 16:42:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346087AbjLEVmI (ORCPT ); Tue, 5 Dec 2023 16:42:08 -0500 Received: from mail-qk1-x72a.google.com (mail-qk1-x72a.google.com [IPv6:2607:f8b0:4864:20::72a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CBD71AA for ; Tue, 5 Dec 2023 13:42:13 -0800 (PST) Received: by mail-qk1-x72a.google.com with SMTP id af79cd13be357-77dd07e7d39so419503885a.0 for ; Tue, 05 Dec 2023 13:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1701812531; x=1702417331; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=Q6YS5yNlvl+FKFyGS3DIWxbNX8VWKvkEW8slTswnooc=; b=APSnabA4fbMPiUy+Z1Ba2nYOftClJzzqtuBcFXY1QJ2+KJFcg7NpyWXfOI3ZaZCsFh a+QxWfioKpgObJ95pJFLvzD7h5JLW3v2zulY+bLquyxSK879g5tqrY6qYdl7NKDjTxmC D8uikSoo1bW5mVwA9jgDJFX+IN/dajC7zlHoM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701812531; x=1702417331; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Q6YS5yNlvl+FKFyGS3DIWxbNX8VWKvkEW8slTswnooc=; b=qTRqYpv7G4kkLW3M8lXZh9UhdReLsuUE1GpIZz9GpBQExucTbXbk1kRJ53DMrU8cC9 88hdDPM5XYTHvnG+kxLx4VmwFrmAZVq84DM2lpOikTtPgt1o9qi82QdqOsWit60hqLoi jIyLybMev2CDkL8rRW6l82QjCaOXMva5i4pUnFg1M/pxLl0sL6rM/EFcilIPdWx/C4dG b0/hm5Iwz6RND4A4z6/hBzSRZIp8g0cGzImWvuTy4ZP5uLKFyBn4aF74alehzv8MfwBU Ky3iuMXeZ2paz/UyB2CPPc/Zy0yf86NOBLXpOn9S+nFuh3KEsQ8zyB3Y8Fx6WnBllAHo vc7Q== X-Gm-Message-State: AOJu0YzWqqxJz9iaevSwGYzbp6MBMnqO9AslVEDM9bVrJxUZR7TEsiLG nW427mJALyKIzNjKqo6CeCpBSFFT88HxWxW4ylIYMG+M X-Received: by 2002:a05:620a:218b:b0:77e:fba3:9d38 with SMTP id g11-20020a05620a218b00b0077efba39d38mr2039144qka.156.1701812531314; Tue, 05 Dec 2023 13:42:11 -0800 (PST) Received: from mail-qt1-f175.google.com (mail-qt1-f175.google.com. [209.85.160.175]) by smtp.gmail.com with ESMTPSA id b12-20020a05620a0ccc00b0077dd098d0b6sm5423691qkj.109.2023.12.05.13.42.10 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 05 Dec 2023 13:42:10 -0800 (PST) Received: by mail-qt1-f175.google.com with SMTP id d75a77b69052e-4255cc2bcdaso29991cf.1 for ; Tue, 05 Dec 2023 13:42:10 -0800 (PST) X-Received: by 2002:a05:622a:4ce:b0:425:4823:f9a3 with SMTP id q14-20020a05622a04ce00b004254823f9a3mr60587qtx.2.1701812530294; Tue, 05 Dec 2023 13:42:10 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Doug Anderson Date: Tue, 5 Dec 2023 13:41:57 -0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] trace: kdb: Replace simple_strtoul with kstrtoul in kdb_ftdump To: Yuran Pereira Cc: kgdb-bugreport@lists.sourceforge.net, linux-trace-kernel@vger.kernel.org, jason.wessel@windriver.com, daniel.thompson@linaro.org, rostedt@goodmis.org, mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-kernel-mentees@lists.linuxfoundation.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (pete.vger.email [0.0.0.0]); Tue, 05 Dec 2023 13:42:27 -0800 (PST) Hi, On Sun, Nov 19, 2023 at 4:10=E2=80=AFPM Yuran Pereira wrote: > > The function simple_strtoul performs no error checking in scenarios > where the input value overflows the intended output variable. > This results in this function successfully returning, even when the > output does not match the input string (aka the function returns > successfully even when the result is wrong). > > Or as it was mentioned [1], "...simple_strtol(), simple_strtoll(), > simple_strtoul(), and simple_strtoull() functions explicitly ignore > overflows, which may lead to unexpected results in callers." > Hence, the use of those functions is discouraged. > > This patch replaces all uses of the simple_strtoul with the safer > alternatives kstrtoint and kstrtol. > > [1] https://www.kernel.org/doc/html/latest/process/deprecated.html#simple= -strtol-simple-strtoll-simple-strtoul-simple-strtoull > > Signed-off-by: Yuran Pereira > --- > kernel/trace/trace_kdb.c | 14 ++++++-------- > 1 file changed, 6 insertions(+), 8 deletions(-) > > diff --git a/kernel/trace/trace_kdb.c b/kernel/trace/trace_kdb.c > index 59857a1ee44c..3891f885e4a6 100644 > --- a/kernel/trace/trace_kdb.c > +++ b/kernel/trace/trace_kdb.c > @@ -96,23 +96,21 @@ static int kdb_ftdump(int argc, const char **argv) > { > int skip_entries =3D 0; > long cpu_file; > - char *cp; > + int err; > int cnt; > int cpu; > > if (argc > 2) > return KDB_ARGCOUNT; > > - if (argc) { > - skip_entries =3D simple_strtol(argv[1], &cp, 0); > - if (*cp) > + if (argc) > + if (kstrtoint(argv[1], 0, &skip_entries)) > skip_entries =3D 0; > - } Similar nit about braces as in patch #1. tl;dr is change the above to: if (argc && kstrtoint(argv[1], 0, &skip_entries)) skip_entries =3D 0; > > if (argc =3D=3D 2) { > - cpu_file =3D simple_strtol(argv[2], &cp, 0); > - if (*cp || cpu_file >=3D NR_CPUS || cpu_file < 0 || > - !cpu_online(cpu_file)) > + err =3D kstrtol(argv[2], 0, &cpu_file); > + if (err || cpu_file >=3D NR_CPUS || cpu_file < 0 || > + !cpu_online(cpu_file)) nit: why did you change the indentation for "!cpu_online(cpu_file))"? It seemed better before. With nits fixed: Reviewed-by: Douglas Anderson