Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp1972772lqa; Tue, 30 Apr 2024 05:09:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWcZVUvXonyzD9gt70I4RU4BKnUtOBT8/aLLBDnDQRpPgMqX7BYgBlqbQOohwgk02j7IO2UpC9IsOomQnE1pQOpwMhVyWF22nOJSxwiQA== X-Google-Smtp-Source: AGHT+IFKTUsiBwq147RDJAGGXLdtP230qWc3759FD2MAGARCzAiQPt1nzUJwMPNTjKApl92Hf5SA X-Received: by 2002:a05:6a00:1788:b0:6ed:1c7:8c6b with SMTP id s8-20020a056a00178800b006ed01c78c6bmr16679131pfg.1.1714478964096; Tue, 30 Apr 2024 05:09:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714478964; cv=pass; d=google.com; s=arc-20160816; b=jjOmQSzFd/YB3B7tYR0OKcVSANF1wPkUEVw+dWnBbmJFS7UjpGRHzVv5jXewlBPkSn 3bAx/cvSxcsLKx5CIovotmIQZti4c/37RskLp+OLbZUVecY7kor5xwY6NWfOJrNI8ENr +IFhOlB7zwzIBNcD1SQUz9aWPM+sYgnxIfNscC2cSvzT9trmWtvFDY758Vu8iVPyx/AB yDZaEAB8/VrFH9BYEtyf6RS8KJHVck+1PbfauK6k8UIO299s/xJihnrlm7wdiS1LLGjL vralUQPlrvzt5OayDupBpkgtS6YPn06WIHUcyEF/P51uB6Kkh1bj5l1TX17DMha0HRA+ uPcA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:autocrypt:from:references:cc :to:content-language:subject:user-agent:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:date:message-id :dkim-signature:dkim-signature:dkim-signature:dkim-signature; bh=ulxbG0KkC2gvBCetlLzOptoa891y9Q3oQRZRhcD0UrE=; fh=ZZ+OLDGrlZGg9vd08AKaQKyvPvE/aJczybfCSHg3QxI=; b=itkc/DPLUsG+RexTzsHS6fD55ACPACPPSGhlhQO/hg53Dj/sMrRml8p6vPk9km8wIj 3qUSDanhdmzEGKkVaAH2wAyC+zA3mMToJ+rtpTzhIVUpedRqsSKeMKVAwCUUlqPMpv2Z PCuBX4rNs1sQd+G21v1q334K08da+iwALc8V1PpWeO1mxNTFWWvoxdQb8MsFaS6gD3mp 7YYteOYq3wiecY9QDVCki3CtifALStOHvQaM09qR7qkrOOd7UsoKVnPs5hTKtF7B/qH3 bpuh/rpZ2dM04LeFC0+PsleCpcMZubUbDS0ODLdX7bjzz6XXkdZjvHG8QFNwX/UwLvja 7FTg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=doKx4CYK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=OBtJv0UY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-163898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163898-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id j14-20020a63594e000000b005ce087e004dsi21298241pgm.799.2024.04.30.05.09.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 05:09:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-163898-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=@suse.cz header.s=susede2_rsa header.b=doKx4CYK; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; dkim=pass header.i=@suse.cz header.s=susede2_rsa header.b=OBtJv0UY; dkim=neutral (no key) header.i=@suse.cz header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.cz dkim=pass dkdomain=suse.cz dkim=pass dkdomain=suse.cz); spf=pass (google.com: domain of linux-kernel+bounces-163898-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-163898-linux.lists.archive=gmail.com@vger.kernel.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id B191828171C for ; Tue, 30 Apr 2024 12:09:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 966E013D88A; Tue, 30 Apr 2024 12:09:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="doKx4CYK"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="5o9k4diO"; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b="OBtJv0UY"; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b="F2g/VsCd" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 B31E2168A9; Tue, 30 Apr 2024 12:09:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714478954; cv=none; b=dBR0tTMSdeD61epEKkeeO9O7dYgXmmM+qNQEzQMcoAJ+4Kij4pEIrz0W+ZR1SKtQ5ZgDCuLGGtoUFpmBfJp0MdBDO/BWha5bYHt1VrKpXk0xEVBTNj7+jTbvwfU8+ySLcXhENyPc7xXg79mZCDYIGTG0+D3cVrtgDzjCK91e4jQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714478954; c=relaxed/simple; bh=GtIDDflgYwrQAefbYI2ptdeJ3vvMwB2mbzjjnSsBwC0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=ZvbSmjR7ec4tbvSCXQgCHWeceeHOWNxiAColeEbgk/ltMixCqqiPQJ37CEUag84JJ2kUK6GRJ+OPwrM5K53P8+9WtWxfEgQ+T9uakX+4hzzH1/sVj3yTeumkFjNvsFnH+XP7Zru9uVwb8lVsiXYrsE2+IXpEDdriZoA4fy+lBsA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz; spf=pass smtp.mailfrom=suse.cz; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=doKx4CYK; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=5o9k4diO; dkim=pass (1024-bit key) header.d=suse.cz header.i=@suse.cz header.b=OBtJv0UY; dkim=permerror (0-bit key) header.d=suse.cz header.i=@suse.cz header.b=F2g/VsCd; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=suse.cz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.cz Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id CE60B33FC8; Tue, 30 Apr 2024 12:09:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714478951; h=from:from:reply-to: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:autocrypt:autocrypt; bh=ulxbG0KkC2gvBCetlLzOptoa891y9Q3oQRZRhcD0UrE=; b=doKx4CYKKGhY3WlExEeM9DPMM35tls4vveAiUobyAXzHBJh3S/lq61o4JIx8V4rE/UvdTS Bwn+AgVjAw88x+EK0+nW0DqGK21wk0EoiX48gBkGAu4Wn3eM2k97BKit6FMBTDgy2aWhg5 F6usTpIYtOs8EAymDmHOnoP6yREvgEc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714478951; h=from:from:reply-to: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:autocrypt:autocrypt; bh=ulxbG0KkC2gvBCetlLzOptoa891y9Q3oQRZRhcD0UrE=; b=5o9k4diOZzFdXWqyXnxapiFvRgKebQfRWvIAxq7q76GvpQmDg1S6Kz61R6NRKnaGd5/9rR owADXnw8E2EZ2aDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_rsa; t=1714478950; h=from:from:reply-to: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:autocrypt:autocrypt; bh=ulxbG0KkC2gvBCetlLzOptoa891y9Q3oQRZRhcD0UrE=; b=OBtJv0UYnCLwxl4ZbS5Jff+U+nEUtmQc8NuxD4Vsx0hNL5SfgmMXT+4bAx9vnBEIUw7TH5 njRVnhgiIUjOJHMBkcStPOi4pectY4T7JoF1JOBNELUHmmIRGbLxcgCPl4c5zTqvfyKV+A fgvK5aXlWF7k+oGB3MSABWz5jU0rkoA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.cz; s=susede2_ed25519; t=1714478950; h=from:from:reply-to: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:autocrypt:autocrypt; bh=ulxbG0KkC2gvBCetlLzOptoa891y9Q3oQRZRhcD0UrE=; b=F2g/VsCd/pDzczMfAeOKDFocscwfzCd0RSiq0HzxscAz8pG1GUMx15FVWpEITInKZm4tIh eJtK7R+0Pjj4DkBA== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id A64FD137BA; Tue, 30 Apr 2024 12:09:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id azLpJ2bfMGa+FwAAD6G6ig (envelope-from ); Tue, 30 Apr 2024 12:09:10 +0000 Message-ID: <6a10be7d-b556-42a9-852c-b6ed821ec41e@suse.cz> Date: Tue, 30 Apr 2024 14:09:10 +0200 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] mm/slab: make __free(kfree) accept error pointers Content-Language: en-US To: Matthew Wilcox , Dan Carpenter Cc: Christoph Lameter , Peter Zijlstra , Pekka Enberg , David Rientjes , Joonsoo Kim , Andrew Morton , Roman Gushchin , Hyeonggon Yoo <42.hyeyoo@gmail.com>, linux-mm@kvack.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Bartosz Golaszewski , "Lameter, Christopher" References: <285fee25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IIQmx2scYsRBUwm5VI EurRWKqENcDRjyo+ol59j0FViYysjQQeobXBDDE31t5SBg++veI6tXfpco/UiKEsDswL1WAr tEAZaruo7254TyH+gydURl2wJuzo/aZ7Y7PpqaODbYv727Dvm5eX64HCyyAH0s6sOCyGF5/p eIhrOn24oBf67KtdAN3H9JoFNUVTYJc1VJU3R1JtVdgwEdr+NEciEfYl0O19VpLE/PZxP4wX PWnhf5WjdoNI1Xec+RcJ5p/pSel0jnvBX8L2cmniYnmI883NhtGZsEWj++wyKiS4NranDFlA HdDM3b4lUth1pTtABKQ1YuTvehj7EfoWD3bv9kuGZGPrAeFNiHPdOT7DaXKeHpW9homgtBxj 8aX/UkSvEGJKUEbFL9cVa5tzyialGkSiZJNkWgeHe+jEcfRT6pJZOJidSCdzvJpbdJmm+eED w9XOLH1IIWh7RURU7G1iOfEfmImFeC3cbbS73LQEFGe1urxvIH5K/7vX+FkNcr9ujwWuPE9b 1C2o4i/yZPLXIVy387EjA6GZMqvQUFuSTs/GeBcv0NjIQi8867H3uLjz+mQy63fAitsDwLmR EP+ylKVEKb0Q2A== In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Flag: NO X-Spam-Score: -2.79 X-Spam-Level: X-Spamd-Result: default: False [-2.79 / 50.00]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; XM_UA_NO_VERSION(0.01)[]; TAGGED_RCPT(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; RCPT_COUNT_TWELVE(0.00)[15]; MID_RHS_MATCH_FROM(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com]; DKIM_SIGNED(0.00)[suse.cz:s=susede2_rsa,suse.cz:s=susede2_ed25519]; FROM_HAS_DN(0.00)[]; FREEMAIL_CC(0.00)[linux.com,infradead.org,kernel.org,google.com,lge.com,linux-foundation.org,linux.dev,gmail.com,kvack.org,vger.kernel.org,linaro.org,os.amperecomputing.com]; TO_DN_SOME(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_BLOCKED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns] On 4/29/24 5:03 AM, Matthew Wilcox wrote: > On Sun, Apr 28, 2024 at 05:26:44PM +0300, Dan Carpenter wrote: >> Currently, if an automatically freed allocation is an error pointer that >> will lead to a crash. An example of this is in wm831x_gpio_dbg_show(). >> >> 171 char *label __free(kfree) = gpiochip_dup_line_label(chip, i); >> 172 if (IS_ERR(label)) { >> 173 dev_err(wm831x->dev, "Failed to duplicate label\n"); >> 174 continue; >> 175 } >> >> The auto clean up function should check for error pointers as well, >> otherwise we're going to keep hitting issues like this. >> >> Fixes: 54da6a092431 ("locking: Introduce __cleanup() based infrastructure") >> Cc: >> Signed-off-by: Dan Carpenter >> --- >> Obviously, the fixes tag isn't very fair but it will tell the -stable >> tools how far to backport this. >> >> include/linux/slab.h | 4 ++-- >> 1 files changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/include/linux/slab.h b/include/linux/slab.h >> index 4cc37ef22aae..5f5766219375 100644 >> --- a/include/linux/slab.h >> +++ b/include/linux/slab.h >> @@ -279,7 +279,7 @@ void kfree(const void *objp); >> void kfree_sensitive(const void *objp); >> size_t __ksize(const void *objp); >> >> -DEFINE_FREE(kfree, void *, if (_T) kfree(_T)) >> +DEFINE_FREE(kfree, void *, if (!IS_ERR_OR_NULL(_T)) kfree(_T)) > > Wait, why do we check 'if (_T)' at all? kfree() already handles NULL > pointers just fine. I wouldn't be averse to making it handle error > pointers either. Making kfree() handle IS_ERR() is perhaps a discussion for something else than a stable fix. But Christoph has a point that kfree() checks ZERO_OR_NULL_PTR. Here we check IS_ERR_OR_NULL. How about we checked only IS_ERR here so it makes some sense? >> -DEFINE_FREE(kvfree, void *, if (_T) kvfree(_T)) >> +DEFINE_FREE(kvfree, void *, if (!IS_ERR_OR_NULL(_T)) kvfree(_T)) > > Ditto kvfree(). Fixing kfree() would fix both of these. ZERO and NULL should be both false for is_vmalloc_addr() so ultimately kfree() will handle those, so we could also do only IS_ERR here?