Message ID | 20211216200638.935463-1-cascardo@canonical.com |
---|---|
State | Accepted |
Headers | show |
Series | [SRU,H/I/OEM-5.14] NFSD: Fix exposure in nfsd4_decode_bitmap() | expand |
Acked-by: Tim Gardner <tim.gardner@canonical.com> On 12/16/21 1:06 PM, Thadeu Lima de Souza Cascardo wrote: > From: Chuck Lever <chuck.lever@oracle.com> > > rtm@csail.mit.edu reports: >> nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC >> directs it to do so. This can cause nfsd4_decode_state_protect4_a() >> to write client-supplied data beyond the end of >> nfsd4_exchange_id.spo_must_allow[] when called by >> nfsd4_decode_exchange_id(). > > Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond > @bmlen. > > Reported by: rtm@csail.mit.edu > Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > Signed-off-by: J. Bruce Fields <bfields@redhat.com> > (cherry picked from commit c0019b7db1d7ac62c711cda6b357a659d46428fe) > CVE-2021-4090 > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> > --- > fs/nfsd/nfs4xdr.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index be64d3f5e411..0017da5bf23f 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) > p = xdr_inline_decode(argp->xdr, count << 2); > if (!p) > return nfserr_bad_xdr; > - i = 0; > - while (i < count) > - bmval[i++] = be32_to_cpup(p++); > - while (i < bmlen) > - bmval[i++] = 0; > + for (i = 0; i < bmlen; i++) > + bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; > > return nfs_ok; > } >
Acked-by: Kelsey Skunberg <kelsey.skunberg@canonical.com> On 2021-12-16 17:06:38 , Thadeu Lima de Souza Cascardo wrote: > From: Chuck Lever <chuck.lever@oracle.com> > > rtm@csail.mit.edu reports: > > nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC > > directs it to do so. This can cause nfsd4_decode_state_protect4_a() > > to write client-supplied data beyond the end of > > nfsd4_exchange_id.spo_must_allow[] when called by > > nfsd4_decode_exchange_id(). > > Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond > @bmlen. > > Reported by: rtm@csail.mit.edu > Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > Signed-off-by: J. Bruce Fields <bfields@redhat.com> > (cherry picked from commit c0019b7db1d7ac62c711cda6b357a659d46428fe) > CVE-2021-4090 > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> > --- > fs/nfsd/nfs4xdr.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index be64d3f5e411..0017da5bf23f 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) > p = xdr_inline_decode(argp->xdr, count << 2); > if (!p) > return nfserr_bad_xdr; > - i = 0; > - while (i < count) > - bmval[i++] = be32_to_cpup(p++); > - while (i < bmlen) > - bmval[i++] = 0; > + for (i = 0; i < bmlen; i++) > + bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; > > return nfs_ok; > } > -- > 2.32.0 > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team
Applied to master-next for hirsute and impish. Thank you! -Kelsey On 2021-12-16 17:06:38 , Thadeu Lima de Souza Cascardo wrote: > From: Chuck Lever <chuck.lever@oracle.com> > > rtm@csail.mit.edu reports: > > nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC > > directs it to do so. This can cause nfsd4_decode_state_protect4_a() > > to write client-supplied data beyond the end of > > nfsd4_exchange_id.spo_must_allow[] when called by > > nfsd4_decode_exchange_id(). > > Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond > @bmlen. > > Reported by: rtm@csail.mit.edu > Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > Signed-off-by: J. Bruce Fields <bfields@redhat.com> > (cherry picked from commit c0019b7db1d7ac62c711cda6b357a659d46428fe) > CVE-2021-4090 > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> > --- > fs/nfsd/nfs4xdr.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index be64d3f5e411..0017da5bf23f 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) > p = xdr_inline_decode(argp->xdr, count << 2); > if (!p) > return nfserr_bad_xdr; > - i = 0; > - while (i < count) > - bmval[i++] = be32_to_cpup(p++); > - while (i < bmlen) > - bmval[i++] = 0; > + for (i = 0; i < bmlen; i++) > + bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; > > return nfs_ok; > } > -- > 2.32.0 > > > -- > kernel-team mailing list > kernel-team@lists.ubuntu.com > https://lists.ubuntu.com/mailman/listinfo/kernel-team
On 16.12.2021 22.06, Thadeu Lima de Souza Cascardo wrote: > From: Chuck Lever <chuck.lever@oracle.com> > > rtm@csail.mit.edu reports: >> nfsd4_decode_bitmap4() will write beyond bmval[bmlen-1] if the RPC >> directs it to do so. This can cause nfsd4_decode_state_protect4_a() >> to write client-supplied data beyond the end of >> nfsd4_exchange_id.spo_must_allow[] when called by >> nfsd4_decode_exchange_id(). > > Rewrite the loops so nfsd4_decode_bitmap() cannot iterate beyond > @bmlen. > > Reported by: rtm@csail.mit.edu > Fixes: d1c263a031e8 ("NFSD: Replace READ* macros in nfsd4_decode_fattr()") > Signed-off-by: Chuck Lever <chuck.lever@oracle.com> > Signed-off-by: J. Bruce Fields <bfields@redhat.com> > (cherry picked from commit c0019b7db1d7ac62c711cda6b357a659d46428fe) > CVE-2021-4090 > Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@canonical.com> > --- > fs/nfsd/nfs4xdr.c | 7 ++----- > 1 file changed, 2 insertions(+), 5 deletions(-) > > diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c > index be64d3f5e411..0017da5bf23f 100644 > --- a/fs/nfsd/nfs4xdr.c > +++ b/fs/nfsd/nfs4xdr.c > @@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) > p = xdr_inline_decode(argp->xdr, count << 2); > if (!p) > return nfserr_bad_xdr; > - i = 0; > - while (i < count) > - bmval[i++] = be32_to_cpup(p++); > - while (i < bmlen) > - bmval[i++] = 0; > + for (i = 0; i < bmlen; i++) > + bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; > > return nfs_ok; > } > applied to oem-5.14, thanks
diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index be64d3f5e411..0017da5bf23f 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -288,11 +288,8 @@ nfsd4_decode_bitmap4(struct nfsd4_compoundargs *argp, u32 *bmval, u32 bmlen) p = xdr_inline_decode(argp->xdr, count << 2); if (!p) return nfserr_bad_xdr; - i = 0; - while (i < count) - bmval[i++] = be32_to_cpup(p++); - while (i < bmlen) - bmval[i++] = 0; + for (i = 0; i < bmlen; i++) + bmval[i] = (i < count) ? be32_to_cpup(p++) : 0; return nfs_ok; }