From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B6C4E6748F for ; Fri, 1 Nov 2024 00:14:15 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 08EED6B009E; Thu, 31 Oct 2024 20:14:15 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 03CBD6B00A1; Thu, 31 Oct 2024 20:14:14 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id E1F1E6B00A2; Thu, 31 Oct 2024 20:14:14 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id C1DD56B009E for ; Thu, 31 Oct 2024 20:14:14 -0400 (EDT) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 3E9F2141B53 for ; Fri, 1 Nov 2024 00:14:14 +0000 (UTC) X-FDA: 82735603734.28.F4D7384 Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) by imf17.hostedemail.com (Postfix) with ESMTP id 2ECC44001F for ; Fri, 1 Nov 2024 00:13:51 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LlsVn4NO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of surenb@google.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1730419890; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=gDJhXEmGr1M/HN6h03M51446H+AHW6BogDU2GvRtVHY=; b=ACkjdiEAo+ESUfVkTgOwR5BcCGtr1Fu9F1N8gPfr5CbtOXg5a4bqB/8K3w2l/4Fz6tHpVI IdGFqOPlOV5uo+u0vr0phuLtAKMxAS3UwwipOKr2/4f1MK0JzFglYPp6yBQHSgxUWUMSzN XKfslHTQCKbjBkH50siuWdWk0lt6G+8= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=google.com header.s=20230601 header.b=LlsVn4NO; dmarc=pass (policy=reject) header.from=google.com; spf=pass (imf17.hostedemail.com: domain of surenb@google.com designates 209.85.160.171 as permitted sender) smtp.mailfrom=surenb@google.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1730419890; a=rsa-sha256; cv=none; b=44F5ANUPH5aE5dd2nGTwMc8ioF+DXeII8nSSXiD7Bm3XQxUGD00coqf0GVha0o2+hEfBiR EWD2XvNy+VGqoEa9Ni3AbFVk1/m2j21HSMe1o0W3I0Kpb2bLD7ZvlpUWcDqXZ557QMBxHW YIXQgDFgXMVQOCeRykO8Bt7TshdMjuE= Received: by mail-qt1-f171.google.com with SMTP id d75a77b69052e-460969c49f2so74421cf.0 for ; Thu, 31 Oct 2024 17:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1730420051; x=1731024851; darn=kvack.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=gDJhXEmGr1M/HN6h03M51446H+AHW6BogDU2GvRtVHY=; b=LlsVn4NO/4o0RkguXBC2tMQQ368NRlMAyyPgFAKUOXhopqLiUPxIZB6AGY1OdaS6f7 3/ACqv64pv9FAzmvOrRgWtp5DtZtc/LSuYyTvMSA4UmMFaZhuBk6on7q6ZnQtfsUH9Lg AtYOixry42MquKP8enxEWczGmzuTDOBecJddz5m3d0/4f95g+GaQrux+h9Zx8MuQOt3N o2NYvFL4NLGQzgnQPtHlhbPKDqjphNCW8ccIebQT1DfLTS+HMLstdnRUefaW30PYQvbW +R0Z8Nhz0uycug1j4U70Itn9vSC9JLNZOL7zMogpZCMWVcg+OMXiLVnfv/Q4MlLp4vcE mtAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730420051; x=1731024851; 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=gDJhXEmGr1M/HN6h03M51446H+AHW6BogDU2GvRtVHY=; b=w+5alqHjcib4H+Z/Qouk++CLWlCIUNFg/SR2duh7ajvHw/X7sVyI3j+M3lKVJZGjcF rDmLHsRPyY5fJHLaJj9GTnF/MpZzm6oo1rZVsVufIHxupmhbPESK+b7nvSQsWBfIY7RJ ZOb3ksKiBZgplWU7J/2kO4DTNgW0m4jqu0MICEtHFlGkAMRzlHIMQAMWJnSa2lVIN+x7 2DHoZRBBED+TJOWptd4jXr+SZCkmfWSdv69Turpf384aax4MjrqHt8XNgTBzGlzKLAUo 0NJxLazb9BKVXun9uBBDEV6puPGx8Kb+r7JKXStgKc0pmbxUcaeX2kslmn+AzQMV4YXP 7IVQ== X-Forwarded-Encrypted: i=1; AJvYcCW1uIL84RQlKqunKMZgbbmKr5JNfBF0BuZakFLeTHhVts0x6AyopuG7z14dulca+REUotXPcrwEFw==@kvack.org X-Gm-Message-State: AOJu0YyPN5TA5GV6Zw6Bcqvs1DVP28RdTM5hGDH40iASKIqjNnfjGA0q txlyBilMZjXTfSZM4wUpRGr5T5O/hXXAbzg8eQ1anNmHoiXiiiG6ZhvlimEDcSTWUCV4rdCerX1 E2g29YwybmOdEd+B03Kw5pADt2uWfTBJtIRcW X-Gm-Gg: ASbGncsce9PuRNgEXmdTxM0WNaICGtsHxbHvR83jRkeT8F3GhZP9vArPOiMGKkx2Ihc UPshK8ZZw8xSHiRzG7RBuWcNsqyz4daw= X-Google-Smtp-Source: AGHT+IGn/0z3SSIWnwroupLQbYlOwmQT+qm7h63zxWeTpVdmBEtPlDixbl8Mxme95HJO4jGzsyI8c3SZosyYXn+zvm0= X-Received: by 2002:ac8:5748:0:b0:460:46a8:9e67 with SMTP id d75a77b69052e-462aba3818cmr5571951cf.10.1730420049098; Thu, 31 Oct 2024 17:14:09 -0700 (PDT) MIME-Version: 1.0 References: <20241101000017.3856204-1-surenb@google.com> In-Reply-To: <20241101000017.3856204-1-surenb@google.com> From: Suren Baghdasaryan Date: Thu, 31 Oct 2024 17:13:58 -0700 Message-ID: Subject: Re: [PATCH 1/1] alloc_tag: fix empty codetag module section handling To: akpm@linux-foundation.org Cc: kent.overstreet@linux.dev, dan.carpenter@linaro.org, rppt@kernel.org, mcgrof@kernel.org, petr.pavlu@suse.com, samitolvanen@google.com, da.gomez@samsung.com, yuzhao@google.com, souravpanda@google.com, pasha.tatashin@soleen.com, linux-mm@kvack.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 2ECC44001F X-Stat-Signature: 613ssfizdc83y3yd6kwo9bmb3thdzmhe X-Rspam-User: X-HE-Tag: 1730420031-553473 X-HE-Meta: U2FsdGVkX18Mm02o9FqzAnBuASP6n2WliEWLcg61Ngnrz9a4g+GqbcxLKzgZsoN2dpzHsPwp0vC6JjEFeIliOSLrU8rb1BeCvGfKSi53QFzwSbCDc51KBUHfBWMMBGyUQVANJC2kmPaPtagBxNBsJYsXFa20VikjEM6kRVyIHXqylUYaN8hKruENRUTFZOF/bE3cU80TsYD5P64Le3INQ9jrQs0M319FdEBbnMhEErR15uXuTyHXoK/OuLfMC7BeivmU6ztuljFZ1KswoOuVu415HNletnqQnAaBnYXh62nqoboabD5ech2Fx6H2M0VX1cXEMHjXAsnNozuW4fnpGHcE1cJz17VUmVWRF6w7UVRzvURM/4UUIEKF1vKVyOYjrUu/0JHhK/WwMa/WtxSCRpUl4//DzY/6l7ndrH39Ftwf0Wd3+nmB/77IMSWBX590Vly9VxAb2thvqDm8reIFSQCck5tRoRunmLKXQyxzxKwx6R18FXtjwAGQnUknNRygQF7k/pSuPZnMI8gHmDBFLhPun/aRdcxfYz1nKquzzSvLPZ0bzKVDChOAE+StY0KKtBfg2idGkynrlZkW1BTbjZqGpQ8Rucra0gwCqixVFgWeCTwNFnNshITnyx6J6ouoCPzUfJSP8Ro53xrNsb1j4/3braRilHsXuicI42bY8VFagXd37zAe2upULvBUezc8+AK40VDRNoDJJVCMiiVS3B7WbvS4r8IbFLThkVk3jyc8lW6Xcn7fG7T/f/TNm5zaGNIuYOzVcCTn16HaQQJ2XtJcnYzjcxYm+KCvr12g9kw264u82142O5pi0gP7tvuSYCxrN5YHibPwW/90CP4aqt4NUyP+qyDIFcKaW9IgmQV60QHh+qtzQ3gxH1SOgKYrWRU+9egG9sqNfbbxE+YtNEzBqKPq5RM/KOXtwdMs9qNjlP5z2GSASf8jKLKkh9H16NrHag6uJstoe2IoNE6 U4Tsez3E uKbejkldM3ulihgP5wvB4Q9xXodP/nF4Rnal0AxPvm55zAijdv11Ju8D9ex/PLHxXCAEnLp2qjHyYP33q6S9I1IxG4fJACWFNCUxcossd/hqPg/wUQ5iDP4IwEdOR2c+/56vq/KZPgVjdJGAZu6r+a39cIWYZTf1pSYb9eiPaH6me2mZ9rJt8V3whNjbXKIK1ec3b62MRL6BopddwAg4LOuk67bAx8y31clpRl9QE8j08SBF55HkV70jvZkmeWKbwJI068Xe9himgq407HH+skihdFZhw4+N51cS0FncXIiuQH5Zdf0Da4bsVNksgHFrup6lN5FxqWKG4K/Al075tq7WmZRAMSSpKTHdw X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: On Thu, Oct 31, 2024 at 5:00=E2=80=AFPM Suren Baghdasaryan wrote: > > When a module does not have any allocations, it's allocation tag section > is empty and codetag_alloc_module_section() returns NULL. However this > condition should never happen because codetag_needs_module_section() will > detect an empty section and avoid calling codetag_alloc_module_section(). > Change codetag_alloc_module_section() to never return NULL, which should > prevent static checker warnings. Add a WARN_ON() and a proper error > reporting in case codetag_alloc_module_section() returns NULL, to prevent > future codetag type implementations from returning NULL from their > cttype->desc.alloc_section_mem() operation. > > Fixes: 61c9e58f3a10 ("alloc_tag: load module tags into separate contiguou= s memory") > Reported-by: Dan Carpenter > Closes: https://lore.kernel.org/all/50f12fa1-17c1-4940-a6bf-beaf61f6b17a@= stanley.mountain/ > Signed-off-by: Suren Baghdasaryan Andrew, I was going to respin v5 of my patchset and include all these small fixes in it but it's a bit tricky because I would have to revert another unrelated patch [1] from mm-unstable which refactors relevant code. So far the fixes are rather small, so I think you should not have much trouble folding them into the original patchset when the time comes, but if that becomes a problem I can prepare a new version. [1] d0d77a256a75 ("mm/codetag: uninline and move pgalloc_tag_copy and pgalloc_tag_split") > --- > kernel/module/main.c | 4 ++++ > lib/alloc_tag.c | 2 +- > lib/codetag.c | 2 +- > 3 files changed, 6 insertions(+), 2 deletions(-) > > diff --git a/kernel/module/main.c b/kernel/module/main.c > index 129c98e6380d..00c16f5c5568 100644 > --- a/kernel/module/main.c > +++ b/kernel/module/main.c > @@ -2316,6 +2316,10 @@ static int move_module(struct module *mod, struct = load_info *info) > if (codetag_needs_module_section(mod, sname, shdr->sh_siz= e)) { > dest =3D codetag_alloc_module_section(mod, sname,= shdr->sh_size, > arch_mod_section_prepend(mod, i),= shdr->sh_addralign); > + if (WARN_ON(!dest)) { > + ret =3D -EINVAL; > + goto out_err; > + } > if (IS_ERR(dest)) { > ret =3D PTR_ERR(dest); > goto out_err; > diff --git a/lib/alloc_tag.c b/lib/alloc_tag.c > index 1c74942e6dfd..00ab18ea452a 100644 > --- a/lib/alloc_tag.c > +++ b/lib/alloc_tag.c > @@ -437,7 +437,7 @@ static void *reserve_module_tags(struct module *mod, = unsigned long size, > > /* If no tags return NULL */ > if (size < sizeof(struct alloc_tag)) > - return NULL; > + return ERR_PTR(-EINVAL); > > /* > * align is always power of 2, so we can use IS_ALIGNED and ALIGN= . > diff --git a/lib/codetag.c b/lib/codetag.c > index 4949511b4933..42aadd6c1454 100644 > --- a/lib/codetag.c > +++ b/lib/codetag.c > @@ -244,7 +244,7 @@ void *codetag_alloc_module_section(struct module *mod= , const char *name, > { > const char *type_name =3D name + strlen(CODETAG_SECTION_PREFIX); > struct codetag_type *cttype; > - void *ret =3D NULL; > + void *ret =3D ERR_PTR(-EINVAL); > > mutex_lock(&codetag_lock); > list_for_each_entry(cttype, &codetag_types, link) { > > base-commit: 758db9ca0107bc6c00f0ed4808974d66c8dc2fea > -- > 2.47.0.163.g1226f6d8fa-goog >