From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oa1-f69.google.com (mail-oa1-f69.google.com [209.85.160.69]) (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 C53D0370D6D for ; Sun, 3 May 2026 22:02:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.160.69 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777845781; cv=none; b=IgMyDjR1iOY+420zY1OBYYKcWj98tygFXhHdZ9mNuLH+jP4mWX2cHFQOd1TS1mxDxKc0/+40J2Z0rGaD3GVXa4hqif6dm5pmP2YxDGp05ndykoSBnF6Q4f/BE7CqMKDBiNjanHF6LNBcpQFowJ0k8v6bU+Qq3m091xoyjNszxz0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777845781; c=relaxed/simple; bh=i48O8YoXSm4eZPa4K4f66lPi/Omw6Syg0gzJob+F//w=; h=MIME-Version:Date:In-Reply-To:Message-ID:Subject:From:To: Content-Type; b=X6/9OgEXEAzpvC4OGjHyn/lVGymZeAbb0ALA6CjDwtg6IJsFmOQ39odCXyZDz/xwDT3Cn89WGwqvwD/ttLPyAQ6Ef10mkT/oRM+TpOFeKqaHkEQziO/SKt2zt18lRUfgs/E+k+NuOKS8mf7dmvv+b41rlM3YzcorjUsNMD9zz1s= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com; arc=none smtp.client-ip=209.85.160.69 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=syzkaller.appspotmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=M3KW2WVRGUFZ5GODRSRYTGD7.apphosting.bounces.google.com Received: by mail-oa1-f69.google.com with SMTP id 586e51a60fabf-4344aa5652fso5752136fac.2 for ; Sun, 03 May 2026 15:02:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777845779; x=1778450579; h=content-transfer-encoding:to:from:subject:message-id:in-reply-to :date:mime-version:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=TPtH941kkvA5eKZayL08ETQWSGkwyLeOO2PiBvuUTzk=; b=HJ8bwbKp+Pli8UcXlZRUeBQewUxX5+96yKhnATrt2cbLBMGg6Z+vEmZZ1T0pTvNvc4 Ob5+aNuEYrrpTPmeHj9nk/5dgB6U6j65DeOvBad8+EZk0AoSte+DwB0rAM+abJ+0LvT/ 5YBznCqJ3OWCFul17bNTQG64kwxOPs2JYkq8guP9zUDDF989uKMa4glgZs5YhLf7JReR 8U/qt/L7QN/8XRUlGckhHEaGPW+FyBe4wzwD5ZVdkyHMgWagPSSUXGTREm1+dAk82Ug4 8tgUeUTJbMoSYsb5mDcTdtimqHaT5iPRa2JPQbdOAGDb7HjQTPMRBe4HSI5yr3QWgwUZ /FHg== X-Gm-Message-State: AOJu0YwgejS20rbF7OLzg0AQmMCe7s1P8HJqL/brcuA2Cb0ij45obobf 42Ofh+52Oya4his/FGc0iZDYOyLF4kRHFkWF8TuYThkF8v8y+LeC+cJrdk+ZzFTYEx9XEbhFAwH fGxCUIOyTfGgcMbjzkLbbDxA1EGunD2SM7yjbsTYyskgj/orCi0odvFLKQ5c= Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Received: by 2002:a05:6820:1c86:b0:67d:e7c3:3c65 with SMTP id 006d021491bc7-69697e4038amr3530784eaf.56.1777845778770; Sun, 03 May 2026 15:02:58 -0700 (PDT) Date: Sun, 03 May 2026 15:02:58 -0700 In-Reply-To: <69e4ee46.a00a0220.1bd0ca.0058.GAE@google.com> X-Google-Appengine-App-Id: s~syzkaller X-Google-Appengine-App-Id-Alias: syzkaller Message-ID: <69f7c612.050a0220.1584b9.0050.GAE@google.com> Subject: Forwarded: Re: [PATCH] security/keys/encrypted: encrypted_key_alloc(): fix KMSAN uninit-value on dlen From: syzbot To: linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable For archival purposes, forwarding an incoming command email to linux-kernel@vger.kernel.org, syzkaller-bugs@googlegroups.com. *** Subject: Re: [PATCH] security/keys/encrypted: encrypted_key_alloc(): fix KM= SAN uninit-value on dlen Author: pardhuvarma.kernel@gmail.com #syz test KMSAN reports an uninitialized-value use in encrypted_key_alloc() due to dlen being referenced in a compound condition when kstrtol() fails. Split the condition to ensure dlen is only accessed after successful initialization. Preserve original error handling semantics. Reported-by: syzbot+23d7fcd204e3837866ff@syzkaller.appspotmail.com Signed-off-by: PardhuVarma Konduru --- security/keys/encrypted-keys/encrypted.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/security/keys/encrypted-keys/encrypted.c b/security/keys/encrypted-keys/encrypted.c index 56b531587a1e..4bf4b4e8f7b5 100644 --- a/security/keys/encrypted-keys/encrypted.c +++ b/security/keys/encrypted-keys/encrypted.c @@ -588,7 +588,9 @@ static struct encrypted_key_payload *encrypted_key_alloc(struct key *key, int ret; ret =3D kstrtol(datalen, 10, &dlen); - if (ret < 0 || dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE) + if (ret < 0) + return ERR_PTR(-EINVAL); + if (dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE) return ERR_PTR(-EINVAL); format_len =3D (!format) ? strlen(key_format_default) : strlen(format); --=20 2.54.0 On Mon, May 4, 2026 at 3:22=E2=80=AFAM PardhuVarma Konduru < pardhuvarma.kernel@gmail.com> wrote: > KMSAN reports an uninitialized-value use in encrypted_key_alloc() > due to dlen being referenced in a compound condition when kstrtol() > fails. > > Split the condition to ensure dlen is only accessed after successful > initialization. > > Preserve original error handling semantics. > > Reported-by: syzbot+23d7fcd204e3837866ff@syzkaller.appspotmail.com > Signed-off-by: PardhuVarma Konduru > --- > security/keys/encrypted-keys/encrypted.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/security/keys/encrypted-keys/encrypted.c > b/security/keys/encrypted-keys/encrypted.c > index 56b531587a1e..4bf4b4e8f7b5 100644 > --- a/security/keys/encrypted-keys/encrypted.c > +++ b/security/keys/encrypted-keys/encrypted.c > @@ -588,7 +588,9 @@ static struct encrypted_key_payload > *encrypted_key_alloc(struct key *key, > int ret; > > ret =3D kstrtol(datalen, 10, &dlen); > - if (ret < 0 || dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE) > + if (ret < 0) > + return ERR_PTR(-EINVAL); > + if (dlen < MIN_DATA_SIZE || dlen > MAX_DATA_SIZE) > return ERR_PTR(-EINVAL); > > format_len =3D (!format) ? strlen(key_format_default) : > strlen(format); > -- > 2.54.0 > >