From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 2CE5A212B1A for ; Wed, 22 Jan 2025 12:00:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737547208; cv=none; b=hECzz4QNst2MNooAhb7nGfMGcPvT7te9iJIkinhP4mMP1A7BrV6HCTLPrjfdVgIbF7fsXVDAahFWIeeqri4BmNDotUfTGbr+Gdmbu9IASy8yAozGaXI5Msu6cV3bm5/wOlPoGbK8snHTR9Pb5+Jkrlnujvjs82f7/jEORRtId2k= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1737547208; c=relaxed/simple; bh=JTiiUwfpur2s7UQ9ZRJEQTwGRhl0uvMOuAxGd3wUPSM=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=Y8cmkfLNGp5/eaqMwqZovn25Shm2v4ynGCqMhlIvWu+OgKI47fRl7YI6hlWCquBT5IJHWJqUgY9S9nlD2jxOgAiGbObMtAq/aO7kD+jDrzIC/I1jfV0GX+/zsqUCzSYekDMYQegF30eXbRbI/ghz6hqfmij6xx4VMjueLgH6NYg= 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=ZCg7WSDF; arc=none smtp.client-ip=209.85.221.45 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ZCg7WSDF" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-3862ca8e0bbso5522480f8f.0 for ; Wed, 22 Jan 2025 04:00:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1737547205; x=1738152005; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=emPcfBpkB0Lpj8Qvfx5eQdF6Zl9UkKOkQ2t3+yyNddw=; b=ZCg7WSDFyFwu4+FUWjXCa3UObxgyfezONcaqhZS8zPtBXIajt8vV+rXKAW2eOgSifJ lKjqS7RhNATqGcf43yilOACzh2hKAIuu8cX1H5Js4NDbO/C2nWWgc0MX7QHHLPP8DGl+ yW74KUXTmgLNHdjd0N6usyT3y4JyNtksZ1veAr0gPx+BB/5SGoYIHEqRU9bTA32kQg3k 8CRtFqNtPszixjmMtlys2K7AROZqeuUFSfuQVHakbNdDz+q2F5rZ9s+gRrQj/prb8of4 +bb6+CSyoTWOA/NxEkTkFkMGiqmI6vgpzeUvLQ8ybz5xi/HfcA0AenlM8A365s15LIIz RnkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1737547205; x=1738152005; h=content-transfer-encoding:in-reply-to:content-language:from :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=emPcfBpkB0Lpj8Qvfx5eQdF6Zl9UkKOkQ2t3+yyNddw=; b=VspY8sWAOPQrMJomZaTZ2JPjHbrdkuQqzbq/7IFe1bN3Cj6pzhWWsEdwWr/vj7VQcu oRgkVUjDA2MJVk4zii9bcqvnBpd+86p97rn7Ef3t2YdxJ0GiLx3UzhN6agcq2qlTpXPc 7Y1u4Ki4QAMFF1gkFbjzm0YFwffv5JeMMn/+JftHliYHSZcne062BUrlyMLhTcJuwMCa 7qpKJlDFpypKcbNMioNtOnV1PC9zrOE8SlLwmKqOQXINhI7iZwqFTt/YvCQ7QNauGRHZ c79wH/cjFleipgutxIU/lHabnA16LeCgFUVifjGoo91mlIkw0AGNcs4bmQYXBCFLoM+V 1MKQ== X-Forwarded-Encrypted: i=1; AJvYcCU4ixikY5jzEr8TKU8XuXaRSURi5jQQXFORZxhM0SFufg7wLeV3e2R0QDuNkOVwU9ubrDFVE9FK+x+5hVQ=@vger.kernel.org X-Gm-Message-State: AOJu0YzlvxVt1hHsD3h/afTS4yVXfX87C/+3ShyN9AADqex5z3Va1Nln VWgoNvcoNq9C33R+lpet5lGDNUutgLV2Q8MfYID6ARf1ggYkeNFsj12/4s3d53vEo0vcsbuf++h 7puk= X-Gm-Gg: ASbGncsVkT3vViVaPit0VZUCVs89BOPKnVk6L+rCtcp2Ix6hMVF17UX2xssdX9RHT1e 75s9rz9OMyXgFUmvQ1Vxt0F86aT7eCXLwvgmf1yGrbQsrIJMLipI/X1+mHcBofTKMnmoU7kZRa0 JIuALkDmKF4bXaHAVZRlQCDWaI5MSmScuv321SHdXceL5ATH+KU1VJ96IZFt8Uw6jTykg5xz2Ak hspUjSKcMFTOPsbpQVICSCKfzEiUopKdTKlBesGAh7qXy1LS4b+0bezSqCM3QsbeAT9rMAZd/D7 7A== X-Google-Smtp-Source: AGHT+IE16r+ket2E8khA78y776u4bFfWeCwwvrE4JU1JIMZM6fCMmM7k22jAe/StCejERkA6nSlTqg== X-Received: by 2002:a5d:64a3:0:b0:385:f909:eb2c with SMTP id ffacd0b85a97d-38bf57a77a2mr25500383f8f.38.1737547205415; Wed, 22 Jan 2025 04:00:05 -0800 (PST) Received: from [192.168.0.24] ([82.76.24.202]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-438b3124a14sm22189545e9.0.2025.01.22.04.00.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 22 Jan 2025 04:00:04 -0800 (PST) Message-ID: <8836281c-e6cc-4731-9f97-dbd97fe0b0fc@linaro.org> Date: Wed, 22 Jan 2025 14:00:03 +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] pstore/zone: fix return value for psz_init_zones To: kees@kernel.org Cc: linux-hardening@vger.kernel.org, linux-kernel@vger.kernel.org References: <20250121150617.608118-1-eugen.hristev@linaro.org> From: Eugen Hristev Content-Language: en-US In-Reply-To: <20250121150617.608118-1-eugen.hristev@linaro.org> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 1/21/25 17:06, Eugen Hristev wrote: > psz_init_zones is not supposed to return NULL. It returns an errno, > and its caller always checks for an errno to look for a problem. > If the caller receives a NULL as a return, this code will go further > without any errors: > > cxt->kpszs = psz_init_zones(PSTORE_TYPE_DMESG, &off, > info->total_size - off_size, > info->kmsg_size, &cxt->kmsg_max_cnt); > if (IS_ERR(cxt->kpszs)) { > err = PTR_ERR(cxt->kpszs); > cxt->kpszs = NULL; > goto free_out; > } > > Later, when dereferencing kpszs, a panic would occur. > > Thus, to avoid this possible crash, it's better to avoid returning NULL > in psz_init_zones, and just return -EINVAL if the parameters received > are wrong (in this case, a zero size request). Please disregard this patch. I found a case when NULL is being used meaningfully so I have to find a better way to handle this. Sorry for the noise.